summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2017-11-26 23:58:25 +0000
committerRich Felker <dalias@aerifal.cx>2018-02-22 18:48:12 -0500
commitabdaba8616c29b0814a4dbe726224b6f2c9f8604 (patch)
tree8bf71934fb4141cdd8e519621bd06544062119ef /include
parentfba3059d72e610944339ab139b01ea0c97d8f7c6 (diff)
downloadmusl-abdaba8616c29b0814a4dbe726224b6f2c9f8604.tar.gz
musl-abdaba8616c29b0814a4dbe726224b6f2c9f8604.tar.bz2
musl-abdaba8616c29b0814a4dbe726224b6f2c9f8604.tar.xz
musl-abdaba8616c29b0814a4dbe726224b6f2c9f8604.zip
sys/{mman,shm}.h: add {MAP,SHM}_HUGE_ macros from linux uapi
*_HUGE_SHIFT, *_HUGE_2MB, *_HUGE_1GB are documented in the man page, so add all of the *_HUGE_* macros from linux uapi. if MAP_HUGETLB is set, top bits of the mmap flags encode the page size. see the linux commit aafd4562dfee81a40ba21b5ea3cf5e06664bc7f6 if SHM_HUGETLB is set, top bits of the shmget flags encode the page size. see the linux commit 4da243ac1cf6aeb30b7c555d56208982d66d6d33 *_HUGE_16GB is defined unsigned to avoid signed left shift ub.
Diffstat (limited to 'include')
-rw-r--r--include/sys/mman.h13
-rw-r--r--include/sys/shm.h13
2 files changed, 26 insertions, 0 deletions
diff --git a/include/sys/mman.h b/include/sys/mman.h
index 12318782..d13d4ca3 100644
--- a/include/sys/mman.h
+++ b/include/sys/mman.h
@@ -35,6 +35,19 @@ extern "C" {
#define MAP_HUGETLB 0x40000
#define MAP_FILE 0
+#define MAP_HUGE_SHIFT 26
+#define MAP_HUGE_MASK 0x3f
+#define MAP_HUGE_64KB (16 << 26)
+#define MAP_HUGE_512KB (19 << 26)
+#define MAP_HUGE_1MB (20 << 26)
+#define MAP_HUGE_2MB (21 << 26)
+#define MAP_HUGE_8MB (23 << 26)
+#define MAP_HUGE_16MB (24 << 26)
+#define MAP_HUGE_256MB (28 << 26)
+#define MAP_HUGE_1GB (30 << 26)
+#define MAP_HUGE_2GB (31 << 26)
+#define MAP_HUGE_16GB (34U << 26)
+
#define PROT_NONE 0
#define PROT_READ 1
#define PROT_WRITE 2
diff --git a/include/sys/shm.h b/include/sys/shm.h
index 67be822b..e7d39ff6 100644
--- a/include/sys/shm.h
+++ b/include/sys/shm.h
@@ -40,6 +40,19 @@ extern "C" {
#define SHM_HUGETLB 04000
#define SHM_NORESERVE 010000
+#define SHM_HUGE_SHIFT 26
+#define SHM_HUGE_MASK 0x3f
+#define SHM_HUGE_64KB (16 << 26)
+#define SHM_HUGE_512KB (19 << 26)
+#define SHM_HUGE_1MB (20 << 26)
+#define SHM_HUGE_2MB (21 << 26)
+#define SHM_HUGE_8MB (23 << 26)
+#define SHM_HUGE_16MB (24 << 26)
+#define SHM_HUGE_256MB (28 << 26)
+#define SHM_HUGE_1GB (30 << 26)
+#define SHM_HUGE_2GB (31 << 26)
+#define SHM_HUGE_16GB (34U << 26)
+
typedef unsigned long shmatt_t;
void *shmat(int, const void *, int);