authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-07 13:55:03-08:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-02-07 13:55:03-08:00
log42fcca49c55eb9250a9ac8868fa6a9201dd9eb7e
tree11e6fa39875109b709dac3e8ee33cab91cad70c1
parentee36131e6a8bf8611f8a6fd55116e98eae2ed63c
parenta60f219660c5973c12987149c48ce9febf3c2b24
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #18846 from ziglang/std.os.linux.MAP

std.os.MAP: use a packed struct

31 files changed, 290 insertions(+), 328 deletions(-)

lib/std/Thread.zig+1-1
......@@ -1237,7 +1237,7 @@ const LinuxThreadImpl = struct {
12371237 null,
12381238 map_bytes,
12391239 os.PROT.NONE,
1240 os.MAP.PRIVATE | os.MAP.ANONYMOUS,
1240 .{ .TYPE = .PRIVATE, .ANONYMOUS = true },
12411241 -1,
12421242 0,
12431243 ) catch |err| switch (err) {
lib/std/c.zig+142
......@@ -45,6 +45,148 @@ pub usingnamespace switch (builtin.os.tag) {
4545 else => struct {},
4646};
4747
48pub const MAP = switch (builtin.os.tag) {
49 .linux => std.os.linux.MAP,
50 .emscripten => packed struct(u32) {
51 TYPE: enum(u4) {
52 SHARED = 0x01,
53 PRIVATE = 0x02,
54 SHARED_VALIDATE = 0x03,
55 },
56 FIXED: bool = false,
57 ANONYMOUS: bool = false,
58 _6: u2 = 0,
59 GROWSDOWN: bool = false,
60 _9: u2 = 0,
61 DENYWRITE: bool = false,
62 EXECUTABLE: bool = false,
63 LOCKED: bool = false,
64 NORESERVE: bool = false,
65 POPULATE: bool = false,
66 NONBLOCK: bool = false,
67 STACK: bool = false,
68 HUGETLB: bool = false,
69 SYNC: bool = false,
70 FIXED_NOREPLACE: bool = false,
71 _: u11 = 0,
72 },
73 .solaris, .illumos => packed struct(u32) {
74 TYPE: enum(u4) {
75 SHARED = 0x01,
76 PRIVATE = 0x02,
77 },
78 FIXED: bool = false,
79 RENAME: bool = false,
80 NORESERVE: bool = false,
81 @"32BIT": bool = false,
82 ANONYMOUS: bool = false,
83 ALIGN: bool = false,
84 TEXT: bool = false,
85 INITDATA: bool = false,
86 _: u20 = 0,
87 },
88 .netbsd => packed struct(u32) {
89 TYPE: enum(u2) {
90 SHARED = 0x01,
91 PRIVATE = 0x02,
92 },
93 REMAPDUP: bool = false,
94 _3: u1 = 0,
95 FIXED: bool = false,
96 RENAME: bool = false,
97 NORESERVE: bool = false,
98 INHERIT: bool = false,
99 _8: u1 = 0,
100 HASSEMAPHORE: bool = false,
101 TRYFIXED: bool = false,
102 WIRED: bool = false,
103 ANONYMOUS: bool = false,
104 STACK: bool = false,
105 _: u18 = 0,
106 },
107 .openbsd => packed struct(u32) {
108 TYPE: enum(u4) {
109 SHARED = 0x01,
110 PRIVATE = 0x02,
111 },
112 FIXED: bool = false,
113 _5: u7 = 0,
114 ANONYMOUS: bool = false,
115 _13: u1 = 0,
116 STACK: bool = false,
117 CONCEAL: bool = false,
118 _: u16 = 0,
119 },
120 .haiku => packed struct(u32) {
121 TYPE: enum(u2) {
122 SHARED = 0x01,
123 PRIVATE = 0x02,
124 },
125 FIXED: bool = false,
126 ANONYMOUS: bool = false,
127 NORESERVE: bool = false,
128 _: u27 = 0,
129 },
130 .macos, .ios, .tvos, .watchos => packed struct(u32) {
131 TYPE: enum(u4) {
132 SHARED = 0x01,
133 PRIVATE = 0x02,
134 },
135 FIXED: bool = false,
136 _5: u1 = 0,
137 NORESERVE: bool = false,
138 _7: u2 = 0,
139 HASSEMAPHORE: bool = false,
140 NOCACHE: bool = false,
141 _11: u1 = 0,
142 ANONYMOUS: bool = false,
143 _: u19 = 0,
144 },
145 .dragonfly => packed struct(u32) {
146 TYPE: enum(u4) {
147 SHARED = 0x01,
148 PRIVATE = 0x02,
149 },
150 FIXED: bool = false,
151 RENAME: bool = false,
152 NORESERVE: bool = false,
153 INHERIT: bool = false,
154 NOEXTEND: bool = false,
155 HASSEMAPHORE: bool = false,
156 STACK: bool = false,
157 NOSYNC: bool = false,
158 ANONYMOUS: bool = false,
159 VPAGETABLE: bool = false,
160 _14: u2 = 0,
161 TRYFIXED: bool = false,
162 NOCORE: bool = false,
163 SIZEALIGN: bool = false,
164 _: u13 = 0,
165 },
166 .freebsd => packed struct(u32) {
167 TYPE: enum(u4) {
168 SHARED = 0x01,
169 PRIVATE = 0x02,
170 },
171 FIXED: bool = false,
172 _5: u5 = 0,
173 STACK: bool = false,
174 NOSYNC: bool = false,
175 ANONYMOUS: bool = false,
176 GUARD: bool = false,
177 EXCL: bool = false,
178 _15: u2 = 0,
179 NOCORE: bool = false,
180 PREFAULT_READ: bool = false,
181 @"32BIT": bool = false,
182 _: u12 = 0,
183 },
184 else => @compileError("target libc does not have MAP"),
185};
186
187/// Used by libc to communicate failure. Not actually part of the underlying syscall.
188pub const MAP_FAILED: *anyopaque = @ptrFromInt(std.math.maxInt(usize));
189
48190pub const whence_t = if (builtin.os.tag == .wasi) std.os.wasi.whence_t else c_int;
49191
50192// Unix-like systems
lib/std/c/darwin.zig-20
......@@ -1310,26 +1310,6 @@ pub const PROT = struct {
13101310 pub const COPY: vm_prot_t = 0x10;
13111311};
13121312
1313pub const MAP = struct {
1314 /// allocated from memory, swap space
1315 pub const ANONYMOUS = 0x1000;
1316 /// map from file (default)
1317 pub const FILE = 0x0000;
1318 /// interpret addr exactly
1319 pub const FIXED = 0x0010;
1320 /// region may contain semaphores
1321 pub const HASSEMAPHORE = 0x0200;
1322 /// changes are private
1323 pub const PRIVATE = 0x0002;
1324 /// share changes
1325 pub const SHARED = 0x0001;
1326 /// don't cache pages for this mapping
1327 pub const NOCACHE = 0x0400;
1328 /// don't reserve needed swap area
1329 pub const NORESERVE = 0x0040;
1330 pub const FAILED = @as(*anyopaque, @ptrFromInt(maxInt(usize)));
1331};
1332
13331313pub const MSF = struct {
13341314 pub const ASYNC = 0x1;
13351315 pub const INVALIDATE = 0x2;
lib/std/c/dragonfly.zig-22
......@@ -223,28 +223,6 @@ pub const PROT = struct {
223223 pub const EXEC = 4;
224224};
225225
226pub const MAP = struct {
227 pub const FILE = 0;
228 pub const FAILED = @as(*anyopaque, @ptrFromInt(maxInt(usize)));
229 pub const ANONYMOUS = ANON;
230 pub const COPY = PRIVATE;
231 pub const SHARED = 1;
232 pub const PRIVATE = 2;
233 pub const FIXED = 16;
234 pub const RENAME = 32;
235 pub const NORESERVE = 64;
236 pub const INHERIT = 128;
237 pub const NOEXTEND = 256;
238 pub const HASSEMAPHORE = 512;
239 pub const STACK = 1024;
240 pub const NOSYNC = 2048;
241 pub const ANON = 4096;
242 pub const VPAGETABLE = 8192;
243 pub const TRYFIXED = 65536;
244 pub const NOCORE = 131072;
245 pub const SIZEALIGN = 262144;
246};
247
248226pub const MSF = struct {
249227 pub const ASYNC = 1;
250228 pub const INVALIDATE = 2;
lib/std/c/emscripten.zig-5
......@@ -16,11 +16,6 @@ pub const IOV_MAX = emscripten.IOV_MAX;
1616pub const IPPROTO = emscripten.IPPROTO;
1717pub const LOCK = emscripten.LOCK;
1818pub const MADV = emscripten.MADV;
19pub const MAP = struct {
20 pub usingnamespace emscripten.MAP;
21 /// Only used by libc to communicate failure.
22 pub const FAILED = @as(*anyopaque, @ptrFromInt(maxInt(usize)));
23};
2419pub const MSF = emscripten.MSF;
2520pub const MSG = emscripten.MSG;
2621pub const NAME_MAX = emscripten.NAME_MAX;
lib/std/c/freebsd.zig-23
......@@ -606,29 +606,6 @@ pub const CLOCK = struct {
606606 pub const PROCESS_CPUTIME_ID = 15;
607607};
608608
609pub const MAP = struct {
610 pub const FAILED = @as(*anyopaque, @ptrFromInt(maxInt(usize)));
611 pub const SHARED = 0x0001;
612 pub const PRIVATE = 0x0002;
613 pub const FIXED = 0x0010;
614 pub const STACK = 0x0400;
615 pub const NOSYNC = 0x0800;
616 pub const ANON = 0x1000;
617 pub const ANONYMOUS = ANON;
618 pub const FILE = 0;
619
620 pub const GUARD = 0x00002000;
621 pub const EXCL = 0x00004000;
622 pub const NOCORE = 0x00020000;
623 pub const PREFAULT_READ = 0x00040000;
624 pub const @"32BIT" = 0x00080000;
625
626 pub fn ALIGNED(alignment: u32) u32 {
627 return alignment << 24;
628 }
629 pub const ALIGNED_SUPER = ALIGNED(1);
630};
631
632609pub const MADV = struct {
633610 pub const NORMAL = 0;
634611 pub const RANDOM = 1;
lib/std/c/haiku.zig-16
......@@ -408,22 +408,6 @@ pub const CLOCK = struct {
408408 pub const THREAD_CPUTIME_ID = -3;
409409};
410410
411pub const MAP = struct {
412 /// mmap() error return code
413 pub const FAILED = @as(*anyopaque, @ptrFromInt(maxInt(usize)));
414 /// changes are seen by others
415 pub const SHARED = 0x01;
416 /// changes are only seen by caller
417 pub const PRIVATE = 0x02;
418 /// require mapping to specified addr
419 pub const FIXED = 0x04;
420 /// no underlying object
421 pub const ANONYMOUS = 0x0008;
422 pub const ANON = ANONYMOUS;
423 /// don't commit memory
424 pub const NORESERVE = 0x10;
425};
426
427411pub const MSF = struct {
428412 pub const ASYNC = 1;
429413 pub const INVALIDATE = 2;
lib/std/c/linux.zig-6
......@@ -1,6 +1,5 @@
11const std = @import("../std.zig");
22const builtin = @import("builtin");
3const maxInt = std.math.maxInt;
43const native_abi = builtin.abi;
54const native_arch = builtin.cpu.arch;
65const linux = std.os.linux;
......@@ -25,11 +24,6 @@ pub const IOV_MAX = linux.IOV_MAX;
2524pub const IPPROTO = linux.IPPROTO;
2625pub const LOCK = linux.LOCK;
2726pub const MADV = linux.MADV;
28pub const MAP = struct {
29 pub usingnamespace linux.MAP;
30 /// Only used by libc to communicate failure.
31 pub const FAILED = @as(*anyopaque, @ptrFromInt(maxInt(usize)));
32};
3327pub const MSF = linux.MSF;
3428pub const MMAP2_UNIT = linux.MMAP2_UNIT;
3529pub const MSG = linux.MSG;
lib/std/c/netbsd.zig-20
......@@ -573,26 +573,6 @@ pub const CLOCK = struct {
573573 pub const PROCESS_CPUTIME_ID = 0x40000000;
574574};
575575
576pub const MAP = struct {
577 pub const FAILED = @as(*anyopaque, @ptrFromInt(maxInt(usize)));
578 pub const SHARED = 0x0001;
579 pub const PRIVATE = 0x0002;
580 pub const REMAPDUP = 0x0004;
581 pub const FIXED = 0x0010;
582 pub const RENAME = 0x0020;
583 pub const NORESERVE = 0x0040;
584 pub const INHERIT = 0x0080;
585 pub const HASSEMAPHORE = 0x0200;
586 pub const TRYFIXED = 0x0400;
587 pub const WIRED = 0x0800;
588
589 pub const FILE = 0x0000;
590 pub const NOSYNC = 0x0800;
591 pub const ANON = 0x1000;
592 pub const ANONYMOUS = ANON;
593 pub const STACK = 0x2000;
594};
595
596576pub const MSF = struct {
597577 pub const ASYNC = 1;
598578 pub const INVALIDATE = 2;
lib/std/c/openbsd.zig-18
......@@ -436,24 +436,6 @@ pub const CLOCK = struct {
436436 pub const THREAD_CPUTIME_ID = 4;
437437};
438438
439pub const MAP = struct {
440 pub const FAILED = @as(*anyopaque, @ptrFromInt(maxInt(usize)));
441 pub const SHARED = 0x0001;
442 pub const PRIVATE = 0x0002;
443 pub const FIXED = 0x0010;
444 pub const RENAME = 0;
445 pub const NORESERVE = 0;
446 pub const INHERIT = 0;
447 pub const HASSEMAPHORE = 0;
448 pub const TRYFIXED = 0;
449
450 pub const FILE = 0;
451 pub const ANON = 0x1000;
452 pub const ANONYMOUS = ANON;
453 pub const STACK = 0x4000;
454 pub const CONCEAL = 0x8000;
455};
456
457439pub const MSF = struct {
458440 pub const ASYNC = 1;
459441 pub const INVALIDATE = 2;
lib/std/c/solaris.zig-21
......@@ -523,27 +523,6 @@ pub const CLOCK = struct {
523523 pub const PROF = THREAD_CPUTIME_ID;
524524};
525525
526pub const MAP = struct {
527 pub const FAILED = @as(*anyopaque, @ptrFromInt(maxInt(usize)));
528 pub const SHARED = 0x0001;
529 pub const PRIVATE = 0x0002;
530 pub const TYPE = 0x000f;
531
532 pub const FILE = 0x0000;
533 pub const FIXED = 0x0010;
534 // Unimplemented
535 pub const RENAME = 0x0020;
536 pub const NORESERVE = 0x0040;
537 /// Force mapping in lower 4G address space
538 pub const @"32BIT" = 0x0080;
539
540 pub const ANON = 0x0100;
541 pub const ANONYMOUS = ANON;
542 pub const ALIGN = 0x0200;
543 pub const TEXT = 0x0400;
544 pub const INITDATA = 0x0800;
545};
546
547526pub const MSF = struct {
548527 pub const ASYNC = 1;
549528 pub const INVALIDATE = 2;
lib/std/crypto/tlcsprng.zig+1-1
......@@ -83,7 +83,7 @@ fn tlsCsprngFill(_: *anyopaque, buffer: []u8) void {
8383 null,
8484 @sizeOf(Context),
8585 os.PROT.READ | os.PROT.WRITE,
86 os.MAP.PRIVATE | os.MAP.ANONYMOUS,
86 .{ .TYPE = .PRIVATE, .ANONYMOUS = true },
8787 -1,
8888 0,
8989 ) catch {
lib/std/debug.zig+1-1
......@@ -1652,7 +1652,7 @@ fn mapWholeFile(file: File) ![]align(mem.page_size) const u8 {
16521652 null,
16531653 file_len,
16541654 os.PROT.READ,
1655 os.MAP.SHARED,
1655 .{ .TYPE = .SHARED },
16561656 file.handle,
16571657 0,
16581658 );
lib/std/dynamic_library.zig+4-4
......@@ -127,7 +127,7 @@ pub const ElfDynLib = struct {
127127 null,
128128 mem.alignForward(usize, size, mem.page_size),
129129 os.PROT.READ,
130 os.MAP.PRIVATE,
130 .{ .TYPE = .PRIVATE },
131131 fd,
132132 0,
133133 );
......@@ -165,7 +165,7 @@ pub const ElfDynLib = struct {
165165 null,
166166 virt_addr_end,
167167 os.PROT.NONE,
168 os.MAP.PRIVATE | os.MAP.ANONYMOUS,
168 .{ .TYPE = .PRIVATE, .ANONYMOUS = true },
169169 -1,
170170 0,
171171 );
......@@ -197,7 +197,7 @@ pub const ElfDynLib = struct {
197197 ptr,
198198 extended_memsz,
199199 prot,
200 os.MAP.PRIVATE | os.MAP.FIXED,
200 .{ .TYPE = .PRIVATE, .FIXED = true },
201201 fd,
202202 ph.p_offset - extra_bytes,
203203 );
......@@ -206,7 +206,7 @@ pub const ElfDynLib = struct {
206206 ptr,
207207 extended_memsz,
208208 prot,
209 os.MAP.PRIVATE | os.MAP.FIXED | os.MAP.ANONYMOUS,
209 .{ .TYPE = .PRIVATE, .FIXED = true, .ANONYMOUS = true },
210210 -1,
211211 0,
212212 );
lib/std/heap/PageAllocator.zig+1-1
......@@ -35,7 +35,7 @@ fn alloc(_: *anyopaque, n: usize, log2_align: u8, ra: usize) ?[*]u8 {
3535 hint,
3636 aligned_len,
3737 os.PROT.READ | os.PROT.WRITE,
38 os.MAP.PRIVATE | os.MAP.ANONYMOUS,
38 .{ .TYPE = .PRIVATE, .ANONYMOUS = true },
3939 -1,
4040 0,
4141 ) catch return null;
lib/std/os.zig+4-4
......@@ -4657,16 +4657,16 @@ pub fn mmap(
46574657 ptr: ?[*]align(mem.page_size) u8,
46584658 length: usize,
46594659 prot: u32,
4660 flags: u32,
4660 flags: system.MAP,
46614661 fd: fd_t,
46624662 offset: u64,
46634663) MMapError![]align(mem.page_size) u8 {
46644664 const mmap_sym = if (lfs64_abi) system.mmap64 else system.mmap;
46654665
4666 const ioffset = @as(i64, @bitCast(offset)); // the OS treats this as unsigned
4667 const rc = mmap_sym(ptr, length, prot, flags, fd, ioffset);
4666 const ioffset: i64 = @bitCast(offset); // the OS treats this as unsigned
4667 const rc = mmap_sym(ptr, length, prot, @bitCast(flags), fd, ioffset);
46684668 const err = if (builtin.link_libc) blk: {
4669 if (rc != std.c.MAP.FAILED) return @as([*]align(mem.page_size) u8, @ptrCast(@alignCast(rc)))[0..length];
4669 if (rc != std.c.MAP_FAILED) return @as([*]align(mem.page_size) u8, @ptrCast(@alignCast(rc)))[0..length];
46704670 break :blk @as(E, @enumFromInt(system._errno().*));
46714671 } else blk: {
46724672 const err = errno(rc);
lib/std/os/emscripten.zig-21
......@@ -449,27 +449,6 @@ pub const MADV = struct {
449449 pub const SOFT_OFFLINE = 101;
450450};
451451
452pub const MAP = struct {
453 pub const SHARED = 0x01;
454 pub const PRIVATE = 0x02;
455 pub const SHARED_VALIDATE = 0x03;
456 pub const TYPE = 0x0f;
457 pub const FIXED = 0x10;
458 pub const ANON = 0x20;
459 pub const ANONYMOUS = ANON;
460 pub const NORESERVE = 0x4000;
461 pub const GROWSDOWN = 0x0100;
462 pub const DENYWRITE = 0x0800;
463 pub const EXECUTABLE = 0x1000;
464 pub const LOCKED = 0x2000;
465 pub const POPULATE = 0x8000;
466 pub const NONBLOCK = 0x10000;
467 pub const STACK = 0x20000;
468 pub const HUGETLB = 0x40000;
469 pub const SYNC = 0x80000;
470 pub const FIXED_NOREPLACE = 0x100000;
471};
472
473452pub const MSF = struct {
474453 pub const ASYNC = 1;
475454 pub const INVALIDATE = 2;
lib/std/os/linux.zig+130-30
......@@ -109,36 +109,136 @@ pub const SYS = switch (@import("builtin").cpu.arch) {
109109 else => @compileError("The Zig Standard Library is missing syscall definitions for the target CPU architecture"),
110110};
111111
112pub const MAP = struct {
113 pub usingnamespace arch_bits.MAP;
114
115 /// Share changes
116 pub const SHARED = 0x01;
117 /// Changes are private
118 pub const PRIVATE = 0x02;
119 /// share + validate extension flags
120 pub const SHARED_VALIDATE = 0x03;
121 /// Mask for type of mapping
122 pub const TYPE = 0x0f;
123 /// Interpret addr exactly
124 pub const FIXED = 0x10;
125 /// don't use a file
126 pub const ANONYMOUS = if (is_mips) 0x800 else 0x20;
127 // MAP_ 0x0100 - 0x4000 flags are per architecture
128 /// populate (prefault) pagetables
129 pub const POPULATE = if (is_mips) 0x10000 else 0x8000;
130 /// do not block on IO
131 pub const NONBLOCK = if (is_mips) 0x20000 else 0x10000;
132 /// give out an address that is best suited for process/thread stacks
133 pub const STACK = if (is_mips) 0x40000 else 0x20000;
134 /// create a huge page mapping
135 pub const HUGETLB = if (is_mips) 0x80000 else 0x40000;
136 /// perform synchronous page faults for the mapping
137 pub const SYNC = 0x80000;
138 /// MAP_FIXED which doesn't unmap underlying mapping
139 pub const FIXED_NOREPLACE = 0x100000;
140 /// For anonymous mmap, memory could be uninitialized
141 pub const UNINITIALIZED = 0x4000000;
112pub const MAP_TYPE = enum(u4) {
113 SHARED = 0x01,
114 PRIVATE = 0x02,
115 SHARED_VALIDATE = 0x03,
116};
117
118pub const MAP = switch (native_arch) {
119 .x86_64, .x86 => packed struct(u32) {
120 TYPE: MAP_TYPE,
121 FIXED: bool = false,
122 ANONYMOUS: bool = false,
123 @"32BIT": bool = false,
124 _7: u1 = 0,
125 GROWSDOWN: bool = false,
126 _9: u2 = 0,
127 DENYWRITE: bool = false,
128 EXECUTABLE: bool = false,
129 LOCKED: bool = false,
130 NORESERVE: bool = false,
131 POPULATE: bool = false,
132 NONBLOCK: bool = false,
133 STACK: bool = false,
134 HUGETLB: bool = false,
135 SYNC: bool = false,
136 FIXED_NOREPLACE: bool = false,
137 _21: u5 = 0,
138 UNINITIALIZED: bool = false,
139 _: u5 = 0,
140 },
141 .aarch64, .aarch64_be, .arm, .thumb => packed struct(u32) {
142 TYPE: MAP_TYPE,
143 FIXED: bool = false,
144 ANONYMOUS: bool = false,
145 _6: u2 = 0,
146 GROWSDOWN: bool = false,
147 _9: u2 = 0,
148 DENYWRITE: bool = false,
149 EXECUTABLE: bool = false,
150 LOCKED: bool = false,
151 NORESERVE: bool = false,
152 POPULATE: bool = false,
153 NONBLOCK: bool = false,
154 STACK: bool = false,
155 HUGETLB: bool = false,
156 SYNC: bool = false,
157 FIXED_NOREPLACE: bool = false,
158 _21: u5 = 0,
159 UNINITIALIZED: bool = false,
160 _: u5 = 0,
161 },
162 .riscv64 => packed struct(u32) {
163 TYPE: MAP_TYPE,
164 FIXED: bool = false,
165 ANONYMOUS: bool = false,
166 _6: u9 = 0,
167 POPULATE: bool = false,
168 NONBLOCK: bool = false,
169 STACK: bool = false,
170 HUGETLB: bool = false,
171 SYNC: bool = false,
172 FIXED_NOREPLACE: bool = false,
173 _21: u5 = 0,
174 UNINITIALIZED: bool = false,
175 _: u5 = 0,
176 },
177 .sparc64 => packed struct(u32) {
178 TYPE: MAP_TYPE,
179 FIXED: bool = false,
180 ANONYMOUS: bool = false,
181 NORESERVE: bool = false,
182 _7: u1 = 0,
183 LOCKED: bool = false,
184 GROWSDOWN: bool = false,
185 _10: u1 = 0,
186 DENYWRITE: bool = false,
187 EXECUTABLE: bool = false,
188 _13: u2 = 0,
189 POPULATE: bool = false,
190 NONBLOCK: bool = false,
191 STACK: bool = false,
192 HUGETLB: bool = false,
193 SYNC: bool = false,
194 FIXED_NOREPLACE: bool = false,
195 _21: u5 = 0,
196 UNINITIALIZED: bool = false,
197 _: u5 = 0,
198 },
199 .mips, .mipsel, .mips64, .mips64el => packed struct(u32) {
200 TYPE: MAP_TYPE,
201 FIXED: bool = false,
202 _5: u1 = 0,
203 @"32BIT": bool = false,
204 _7: u3 = 0,
205 NORESERVE: bool = false,
206 ANONYMOUS: bool = false,
207 GROWSDOWN: bool = false,
208 DENYWRITE: bool = false,
209 EXECUTABLE: bool = false,
210 LOCKED: bool = false,
211 POPULATE: bool = false,
212 NONBLOCK: bool = false,
213 STACK: bool = false,
214 HUGETLB: bool = false,
215 FIXED_NOREPLACE: bool = false,
216 _21: u5 = 0,
217 UNINITIALIZED: bool = false,
218 _: u5 = 0,
219 },
220 .powerpc, .powerpcle, .powerpc64, .powerpc64le => packed struct(u32) {
221 TYPE: MAP_TYPE,
222 FIXED: bool = false,
223 ANONYMOUS: bool = false,
224 NORESERVE: bool = false,
225 LOCKED: bool = false,
226 GROWSDOWN: bool = false,
227 _9: u2 = 0,
228 DENYWRITE: bool = false,
229 EXECUTABLE: bool = false,
230 _13: u2 = 0,
231 POPULATE: bool = false,
232 NONBLOCK: bool = false,
233 STACK: bool = false,
234 HUGETLB: bool = false,
235 SYNC: bool = false,
236 FIXED_NOREPLACE: bool = false,
237 _21: u5 = 0,
238 UNINITIALIZED: bool = false,
239 _: u5 = 0,
240 },
241 else => @compileError("missing std.os.linux.MAP constants for this architecture"),
142242};
143243
144244pub const O = struct {
lib/std/os/linux/arm-eabi.zig-13
......@@ -197,19 +197,6 @@ pub const LOCK = struct {
197197 pub const NB = 4;
198198};
199199
200pub const MAP = struct {
201 /// stack-like segment
202 pub const GROWSDOWN = 0x0100;
203 /// ETXTBSY
204 pub const DENYWRITE = 0x0800;
205 /// mark it as an executable
206 pub const EXECUTABLE = 0x1000;
207 /// pages are locked
208 pub const LOCKED = 0x2000;
209 /// don't check for reservations
210 pub const NORESERVE = 0x4000;
211};
212
213200pub const VDSO = struct {
214201 pub const CGT_SYM = "__vdso_clock_gettime";
215202 pub const CGT_VER = "LINUX_2.6";
lib/std/os/linux/arm64.zig-13
......@@ -179,19 +179,6 @@ pub const LOCK = struct {
179179 pub const NB = 4;
180180};
181181
182pub const MAP = struct {
183 /// stack-like segment
184 pub const GROWSDOWN = 0x0100;
185 /// ETXTBSY
186 pub const DENYWRITE = 0x0800;
187 /// mark it as an executable
188 pub const EXECUTABLE = 0x1000;
189 /// pages are locked
190 pub const LOCKED = 0x2000;
191 /// don't check for reservations
192 pub const NORESERVE = 0x4000;
193};
194
195182pub const VDSO = struct {
196183 pub const CGT_SYM = "__kernel_clock_gettime";
197184 pub const CGT_VER = "LINUX_2.6.39";
lib/std/os/linux/io_uring.zig+2-2
......@@ -1344,7 +1344,7 @@ pub const SubmissionQueue = struct {
13441344 null,
13451345 size,
13461346 os.PROT.READ | os.PROT.WRITE,
1347 os.MAP.SHARED | os.MAP.POPULATE,
1347 .{ .TYPE = .SHARED, .POPULATE = true },
13481348 fd,
13491349 linux.IORING_OFF_SQ_RING,
13501350 );
......@@ -1358,7 +1358,7 @@ pub const SubmissionQueue = struct {
13581358 null,
13591359 size_sqes,
13601360 os.PROT.READ | os.PROT.WRITE,
1361 os.MAP.SHARED | os.MAP.POPULATE,
1361 .{ .TYPE = .SHARED, .POPULATE = true },
13621362 fd,
13631363 linux.IORING_OFF_SQES,
13641364 );
lib/std/os/linux/mips.zig-9
......@@ -271,15 +271,6 @@ pub const LOCK = struct {
271271
272272pub const MMAP2_UNIT = 4096;
273273
274pub const MAP = struct {
275 pub const NORESERVE = 0x0400;
276 pub const GROWSDOWN = 0x1000;
277 pub const DENYWRITE = 0x2000;
278 pub const EXECUTABLE = 0x4000;
279 pub const LOCKED = 0x8000;
280 pub const @"32BIT" = 0x40;
281};
282
283274pub const VDSO = struct {
284275 pub const CGT_SYM = "__kernel_clock_gettime";
285276 pub const CGT_VER = "LINUX_2.6.39";
lib/std/os/linux/mips64.zig-9
......@@ -256,15 +256,6 @@ pub const LOCK = struct {
256256
257257pub const MMAP2_UNIT = 4096;
258258
259pub const MAP = struct {
260 pub const NORESERVE = 0x0400;
261 pub const GROWSDOWN = 0x1000;
262 pub const DENYWRITE = 0x2000;
263 pub const EXECUTABLE = 0x4000;
264 pub const LOCKED = 0x8000;
265 pub const @"32BIT" = 0x40;
266};
267
268259pub const VDSO = struct {
269260 pub const CGT_SYM = "__kernel_clock_gettime";
270261 pub const CGT_VER = "LINUX_2.6.39";
lib/std/os/linux/powerpc.zig-13
......@@ -198,19 +198,6 @@ pub const LOCK = struct {
198198 pub const NB = 4;
199199};
200200
201pub const MAP = struct {
202 /// stack-like segment
203 pub const GROWSDOWN = 0x0100;
204 /// ETXTBSY
205 pub const DENYWRITE = 0x0800;
206 /// mark it as an executable
207 pub const EXECUTABLE = 0x1000;
208 /// pages are locked
209 pub const LOCKED = 0x0080;
210 /// don't check for reservations
211 pub const NORESERVE = 0x0040;
212};
213
214201pub const VDSO = struct {
215202 pub const CGT_SYM = "__kernel_clock_gettime";
216203 pub const CGT_VER = "LINUX_2.6.15";
lib/std/os/linux/powerpc64.zig-13
......@@ -198,19 +198,6 @@ pub const LOCK = struct {
198198 pub const NB = 4;
199199};
200200
201pub const MAP = struct {
202 /// stack-like segment
203 pub const GROWSDOWN = 0x0100;
204 /// ETXTBSY
205 pub const DENYWRITE = 0x0800;
206 /// mark it as an executable
207 pub const EXECUTABLE = 0x1000;
208 /// pages are locked
209 pub const LOCKED = 0x0080;
210 /// don't check for reservations
211 pub const NORESERVE = 0x0040;
212};
213
214201pub const VDSO = struct {
215202 pub const CGT_SYM = "__kernel_clock_gettime";
216203 pub const CGT_VER = "LINUX_2.6.15";
lib/std/os/linux/riscv64.zig-1
......@@ -246,4 +246,3 @@ pub const Stat = extern struct {
246246pub const Elf_Symndx = u32;
247247
248248pub const VDSO = struct {};
249pub const MAP = struct {};
lib/std/os/linux/sparc64.zig-13
......@@ -248,19 +248,6 @@ pub const LOCK = struct {
248248 pub const UN = 8;
249249};
250250
251pub const MAP = struct {
252 /// stack-like segment
253 pub const GROWSDOWN = 0x0200;
254 /// ETXTBSY
255 pub const DENYWRITE = 0x0800;
256 /// mark it as an executable
257 pub const EXECUTABLE = 0x1000;
258 /// pages are locked
259 pub const LOCKED = 0x0100;
260 /// don't check for reservations
261 pub const NORESERVE = 0x0040;
262};
263
264251pub const VDSO = struct {
265252 pub const CGT_SYM = "__vdso_clock_gettime";
266253 pub const CGT_VER = "LINUX_2.6";
lib/std/os/linux/tls.zig+1-1
......@@ -324,7 +324,7 @@ pub fn initStaticTLS(phdrs: []elf.Phdr) void {
324324 null,
325325 tls_image.alloc_size + tls_image.alloc_align - 1,
326326 os.PROT.READ | os.PROT.WRITE,
327 os.MAP.PRIVATE | os.MAP.ANONYMOUS,
327 .{ .TYPE = .PRIVATE, .ANONYMOUS = true },
328328 -1,
329329 0,
330330 ) catch os.abort();
lib/std/os/linux/x86.zig-9
......@@ -211,15 +211,6 @@ pub const LOCK = struct {
211211 pub const UN = 8;
212212};
213213
214pub const MAP = struct {
215 pub const NORESERVE = 0x4000;
216 pub const GROWSDOWN = 0x0100;
217 pub const DENYWRITE = 0x0800;
218 pub const EXECUTABLE = 0x1000;
219 pub const LOCKED = 0x2000;
220 pub const @"32BIT" = 0x40;
221};
222
223214pub const MMAP2_UNIT = 4096;
224215
225216pub const VDSO = struct {
lib/std/os/linux/x86_64.zig-15
......@@ -177,21 +177,6 @@ pub const F = struct {
177177 pub const UNLCK = 2;
178178};
179179
180pub const MAP = struct {
181 /// only give out 32bit addresses
182 pub const @"32BIT" = 0x40;
183 /// stack-like segment
184 pub const GROWSDOWN = 0x0100;
185 /// ETXTBSY
186 pub const DENYWRITE = 0x0800;
187 /// mark it as an executable
188 pub const EXECUTABLE = 0x1000;
189 /// pages are locked
190 pub const LOCKED = 0x2000;
191 /// don't check for reservations
192 pub const NORESERVE = 0x4000;
193};
194
195180pub const VDSO = struct {
196181 pub const CGT_SYM = "__vdso_clock_gettime";
197182 pub const CGT_VER = "LINUX_2.6";
lib/std/os/test.zig+3-3
......@@ -576,7 +576,7 @@ test "mmap" {
576576 null,
577577 1234,
578578 os.PROT.READ | os.PROT.WRITE,
579 os.MAP.ANONYMOUS | os.MAP.PRIVATE,
579 .{ .TYPE = .PRIVATE, .ANONYMOUS = true },
580580 -1,
581581 0,
582582 );
......@@ -618,7 +618,7 @@ test "mmap" {
618618 null,
619619 alloc_size,
620620 os.PROT.READ,
621 os.MAP.PRIVATE,
621 .{ .TYPE = .PRIVATE },
622622 file.handle,
623623 0,
624624 );
......@@ -642,7 +642,7 @@ test "mmap" {
642642 null,
643643 alloc_size / 2,
644644 os.PROT.READ,
645 os.MAP.PRIVATE,
645 .{ .TYPE = .PRIVATE },
646646 file.handle,
647647 alloc_size / 2,
648648 );