From 9243caa8d3723e808f4679fe5bb3b97ebfa1b4fe Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Wed, 25 Sep 2019 18:03:18 +0000 Subject: [PATCH] Add linux-compatible memfd_create memfd_create is effectively a SHM_ANON shm_open(2) mapping with optional CLOEXEC and file sealing support. This is used by some mesa parts, some linux libs, and qemu can also take advantage of it and uses the sealing to prevent resizing the region. This reimplements shm_open in terms of shm_open2(2) at the same time. shm_open(2) will be moved to COMPAT12 shortly. Reviewed by: markj, kib Differential Revision: https://reviews.freebsd.org/D21393 --- newlib/libc/sys/rtems/include/sys/mman.h | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/newlib/libc/sys/rtems/include/sys/mman.h b/newlib/libc/sys/rtems/include/sys/mman.h index 6e178d83d..867b68647 100644 --- a/newlib/libc/sys/rtems/include/sys/mman.h +++ b/newlib/libc/sys/rtems/include/sys/mman.h @@ -182,6 +182,30 @@ */ #define SHM_ALLOW_SEALING 0x00000001 +/* + * Flags for memfd_create(). + */ +#define MFD_ALLOW_SEALING 0x00000001 +#define MFD_CLOEXEC 0x00000002 + +/* UNSUPPORTED */ +#define MFD_HUGETLB 0x00000004 + +#define MFD_HUGE_MASK 0xFC000000 +#define MFD_HUGE_SHIFT 26 +#define MFD_HUGE_64KB (16 << MFD_HUGE_SHIFT) +#define MFD_HUGE_512KB (19 << MFD_HUGE_SHIFT) +#define MFD_HUGE_1MB (20 << MFD_HUGE_SHIFT) +#define MFD_HUGE_2MB (21 << MFD_HUGE_SHIFT) +#define MFD_HUGE_8MB (23 << MFD_HUGE_SHIFT) +#define MFD_HUGE_16MB (24 << MFD_HUGE_SHIFT) +#define MFD_HUGE_32MB (25 << MFD_HUGE_SHIFT) +#define MFD_HUGE_256MB (28 << MFD_HUGE_SHIFT) +#define MFD_HUGE_512MB (29 << MFD_HUGE_SHIFT) +#define MFD_HUGE_1GB (30 << MFD_HUGE_SHIFT) +#define MFD_HUGE_2GB (31 << MFD_HUGE_SHIFT) +#define MFD_HUGE_16GB (34 << MFD_HUGE_SHIFT) + #endif /* __BSD_VISIBLE */ /* @@ -242,6 +266,9 @@ int munlockall(void); int shm_open(const char *, int, mode_t); int shm_unlink(const char *); #endif +#if __BSD_VISIBLE +int memfd_create(const char *, unsigned int); +#endif __END_DECLS #endif /* !_KERNEL */