| ... | ... | @@ -2074,6 +2074,10 @@ pub const libc = struct { |
| 2074 | 2074 | /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/mlockall.html |
| 2075 | 2075 | pub extern fn mlockall(flags: c_int) c_int; |
| 2076 | 2076 | |
| 2077 | /// void *mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off); |
| 2078 | /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/mmap.html |
| 2079 | pub extern fn mmap(addr: ?*anyopaque, len: usize, prot: c_int, flags: c_int, fd: c_int, offset: off_t) *allowzero anyopaque; |
| 2080 | |
| 2077 | 2081 | /// int mq_unlink(const char *name); |
| 2078 | 2082 | /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/mq_unlink.html |
| 2079 | 2083 | pub extern fn mq_unlink(name: [*:0]const u8) c_int; |
| ... | ... | @@ -2086,6 +2090,10 @@ pub const libc = struct { |
| 2086 | 2090 | /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/munlockall.html |
| 2087 | 2091 | pub extern fn munlockall() void; |
| 2088 | 2092 | |
| 2093 | /// int munmap(void *addr, size_t len); |
| 2094 | /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/munmap.html |
| 2095 | pub extern fn munmap(addr: *const anyopaque, len: usize) c_int; |
| 2096 | |
| 2089 | 2097 | /// double nearbyint(double x); |
| 2090 | 2098 | /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/nearbyint.html |
| 2091 | 2099 | pub extern fn nearbyint(x: f64) f64; |
| ... | ... | @@ -2854,6 +2862,55 @@ pub const CLOCK = struct { |
| 2854 | 2862 | pub const TAI = 11; |
| 2855 | 2863 | }; |
| 2856 | 2864 | |
| 2865 | pub const MAP = struct { |
| 2866 | pub const FAILED = -1; |
| 2867 | |
| 2868 | pub const SHARED = 0x01; |
| 2869 | pub const PRIVATE = 0x02; |
| 2870 | pub const SHARED_VALIDATE = 0x03; |
| 2871 | pub const TYPE = 0x0f; |
| 2872 | pub const FIXED = 0x10; |
| 2873 | pub const ANON = 0x20; |
| 2874 | pub const ANONYMOUS = ANON; |
| 2875 | pub const NORESERVE = 0x4000; |
| 2876 | pub const GROWSDOWN = 0x0100; |
| 2877 | pub const DENYWRITE = 0x0800; |
| 2878 | pub const EXECUTABLE = 0x1000; |
| 2879 | pub const LOCKED = 0x2000; |
| 2880 | pub const POPULATE = 0x8000; |
| 2881 | pub const NONBLOCK = 0x10000; |
| 2882 | pub const STACK = 0x20000; |
| 2883 | pub const HUGETLB = 0x40000; |
| 2884 | pub const SYNC = 0x80000; |
| 2885 | pub const FIXED_NOREPLACE = 0x100000; |
| 2886 | pub const FILE = 0; |
| 2887 | |
| 2888 | pub const MAP_HUGE_SHIFT = 26; |
| 2889 | pub const MAP_HUGE_MASK = 0x3f; |
| 2890 | pub const MAP_HUGE_16KB = 14 << 26; |
| 2891 | pub const MAP_HUGE_64KB = 16 << 26; |
| 2892 | pub const MAP_HUGE_512KB = 19 << 26; |
| 2893 | pub const MAP_HUGE_1MB = 20 << 26; |
| 2894 | pub const MAP_HUGE_2MB = 21 << 26; |
| 2895 | pub const MAP_HUGE_8MB = 23 << 26; |
| 2896 | pub const MAP_HUGE_16MB = 24 << 26; |
| 2897 | pub const MAP_HUGE_32MB = 25 << 26; |
| 2898 | pub const MAP_HUGE_256MB = 28 << 26; |
| 2899 | pub const MAP_HUGE_512MB = 29 << 26; |
| 2900 | pub const MAP_HUGE_1GB = 30 << 26; |
| 2901 | pub const MAP_HUGE_2GB = 31 << 26; |
| 2902 | pub const MAP_HUGE_16GB = 34 << 26; |
| 2903 | }; |
| 2904 | |
| 2905 | pub const PROT = struct { |
| 2906 | pub const NONE = 0; |
| 2907 | pub const READ = 1; |
| 2908 | pub const WRITE = 2; |
| 2909 | pub const EXEC = 4; |
| 2910 | pub const GROWSDOWN = 0x01000000; |
| 2911 | pub const GROWSUP = 0x02000000; |
| 2912 | }; |
| 2913 | |
| 2857 | 2914 | pub const NAME_MAX = 255; |
| 2858 | 2915 | pub const PATH_MAX = 4096; |
| 2859 | 2916 | pub const NGROUPS_MAX = 32; |
| ... | ... | @@ -3217,3 +3274,14 @@ pub fn renameat(oldfd: c_int, old: [*:0]const u8, newfd: c_int, new: [*:0]const |
| 3217 | 3274 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| 3218 | 3275 | std.debug.assert(rc == 0); |
| 3219 | 3276 | } |
| 3277 | pub fn mmap(addr: ?*anyopaque, len: usize, prot: c_int, flags: c_int, fd: c_int, offset: off_t) errno.Error![]u8 { |
| 3278 | const rc = libc.mmap(addr, len, prot, flags, fd, offset); |
| 3279 | if (@intFromPtr(rc) == MAP.FAILED) return errno.fromInt(errno.fromLibC()); |
| 3280 | const ptr: [*]u8 = @ptrCast(rc); |
| 3281 | return ptr[0..len]; |
| 3282 | } |
| 3283 | pub fn munmap(addr: *const anyopaque, len: usize) errno.Error!void { |
| 3284 | const rc = libc.munmap(addr, len); |
| 3285 | if (rc == -1) return errno.fromInt(errno.fromLibC()); |
| 3286 | std.debug.assert(rc == 0); |
| 3287 | } |