17#include <sys/sysctl.h>
19#include <sys/utsname.h>
27 ::memset(&un, 0,
sizeof(un));
29 return llvm::VersionTuple();
32 uint32_t major, minor, update;
33 int status = ::sscanf(un.release,
"%" PRIu32
".%" PRIu32
".%" PRIu32, &major,
37 return llvm::VersionTuple(major);
39 return llvm::VersionTuple(major, minor);
41 return llvm::VersionTuple(major, minor, update);
43 return llvm::VersionTuple();
47 int mib[2] = {CTL_KERN, KERN_OSREV};
49 size_t osrev_len =
sizeof(osrev);
51 if (::sysctl(mib, 2, &osrev, &osrev_len, NULL, 0) == 0)
52 return llvm::formatv(
"{0,10:10}", osrev).str();
60 if (!g_program_filespec) {
61 static const int name[] = {
62 CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME,
64 char path[MAXPATHLEN];
68 if (sysctl(name, __arraycount(name), path, &len, NULL, 0) != -1) {
69 g_program_filespec.
SetFile(path, FileSpec::Style::native);
72 return g_program_filespec;
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
static llvm::VersionTuple GetOSVersion()
static FileSpec GetProgramFileSpec()
static std::optional< std::string > GetOSBuildString()
A class that represents a running process on the host machine.