11#include <OpenMS/build_config.h>
22#elif defined(__APPLE__)
23 #include <sys/types.h>
24 #include <sys/sysctl.h>
39 inline const std::string
OpenMS_OSNames[] = {
"unknown",
"MacOS",
"Windows",
"Linux"};
60 typedef NTSTATUS (WINAPI* RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
61 HMODULE hMod = GetModuleHandleW(L
"ntdll.dll");
64 auto fxPtr =
reinterpret_cast<RtlGetVersionPtr
>(GetProcAddress(hMod,
"RtlGetVersion"));
67 RTL_OSVERSIONINFOW rovi{};
68 rovi.dwOSVersionInfoSize =
sizeof(rovi);
69 if (fxPtr(&rovi) == 0)
71 return std::to_string(rovi.dwMajorVersion) +
"." + std::to_string(rovi.dwMinorVersion)
72 +
"." + std::to_string(rovi.dwBuildNumber);
77#elif defined(__APPLE__)
78 char version[64] = {};
79 size_t len =
sizeof(version);
80 if (sysctlbyname(
"kern.osproductversion", version, &len,
nullptr, 0) == 0)
82 return std::string(version);
85#elif defined(__unix__)
87 std::ifstream ifs(
"/etc/os-release");
89 while (std::getline(ifs, line))
91 if (line.compare(0, 11,
"VERSION_ID=") == 0)
95 if (val.size() >= 2 && val.front() ==
'"' && val.back() ==
'"')
132 os_version_(
"unknown"),
162 size_t bytes =
sizeof(size_t);
166 return OpenMS_ArchNames[
static_cast<size_t>(OpenMS_Architecture::ARCH_32BIT)];
168 return OpenMS_ArchNames[
static_cast<size_t>(OpenMS_Architecture::ARCH_64BIT)];
170 return OpenMS_ArchNames[
static_cast<size_t>(OpenMS_Architecture::ARCH_UNKNOWN)];
195 info.
os_ = OpenMS_OS::OS_WINDOWS;
196 #elif (defined(__MACH__) && defined(__APPLE__))
197 info.
os_ = OpenMS_OS::OS_MACOS;
198 #elif (defined(__unix__))
199 info.
os_ = OpenMS_OS::OS_LINUX;
206 if (
sizeof(
void*) == 4)
208 info.
arch_ = OpenMS_Architecture::ARCH_32BIT;
212 info.
arch_ = OpenMS_Architecture::ARCH_64BIT;
246 return OPENMS_BUILD_TYPE;
259 return omp_get_max_threads();
273 omp_set_num_threads(num_threads);
Snapshot of the runtime operating system: name, version, and pointer-width architecture.
Definition BuildInfo.h:123
std::string getArchAsString() const
Return the running architecture ("32 bit", "64 bit", or "unknown") as detected by getOSInfo from the ...
Definition BuildInfo.h:143
static std::string getActiveSIMDExtensions()
Return a comma-separated list of SIMD instruction sets compiled into this binary.
std::string getOSVersionAsString() const
Return the OS version captured by getOSInfo (e.g. "10.15" on macOS or "10.0.19045" on Windows); "unkn...
Definition BuildInfo.h:149
OpenMS_Architecture arch_
Definition BuildInfo.h:126
OpenMSOSInfo()
Construct an empty instance with all fields set to "unknown". Use getOSInfo to probe the runtime plat...
Definition BuildInfo.h:130
static std::string getBinaryArchitecture()
Return the pointer width of this binary, derived from sizeof(size_t).
Definition BuildInfo.h:160
static OpenMSOSInfo getOSInfo()
Probe the running platform and return a populated OpenMSOSInfo.
Definition BuildInfo.h:191
std::string os_version_
Definition BuildInfo.h:125
OpenMS_OS os_
Definition BuildInfo.h:124
std::string getOSAsString() const
Return the running operating system name ("Windows", "MacOS", "Linux", or "unknown").
Definition BuildInfo.h:137
int Int
Signed integer type.
Definition Types.h:72
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
std::string getOSVersionString_()
Return the running OS version using a platform-specific probe.
Definition BuildInfo.h:56
const std::string OpenMS_ArchNames[]
String labels paired with OpenMS_Architecture; index by static_cast<size_t>(enum_value).
Definition BuildInfo.h:43
OpenMS_Architecture
Pointer-width architectures OpenMSOSInfo can report. SIZE_OF_OPENMS_ARCHITECTURE is a sentinel for ar...
Definition BuildInfo.h:41
@ SIZE_OF_OPENMS_ARCHITECTURE
OpenMS_OS
Operating systems OpenMSOSInfo can report. SIZE_OF_OPENMS_OS is a sentinel for array sizing.
Definition BuildInfo.h:37
const std::string OpenMS_OSNames[]
String labels paired with OpenMS_OS; index by static_cast<size_t>(enum_value).
Definition BuildInfo.h:39
std::string substr(const std::string &s, size_t pos=0, size_t n=std::string::npos)
Wrapper around std::string::substr; clamps pos to [0, size].
Definition StringUtils.h:525
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Build-configuration accessors: build type, OpenMP availability, and OpenMP thread count.
Definition BuildInfo.h:230
static Size getOpenMPMaxNumThreads()
Return the maximum number of OpenMP threads (including hyperthreads).
Definition BuildInfo.h:256
static void setOpenMPNumThreads(Int num_threads)
Override the OpenMP thread count for subsequent parallel regions.
Definition BuildInfo.h:270
static bool isOpenMPEnabled()
Return true when the library was compiled with OpenMP support (_OPENMP defined), false otherwise.
Definition BuildInfo.h:234
static std::string getBuildType()
Return the CMake build type baked into the library (e.g. "Release", "Debug"), captured from the OPENM...
Definition BuildInfo.h:244