10#include "llvm/Support/FormatVariadic.h"
14#include <sys/sysctl.h>
16#include <sys/utsname.h>
24 ::memset(&un, 0,
sizeof(utsname));
26 return llvm::VersionTuple();
28 unsigned major, minor;
29 if (2 == sscanf(un.release,
"%u.%u", &major, &minor))
30 return llvm::VersionTuple(major, minor);
31 return llvm::VersionTuple();
35 int mib[2] = {CTL_KERN, KERN_OSREV};
37 size_t osrev_len =
sizeof(osrev);
39 if (::sysctl(mib, 2, &osrev, &osrev_len, NULL, 0) == 0)
40 return llvm::formatv(
"{0,8:8}", osrev).str();
47 if (!g_program_filespec) {
48 int exe_path_mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, getpid()};
50 size_t exe_path_size =
sizeof(exe_path);
51 if (sysctl(exe_path_mib, 4, exe_path, &exe_path_size, NULL, 0) == 0)
52 g_program_filespec.
SetFile(exe_path, FileSpec::Style::native);
54 return g_program_filespec;
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
static llvm::VersionTuple GetOSVersion()
static std::optional< std::string > GetOSBuildString()
static FileSpec GetProgramFileSpec()
A class that represents a running process on the host machine.