[libc-commits] [libc] [libc] adjust linux's `mman.h` definitions (PR #79652)

Schrodinger ZHU Yifan via libc-commits libc-commits at lists.llvm.org
Fri Jan 26 16:04:33 PST 2024


================
@@ -9,8 +9,40 @@
 #ifndef __LLVM_LIBC_MACROS_SYS_MMAN_MACROS_H
 #define __LLVM_LIBC_MACROS_SYS_MMAN_MACROS_H
 
-#ifdef __linux__
-#include "linux/sys-mman-macros.h"
+// Use definitions from <linux/mman.h> to dispatch arch-specific flag values.
+// For example, MCL_CURRENT/MCL_FUTURE/MCL_ONFAULT are different on different
+// architectures.
+#if __has_include(<linux/mman.h>)
+#include <linux/mman.h>
+#else
+#error "cannot use <sys/mman.h> without proper system headers."
+#endif
+
+// Some posix standard flags may not be defined in system headers.
----------------
SchrodingerZhu wrote:

Yes, `MAP_FAILED` and `POSIX_*` are not provided in UAPI.

https://github.com/llvm/llvm-project/pull/79652


More information about the libc-commits mailing list