Files
TheRock/rocm-systems/projects/rocprofiler-systems/external/dyninst/dataflowAPI/rose/util/Sawyer.C
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

113 lines
2.9 KiB
C++

// WARNING: Changes to this file must be contributed back to Sawyer or else they will
// be clobbered by the next update from Sawyer. The Sawyer repository is at
// https://github.com/matzke1/sawyer.
#include "Sawyer.h"
#include "Message.h"
#include "Synchronization.h"
namespace Sawyer {
class Initializer {
public:
void operator()() {
Message::initializeLibrary();
}
};
#if SAWYER_MULTI_THREADED
static dyncompat::once_flag initFlag = DYNCOMPAT_ONCE_INIT;
#endif
// thread-safe
SAWYER_EXPORT bool
initializeLibrary(size_t vmajor, size_t vminor, size_t vpatch, bool withThreads) {
// Make sure that the application has compiled the correct version and configuration of Sawyer header files. They
// must match the version and configuration expected by the Sawyer library.
if (vmajor != SAWYER_VERSION_MAJOR || vminor != SAWYER_VERSION_MINOR || vpatch != SAWYER_VERSION_PATCH)
throw std::runtime_error("inconsistent compiling/linking with libsawyer: version number mismatch");
if (withThreads != SAWYER_MULTI_THREADED)
throw std::runtime_error("inconsistent compiling/linking with libsawyer: thread support mismatch");
Initializer init;
#if SAWYER_MULTI_THREADED
dyncompat::call_once(initFlag, init);
#else
static bool initialized = false;
if (!initialized) {
init();
initialized = true;
}
#endif
return true;
}
// Presence/absense of strtoll and strtoull depends on the compiler rather than the target environment. For instance, MinGW
// has strtoll and strtoull and lacks _strtoi64 and _strtoui64 even though both MinGW and MVC are targeting a Windows
// environment.
SAWYER_EXPORT int64_t
strtoll(const char *input, char **rest, int base) {
#ifdef _MSC_VER
return _strtoi64(input, rest, base);
#else
return ::strtoll(input, rest, base);
#endif
}
SAWYER_EXPORT uint64_t
strtoull(const char *input, char **rest, int base) {
#ifdef _MSC_VER
return _strtoui64(input, rest, base);
#else
return ::strtoull(input, rest, base);
#endif
}
SAWYER_EXPORT std::string
readOneLine(FILE *stream) {
std::string retval;
while (1) {
int c = fgetc(stream);
if (c < 0)
break;
retval += (char)c;
if ('\n'==c)
break;
}
return retval;
}
SAWYER_EXPORT FILE*
popen(const std::string &cmd, const char *how) {
#ifdef _WIN32
return ::_popen(cmd.c_str(), how);
#else
return ::popen(cmd.c_str(), how);
#endif
}
SAWYER_EXPORT int
pclose(FILE *f) {
#ifdef _WIN32
return ::_pclose(f);
#else
return ::pclose(f);
#endif
}
SAWYER_EXPORT std::string
generateSequentialName(size_t length) {
static size_t ncalls = 0;
size_t sequence = ncalls++;
std::string letters(length, 'a');
for (size_t i=0; i<length && sequence; ++i, sequence/=26)
letters[length-(i+1)] += sequence % 26;
return letters;
}
} // namespace