[llvm] [DRAFT][BOLT] runtime: syscall wrappers cleanup (PR #207190)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 2 06:52:20 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-bolt
Author: DmitriiMartynov
<details>
<summary>Changes</summary>
The BOLT runtime now uses [syscall wrapper implementations](https://github.com/llvm/llvm-project/blob/main/libc/src/__support/OSUtil/linux/syscall.h) from LLVM's libc. This
approach allows to drop arch-specific syscall implementations from the BOLT
runtime, reducing maintenance overhead.
The specific syscall implementations ([read](https://github.com/llvm/llvm-project/blob/main/libc/src/__support/OSUtil/linux/syscall_wrappers/read.h), [write](https://github.com/llvm/llvm-project/blob/main/libc/src/__support/OSUtil/linux/syscall_wrappers/write.h), etc.) from LLVM's libc are
not used in the BOLT runtime to avoid ErrorOr-related complexity. In LLVM libc,
syscall wrappers use ErrorOr to handle errors: they set errno and return -1 on
failure, or return a valid value otherwise. Since the BOLT runtime does not
support errno, it is simpler to use raw syscall wrappers and check for negative
return values to detect errors.
All syscall wrapper return values and argument types are now based on LLVM's
libc implementation:
- Return values are now signed for proper error checking.
- Argument types have been updated to match libc definitions.
Functionality of __exit, __open, and __readlink have been unified across
architectures. Except for __fork, which will be cleaned up later
---
Patch is 66.71 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/207190.diff
9 Files Affected:
- (modified) bolt/runtime/CMakeLists.txt (+7)
- (modified) bolt/runtime/common.h (+23-114)
- (modified) bolt/runtime/hugify.cpp (+17-17)
- (modified) bolt/runtime/instr.cpp (+31-34)
- (added) bolt/runtime/runtime_types.h (+149)
- (modified) bolt/runtime/sys_aarch64.h (+41-330)
- (modified) bolt/runtime/sys_riscv64.h (+39-336)
- (modified) bolt/runtime/sys_x86_64.h (+50-303)
- (added) bolt/runtime/syscall_wrappers.h (+208)
``````````diff
diff --git a/bolt/runtime/CMakeLists.txt b/bolt/runtime/CMakeLists.txt
index 63f178bd263c2..01a617a4c841e 100644
--- a/bolt/runtime/CMakeLists.txt
+++ b/bolt/runtime/CMakeLists.txt
@@ -64,6 +64,13 @@ target_include_directories(bolt_rt_instr PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_compile_options(bolt_rt_hugify PRIVATE ${BOLT_RT_FLAGS})
target_include_directories(bolt_rt_hugify PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+get_filename_component(LIBC_INCLUDE
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../libc
+ ABSOLUTE
+)
+target_include_directories(bolt_rt_instr PRIVATE ${LIBC_INCLUDE})
+target_include_directories(bolt_rt_hugify PRIVATE ${LIBC_INCLUDE})
+
install(TARGETS bolt_rt_instr DESTINATION "lib${LLVM_LIBDIR_SUFFIX}")
install(TARGETS bolt_rt_hugify DESTINATION "lib${LLVM_LIBDIR_SUFFIX}")
diff --git a/bolt/runtime/common.h b/bolt/runtime/common.h
index 96e269e1bb79b..dbbdb15369b41 100644
--- a/bolt/runtime/common.h
+++ b/bolt/runtime/common.h
@@ -5,76 +5,8 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-
-#if defined(__linux__)
-
-#include <cstddef>
-#include <cstdint>
-
-#include "config.h"
-
-#ifdef HAVE_ELF_H
-#include <elf.h>
-#endif
-
-#elif defined(__APPLE__)
-
-typedef __SIZE_TYPE__ size_t;
-#define __SSIZE_TYPE__ \
- __typeof__(_Generic((__SIZE_TYPE__)0, unsigned long long int \
- : (long long int)0, unsigned long int \
- : (long int)0, unsigned int \
- : (int)0, unsigned short \
- : (short)0, unsigned char \
- : (signed char)0))
-typedef __SSIZE_TYPE__ ssize_t;
-
-typedef unsigned long long uint64_t;
-typedef unsigned uint32_t;
-typedef unsigned char uint8_t;
-
-typedef long long int64_t;
-typedef int int32_t;
-
-#else
-#error "For Linux or MacOS only"
-#endif
-
-#define PROT_READ 0x1 /* Page can be read. */
-#define PROT_WRITE 0x2 /* Page can be written. */
-#define PROT_EXEC 0x4 /* Page can be executed. */
-#define PROT_NONE 0x0 /* Page can not be accessed. */
-#define PROT_GROWSDOWN \
- 0x01000000 /* Extend change to start of \
- growsdown vma (mprotect only). */
-#define PROT_GROWSUP \
- 0x02000000 /* Extend change to start of \
- growsup vma (mprotect only). */
-
-/* Sharing types (must choose one and only one of these). */
-#define MAP_SHARED 0x01 /* Share changes. */
-#define MAP_PRIVATE 0x02 /* Changes are private. */
-#define MAP_FIXED 0x10 /* Interpret addr exactly. */
-
-#if defined(__APPLE__)
-#define MAP_ANONYMOUS 0x1000
-#else
-#define MAP_ANONYMOUS 0x20
-#endif
-
-#define MAP_FAILED ((void *)-1)
-
-#define SEEK_SET 0 /* Seek from beginning of file. */
-#define SEEK_CUR 1 /* Seek from current position. */
-#define SEEK_END 2 /* Seek from end of file. */
-
-#define O_RDONLY 0
-#define O_WRONLY 1
-#define O_RDWR 2
-#define O_CREAT 64
-#define O_TRUNC 512
-#define O_APPEND 1024
-#define O_CLOEXEC 524288
+#include "runtime_types.h"
+#include "syscall_wrappers.h"
// Functions that are required by freestanding environment. Compiler may
// generate calls to these implicitly.
@@ -124,44 +56,11 @@ int memcmp(const void *s1, const void *s2, size_t n) {
// Anonymous namespace covering everything but our library entry point
namespace {
-struct dirent64 {
- uint64_t d_ino; /* Inode number */
- int64_t d_off; /* Offset to next linux_dirent */
- unsigned short d_reclen; /* Length of this linux_dirent */
- unsigned char d_type;
- char d_name[]; /* Filename (null-terminated) */
- /* length is actually (d_reclen - 2 -
- offsetof(struct linux_dirent, d_name)) */
-};
-
-/* Length of the entries in `struct utsname' is 65. */
-#define _UTSNAME_LENGTH 65
-
-struct UtsNameTy {
- char sysname[_UTSNAME_LENGTH]; /* Operating system name (e.g., "Linux") */
- char nodename[_UTSNAME_LENGTH]; /* Name within "some implementation-defined
- network" */
- char release[_UTSNAME_LENGTH]; /* Operating system release (e.g., "2.6.28") */
- char version[_UTSNAME_LENGTH]; /* Operating system version */
- char machine[_UTSNAME_LENGTH]; /* Hardware identifier */
- char domainname[_UTSNAME_LENGTH]; /* NIS or YP domain name */
-};
-
-struct timespec {
- uint64_t tv_sec; /* seconds */
- uint64_t tv_nsec; /* nanoseconds */
-};
-
-#if defined(__aarch64__) || defined(__arm64__)
-#include "sys_aarch64.h"
-#elif defined(__riscv)
-#include "sys_riscv64.h"
-#elif defined(__x86_64__)
-#include "sys_x86_64.h"
-#else
-#error "For AArch64/ARM64,X86_64 AND RISCV64 only."
-#endif
-
+// We use a stack-allocated buffer for string manipulation in many pieces of
+// this code, including the code that prints each line of the fdata file. This
+// buffer needs to accommodate large function names, but shouldn't be
+// arbitrarily large (dynamically allocated) for simplicity of our memory space
+// usage.
constexpr uint32_t BufSize = 32768U;
// Helper functions for writing strings to the .fdata file. We intentionally
@@ -306,11 +205,7 @@ void assert(bool Assertion, const char *Msg) {
#endif
}
-#define SIG_BLOCK 0
-#define SIG_UNBLOCK 1
-#define SIG_SETMASK 2
-
-static const uint64_t MaskAllSignals[] = {-1ULL};
+static const sigset_t MaskAllSignals[] = {-1ULL};
class Mutex {
volatile bool InUse{false};
@@ -323,7 +218,7 @@ class Mutex {
/// RAII wrapper for Mutex
class Lock {
Mutex &M;
- uint64_t SignalMask[1] = {};
+ sigset_t SignalMask[1] = {};
public:
Lock(Mutex &M) : M(M) {
@@ -363,4 +258,18 @@ inline uint64_t alignTo(uint64_t Value, uint64_t Align) {
return (Value + Align - 1) / Align * Align;
}
+constexpr intptr_t MaxErrno = 4095;
+// The function is used to detect errors from syscall wrappers that return
+// pointers instead of scalar values (for example, __mmap).
+// The return value of the __mmap wrapper is either a valid address or an error
+// (a negative value), not MAP_FAILED macro. The MAP_FAILED macro is a libc
+// return value of the mmap library function in case of an error where the
+// actual error is returned via errno variable. So, it is incorrect to compare
+// the __mmap syscall wrapper return value with MAP_FAILED, as only the EPERM
+// (-1) error is checked.
+inline bool isErrValue(const void *Val) {
+ const intptr_t PtrVal = reinterpret_cast<intptr_t>(Val);
+ return PtrVal >= -MaxErrno && PtrVal <= -1;
+}
+
} // anonymous namespace
diff --git a/bolt/runtime/hugify.cpp b/bolt/runtime/hugify.cpp
index de896307f24fc..234d26425fdc8 100644
--- a/bolt/runtime/hugify.cpp
+++ b/bolt/runtime/hugify.cpp
@@ -38,6 +38,9 @@ static void getKernelVersion(uint32_t *Val) {
// major, minor, release
struct UtsNameTy UtsName;
int Ret = __uname(&UtsName);
+ if (Ret < 0) {
+ // handle here
+ }
const char *Buf = UtsName.release;
const char *End = Buf + strLen(Buf);
const char Delims[2][2] = {".", "."};
@@ -64,13 +67,13 @@ static void getKernelVersion(uint32_t *Val) {
static bool hasPagecacheTHPSupport() {
char Buf[64];
- int FD = __open("/sys/kernel/mm/transparent_hugepage/enabled",
- 0 /* O_RDONLY */, 0);
+ const int FD =
+ __open("/sys/kernel/mm/transparent_hugepage/enabled", O_RDONLY, 0);
if (FD < 0)
return false;
memset(Buf, 0, sizeof(Buf));
- const size_t Res = __read(FD, Buf, sizeof(Buf));
+ const ssize_t Res = __read(FD, Buf, sizeof(Buf));
if (Res < 0)
return false;
@@ -98,11 +101,9 @@ static bool hasPagecacheTHPSupport() {
static void hugifyForOldKernel(uint8_t *From, uint8_t *To) {
const size_t Size = To - From;
- uint8_t *Mem = reinterpret_cast<uint8_t *>(
- __mmap(0, Size, 0x3 /* PROT_READ | PROT_WRITE */,
- 0x22 /* MAP_PRIVATE | MAP_ANONYMOUS */, -1, 0));
-
- if (Mem == ((void *)-1) /* MAP_FAILED */) {
+ void *Mem = __mmap(0, Size, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ if (isErrValue(Mem)) {
char Msg[] = "[hugify] could not allocate memory for text move\n";
reportError(Msg, sizeof(Msg));
}
@@ -114,19 +115,18 @@ static void hugifyForOldKernel(uint8_t *From, uint8_t *To) {
// Copy the hot code to a temporary location.
memcpy(Mem, From, Size);
- __prctl(41 /* PR_SET_THP_DISABLE */, 0, 0, 0, 0);
+ __prctl(PR_SET_THP_DISABLE, 0, 0, 0, 0);
// Maps out the existing hot code.
- if (__mmap(reinterpret_cast<uint64_t>(From), Size,
- 0x3 /* PROT_READ | PROT_WRITE */,
- 0x32 /* MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE */, -1,
- 0) == ((void *)-1) /*MAP_FAILED*/) {
+ const void *Addr = __mmap(From, Size, PROT_READ | PROT_WRITE,
+ MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+ if (isErrValue(Addr)) {
char Msg[] =
"[hugify] failed to mmap memory for large page move terminating\n";
reportError(Msg, sizeof(Msg));
}
// Mark the hot code page to be huge page.
- if (__madvise(From, Size, 14 /* MADV_HUGEPAGE */) == -1) {
+ if (__madvise(From, Size, MADV_HUGEPAGE) < 0) {
char Msg[] = "[hugify] setting MADV_HUGEPAGE is failed\n";
reportError(Msg, sizeof(Msg));
}
@@ -135,7 +135,7 @@ static void hugifyForOldKernel(uint8_t *From, uint8_t *To) {
memcpy(From, Mem, Size);
// Change permission back to read-only, ignore failure
- __mprotect(From, Size, 0x5 /* PROT_READ | PROT_EXEC */);
+ __mprotect(From, Size, PROT_READ | PROT_EXEC);
__munmap(Mem, Size);
}
@@ -161,8 +161,8 @@ extern "C" void __bolt_hugify_self_impl() {
return;
}
- if (__madvise(From, (To - From), 14 /* MADV_HUGEPAGE */) == -1) {
- char Msg[] = "[hugify] failed to allocate large page\n";
+ if (__madvise(From, (To - From), MADV_HUGEPAGE) < 0) {
+ char Msg[] = "[hugify] setting MADV_HUGEPAGE is failed\n";
// TODO: allow user to control the failure behavior.
reportError(Msg, sizeof(Msg));
}
diff --git a/bolt/runtime/instr.cpp b/bolt/runtime/instr.cpp
index 1e5bddee5793e..390eb32c65cbb 100644
--- a/bolt/runtime/instr.cpp
+++ b/bolt/runtime/instr.cpp
@@ -141,8 +141,7 @@ class BumpPtrAllocator {
StackBase = reinterpret_cast<uint8_t *>(
__mmap(0, MaxSize, PROT_READ | PROT_WRITE,
(Shared ? MAP_SHARED : MAP_PRIVATE) | MAP_ANONYMOUS, -1, 0));
- assert(StackBase != MAP_FAILED,
- "BumpPtrAllocator: failed to mmap stack!");
+ assert(!isErrValue(StackBase), "BumpPtrAllocator: failed to mmap stack!");
StackSize = 0;
}
@@ -703,13 +702,11 @@ static char *getBinaryPath() {
return TargetPath;
unsigned long CurAddr = (unsigned long)__get_pc();
- uint64_t FDdir = __open(DirPath, O_RDONLY,
- /*mode=*/0666);
- assert(static_cast<int64_t>(FDdir) >= 0,
- "failed to open /proc/self/map_files");
+ int FDdir = __open(DirPath, O_RDONLY, /*mode=*/0666);
+ assert(FDdir >= 0, "failed to open /proc/self/map_files");
- while (long Nread = __getdents64(FDdir, (struct dirent64 *)Buf, BufSize)) {
- assert(static_cast<int64_t>(Nread) != -1, "failed to get folder entries");
+ while (ssize_t Nread = __getdents64(FDdir, (struct dirent64 *)Buf, BufSize)) {
+ assert(Nread >= 0, "failed to get folder entries");
struct dirent64 *d;
for (long Bpos = 0; Bpos < Nread; Bpos += d->d_reclen) {
@@ -724,9 +721,8 @@ static char *getBinaryPath() {
char *C = strCopy(FindBuf, DirPath, NameMax);
C = strCopy(C, d->d_name, NameMax - (C - FindBuf));
*C = '\0';
- uint64_t Ret = __readlink(FindBuf, TargetPath, sizeof(TargetPath));
- assert(static_cast<int64_t>(Ret) >= 0 && Ret < sizeof(TargetPath),
- "readlink error");
+ ssize_t Ret = __readlink(FindBuf, TargetPath, sizeof(TargetPath));
+ assert(Ret >= 0 && Ret < sizeof(TargetPath), "readlink error");
TargetPath[Ret] = '\0';
__close(FDdir);
return TargetPath;
@@ -749,17 +745,18 @@ ProfileWriterContext readDescriptions(const uint8_t *BinContents,
const char *BinPath = getBinaryPath();
assert(BinPath && BinPath[0] != '\0', "failed to find binary path");
- uint64_t FD = __open(BinPath, O_RDONLY,
- /*mode=*/0666);
- assert(static_cast<int64_t>(FD) >= 0, "failed to open binary path");
+ int FD = __open(BinPath, O_RDONLY, /*mode=*/0666);
+ assert(FD >= 0, "failed to open binary path");
Result.FileDesc = FD;
// mmap our binary to memory
- Size = __lseek(FD, 0, SEEK_END);
+ off_t Ret = __lseek(FD, 0, SEEK_END);
+ assert(Ret >= 0, "Failed to lseek!");
+ Size = static_cast<uint64_t>(Ret);
BinContents = reinterpret_cast<uint8_t *>(
__mmap(0, Size, PROT_READ, MAP_PRIVATE, FD, 0));
- assert(BinContents != MAP_FAILED, "readDescriptions: Failed to mmap self!");
+ assert(!isErrValue(BinContents), "readDescriptions: Failed to mmap self!");
}
Result.MMapPtr = BinContents;
Result.MMapSize = Size;
@@ -1493,7 +1490,7 @@ void visitCallFlowEntry(CallFlowHashTable::MapEntry &Entry, int FD,
int openProfile() {
// Build the profile name string by appending our PID
char Buf[BufSize];
- uint64_t PID = __getpid();
+ pid_t PID = __getpid();
char *Ptr = strCopy(Buf, __bolt_instr_filename, BufSize);
if (__bolt_instr_use_pid) {
Ptr = strCopy(Ptr, ".", BufSize - (Ptr - Buf + 1));
@@ -1501,13 +1498,11 @@ int openProfile() {
Ptr = strCopy(Ptr, ".fdata", BufSize - (Ptr - Buf + 1));
}
*Ptr++ = '\0';
- uint64_t FD = __open(Buf, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC,
- /*mode=*/0600);
- if (static_cast<int64_t>(FD) < 0) {
+ int FD = __open(Buf, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, /*mode=*/0600);
+ if (FD < 0) {
report("Error while trying to open profile file for writing: ");
report(Buf);
- reportNumber("\nFailed with error number: 0x",
- 0 - static_cast<int64_t>(FD), 16);
+ reportNumber("\nFailed with error number: 0x", FD, 16);
__exit(1);
}
return FD;
@@ -1570,10 +1565,10 @@ __bolt_instr_data_dump(int FD, const char *LibPath = nullptr,
if (!GlobalWriteProfileMutex->acquire())
return;
- int ret = __lseek(FD, 0, SEEK_SET);
- assert(ret == 0, "Failed to lseek!");
- ret = __ftruncate(FD, 0);
- assert(ret == 0, "Failed to ftruncate!");
+ off_t Ret = __lseek(FD, 0, SEEK_SET);
+ assert(Ret >= 0, "Failed to lseek!");
+ int RetTr = __ftruncate(FD, 0);
+ assert(RetTr >= 0, "Failed to ftruncate!");
BumpPtrAllocator HashAlloc;
HashAlloc.setMaxSize(__bolt_instr_max_size);
ProfileWriterContext Ctx = readDescriptions(LibContents, LibSize);
@@ -1611,10 +1606,10 @@ void watchProcess() {
timespec ts, rem;
uint64_t Elapsed = 0ull;
int FD = openProfile();
- uint64_t ppid;
+ int ppid;
if (__bolt_instr_wait_forks) {
// Store parent pgid
- ppid = -__getpgid(0);
+ ppid = __getpgid(0);
// And leave parent process group
__setpgid(0, 0);
} else {
@@ -1673,14 +1668,14 @@ extern "C" void __attribute((force_align_arg_pointer)) __bolt_instr_setup() {
const bool Shared = !__bolt_instr_use_pid | !!__bolt_instr_sleep_time;
const uint64_t MapPrivateOrShared = Shared ? MAP_SHARED : MAP_PRIVATE;
- void *Ret =
- __mmap(CountersStart, CountersEnd - CountersStart, PROT_READ | PROT_WRITE,
- MAP_ANONYMOUS | MapPrivateOrShared | MAP_FIXED, -1, 0);
- assert(Ret != MAP_FAILED, "__bolt_instr_setup: Failed to mmap counters!");
+ void *Ret = __mmap(reinterpret_cast<void *>(CountersStart),
+ CountersEnd - CountersStart, PROT_READ | PROT_WRITE,
+ MAP_ANONYMOUS | MapPrivateOrShared | MAP_FIXED, -1, 0);
+ assert(!isErrValue(Ret), "__bolt_instr_setup: Failed to mmap counters!");
GlobalMetadataStorage = __mmap(0, 4096, PROT_READ | PROT_WRITE,
MapPrivateOrShared | MAP_ANONYMOUS, -1, 0);
- assert(GlobalMetadataStorage != MAP_FAILED,
+ assert(!isErrValue(GlobalMetadataStorage),
"__bolt_instr_setup: failed to mmap page for metadata!");
GlobalAlloc = new (GlobalMetadataStorage) BumpPtrAllocator;
@@ -1704,8 +1699,10 @@ extern "C" void __attribute((force_align_arg_pointer)) __bolt_instr_setup() {
if (__bolt_instr_wait_forks)
__setpgid(0, 0);
- if (long PID = __fork())
+ if (int PID = __fork()) {
+ assert(PID > 0, "__bolt_instr_setup: fork failed");
return;
+ }
watchProcess();
}
}
diff --git a/bolt/runtime/runtime_types.h b/bolt/runtime/runtime_types.h
new file mode 100644
index 0000000000000..c78887ba2e9cc
--- /dev/null
+++ b/bolt/runtime/runtime_types.h
@@ -0,0 +1,149 @@
+//===- bolt/runtime/runtime_types.h -----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TOOLS_LLVM_BOLT_RUNTIME_TYPES
+#define LLVM_TOOLS_LLVM_BOLT_RUNTIME_TYPES
+
+// FIXME: cleanup here
+
+#if defined(__linux__)
+
+#include <cstddef>
+#include <cstdint>
+
+#include "config.h"
+
+#ifdef HAVE_ELF_H
+#include <elf.h>
+#endif
+
+#elif defined(__APPLE__)
+
+typedef __SIZE_TYPE__ size_t;
+#define __SSIZE_TYPE__ \
+ __typeof__(_Generic((__SIZE_TYPE__)0, \
+ unsigned long long int: (long long int)0, \
+ unsigned long int: (long int)0, \
+ unsigned int: (int)0, \
+ unsigned short: (short)0, \
+ unsigned char: (signed char)0))
+typedef __SSIZE_TYPE__ ssize_t;
+
+typedef unsigned long long uint64_t;
+typedef unsigned uint32_t;
+typedef unsigned char uint8_t;
+
+typedef long long int64_t;
+typedef int int32_t;
+
+#else
+#error "For Linux or MacOS only"
+#endif
+
+#ifndef __LP64__
+#error "Only LP64 data model is supported"
+#endif
+
+#define AT_FDCWD -100
+
+#define PROT_READ 0x1 /* Page can be read. */
+#define PROT_WRITE 0x2 /* Page can be written. */
+#define PROT_EXEC 0x4 /* Page can be executed. */
+#define PROT_NONE 0x0 /* Page can not be accessed. */
+#define PROT_GROWSDOWN \
+ 0x01000000 /* Extend change to start of \
+ growsdown vma (mprotect only). */
+#define PROT_GROWSUP \
+ 0x02000000 /* Extend change to start of \
+ growsup vma (mprotect only). */
+
+/* Sharing types (must choose one and only one of these). */
+#define MAP_SHARED 0x01 /* Share changes. */
+#define MAP_PRIVATE 0x02 /* Changes are private. */
+#define MAP_FIXED 0x10 /* Interpret addr exactly. */
+
+#if defined(__APPLE__)
+#define MAP_ANONYMOUS 0x1000
+#else
+#define MAP_ANONYMOUS 0x20
+#endif
+
+#define MADV_HUGEPAGE 14 /* Worth backing with hugepages */
+
+/* set the state of the "THP disable" flags for the calling thread */
+#define PR_SET_THP_DISABLE 41
+
+#define SEEK_SET 0 /* Seek from beginning of file. */
+#define SEEK_CUR 1 /* Seek from current position. */
+#define SEEK_END 2 /* Seek from end of file. */
+
+#define O_RDONLY 0
+#define O_WRONLY 1
+#define O_RDWR 2
+#define O_CREAT 64
+#define O_TRUNC 512
+#define O_APPEND 1024
+#define O_CLOEXEC 524288
+
+#define SIG_BLOCK 0
+#define SIG_UNBLOCK 1
+#define SIG_SETMASK 2
+
+#define CLONE_CHILD_CLEARTID 0x00200000 /* clear the TID in the child */
+#define CLONE_CHILD_SETTID 0x01000000 /* set the TID in the child */
+
+#define SIGCHLD 17
+
+/* Length of the entries in `struct utsname' is 65. */
+#define _UTSNAME_LENGTH 65
+
+#define _NSI...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/207190
More information about the llvm-commits
mailing list