[libc-commits] [libc] 1952c70 - [libc] Add MAP_ANON as a synonym for MAP_ANONYMOUS. (#222789)

via libc-commits libc-commits at lists.llvm.org
Fri Sep 11 07:58:27 PDT 2026


Author: Alexey Samsonov
Date: 2026-09-11T07:58:22-07:00
New Revision: 1952c705fad0187fc0c6fbd1460dbd56d56c8087

URL: https://github.com/llvm/llvm-project/commit/1952c705fad0187fc0c6fbd1460dbd56d56c8087
DIFF: https://github.com/llvm/llvm-project/commit/1952c705fad0187fc0c6fbd1460dbd56d56c8087.diff

LOG: [libc] Add MAP_ANON as a synonym for MAP_ANONYMOUS. (#222789)

`MAP_ANON` is specified in POSIX, but may not be present in Linux kernel
headers,
which we rely on to get the values of other `MAP_` values. Provide this
macro
ourselves to ensure the user code including `<sys/mman.h>` can use it.

Added: 
    

Modified: 
    libc/include/llvm-libc-macros/sys-mman-macros.h
    libc/include/sys/mman.yaml

Removed: 
    


################################################################################
diff  --git a/libc/include/llvm-libc-macros/sys-mman-macros.h b/libc/include/llvm-libc-macros/sys-mman-macros.h
index bc9f783d84a40..0dd5a86240dd9 100644
--- a/libc/include/llvm-libc-macros/sys-mman-macros.h
+++ b/libc/include/llvm-libc-macros/sys-mman-macros.h
@@ -28,6 +28,12 @@
 #define MAP_FAILED ((void *)-1)
 #endif
 
+// MAP_ANON is a synonym for MAP_ANONYMOUS specified in POSIX,
+// but is not always provided by kernel headers.
+#if !defined(MAP_ANON) && defined(MAP_ANONYMOUS)
+#define MAP_ANON MAP_ANONYMOUS
+#endif
+
 // Posix memory advise flags. (posix_madvise)
 #ifndef POSIX_MADV_NORMAL
 #define POSIX_MADV_NORMAL MADV_NORMAL

diff  --git a/libc/include/sys/mman.yaml b/libc/include/sys/mman.yaml
index 04509f4aabffc..bbd3ebaf72d46 100644
--- a/libc/include/sys/mman.yaml
+++ b/libc/include/sys/mman.yaml
@@ -2,6 +2,8 @@ header: sys/mman.h
 standards:
   - posix
 macros:
+  - macro_name: MAP_ANON
+    macro_header: sys-mman-macros.h
   - macro_name: MAP_FAILED
     macro_header: sys-mman-macros.h
 types:


        


More information about the libc-commits mailing list