| author | |
| committer | |
| log | bcb4ba9afd610a0f3ab66ad828c90fd57dc95a6f |
| tree | f60101eaee6284a6bce0bed184b2b447f024fd6a |
| parent | 6fd358d287ee90de80769bd16b4321039acb570e |
| signature |
12 files changed, 15 insertions(+), 43 deletions(-)
lib/std/c.zig-4| ... | @@ -1601,10 +1601,6 @@ pub const MSF = switch (native_os) { | ... | @@ -1601,10 +1601,6 @@ pub const MSF = switch (native_os) { |
| 1601 | }, | 1601 | }, |
| 1602 | else => void, | 1602 | else => void, |
| 1603 | }; | 1603 | }; |
| 1604 | pub const MMAP2_UNIT = switch (native_os) { | ||
| 1605 | .linux => linux.MMAP2_UNIT, | ||
| 1606 | else => void, | ||
| 1607 | }; | ||
| 1608 | pub const NAME_MAX = switch (native_os) { | 1604 | pub const NAME_MAX = switch (native_os) { |
| 1609 | .linux => linux.NAME_MAX, | 1605 | .linux => linux.NAME_MAX, |
| 1610 | .emscripten => emscripten.NAME_MAX, | 1606 | .emscripten => emscripten.NAME_MAX, |
lib/std/os/linux.zig+1-2| ... | @@ -93,7 +93,6 @@ pub const Elf_Symndx = arch_bits.Elf_Symndx; | ... | @@ -93,7 +93,6 @@ pub const Elf_Symndx = arch_bits.Elf_Symndx; |
| 93 | pub const F = arch_bits.F; | 93 | pub const F = arch_bits.F; |
| 94 | pub const Flock = arch_bits.Flock; | 94 | pub const Flock = arch_bits.Flock; |
| 95 | pub const HWCAP = arch_bits.HWCAP; | 95 | pub const HWCAP = arch_bits.HWCAP; |
| 96 | pub const MMAP2_UNIT = arch_bits.MMAP2_UNIT; | ||
| 97 | pub const REG = arch_bits.REG; | 96 | pub const REG = arch_bits.REG; |
| 98 | pub const SC = arch_bits.SC; | 97 | pub const SC = arch_bits.SC; |
| 99 | pub const Stat = arch_bits.Stat; | 98 | pub const Stat = arch_bits.Stat; |
| ... | @@ -928,7 +927,7 @@ pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: MAP, fd: i32, of | ... | @@ -928,7 +927,7 @@ pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: MAP, fd: i32, of |
| 928 | prot, | 927 | prot, |
| 929 | @as(u32, @bitCast(flags)), | 928 | @as(u32, @bitCast(flags)), |
| 930 | @bitCast(@as(isize, fd)), | 929 | @bitCast(@as(isize, fd)), |
| 931 | @truncate(@as(u64, @bitCast(offset)) / MMAP2_UNIT), | 930 | @truncate(@as(u64, @bitCast(offset)) / std.heap.pageSize()), |
| 932 | ); | 931 | ); |
| 933 | } else { | 932 | } else { |
| 934 | // The s390x mmap() syscall existed before Linux supported syscalls with 5+ parameters, so | 933 | // The s390x mmap() syscall existed before Linux supported syscalls with 5+ parameters, so |
lib/std/os/linux/arm.zig-2| ... | @@ -170,8 +170,6 @@ pub fn restore_rt() callconv(.naked) noreturn { | ... | @@ -170,8 +170,6 @@ pub fn restore_rt() callconv(.naked) noreturn { |
| 170 | } | 170 | } |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | pub const MMAP2_UNIT = 4096; | ||
| 174 | |||
| 175 | pub const F = struct { | 173 | pub const F = struct { |
| 176 | pub const DUPFD = 0; | 174 | pub const DUPFD = 0; |
| 177 | pub const GETFD = 1; | 175 | pub const GETFD = 1; |
lib/std/os/linux/hexagon.zig-2| ... | @@ -251,8 +251,6 @@ pub const Stat = extern struct { | ... | @@ -251,8 +251,6 @@ pub const Stat = extern struct { |
| 251 | 251 | ||
| 252 | pub const Elf_Symndx = u32; | 252 | pub const Elf_Symndx = u32; |
| 253 | 253 | ||
| 254 | pub const MMAP2_UNIT = 4096; | ||
| 255 | |||
| 256 | pub const VDSO = void; | 254 | pub const VDSO = void; |
| 257 | 255 | ||
| 258 | /// TODO | 256 | /// TODO |
lib/std/os/linux/m68k.zig-4| ... | @@ -261,10 +261,6 @@ pub const Stat = extern struct { | ... | @@ -261,10 +261,6 @@ pub const Stat = extern struct { |
| 261 | 261 | ||
| 262 | pub const Elf_Symndx = u32; | 262 | pub const Elf_Symndx = u32; |
| 263 | 263 | ||
| 264 | // m68k has multiple minimum page sizes. | ||
| 265 | // glibc sets MMAP2_PAGE_UNIT to -1 so it is queried at runtime. | ||
| 266 | pub const MMAP2_UNIT = -1; | ||
| 267 | |||
| 268 | // No VDSO used as of glibc 112a0ae18b831bf31f44d81b82666980312511d6. | 264 | // No VDSO used as of glibc 112a0ae18b831bf31f44d81b82666980312511d6. |
| 269 | pub const VDSO = void; | 265 | pub const VDSO = void; |
| 270 | 266 |
lib/std/os/linux/mips.zig-2| ... | @@ -294,8 +294,6 @@ pub const F = struct { | ... | @@ -294,8 +294,6 @@ pub const F = struct { |
| 294 | pub const GETOWNER_UIDS = 17; | 294 | pub const GETOWNER_UIDS = 17; |
| 295 | }; | 295 | }; |
| 296 | 296 | ||
| 297 | pub const MMAP2_UNIT = 4096; | ||
| 298 | |||
| 299 | pub const VDSO = struct { | 297 | pub const VDSO = struct { |
| 300 | pub const CGT_SYM = "__vdso_clock_gettime"; | 298 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| 301 | pub const CGT_VER = "LINUX_2.6"; | 299 | pub const CGT_VER = "LINUX_2.6"; |
lib/std/os/linux/mips64.zig-2| ... | @@ -273,8 +273,6 @@ pub const F = struct { | ... | @@ -273,8 +273,6 @@ pub const F = struct { |
| 273 | pub const GETOWNER_UIDS = 17; | 273 | pub const GETOWNER_UIDS = 17; |
| 274 | }; | 274 | }; |
| 275 | 275 | ||
| 276 | pub const MMAP2_UNIT = 4096; | ||
| 277 | |||
| 278 | pub const VDSO = struct { | 276 | pub const VDSO = struct { |
| 279 | pub const CGT_SYM = "__vdso_clock_gettime"; | 277 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| 280 | pub const CGT_VER = "LINUX_2.6"; | 278 | pub const CGT_VER = "LINUX_2.6"; |
lib/std/os/linux/powerpc.zig-2| ... | @@ -348,7 +348,5 @@ pub const ucontext_t = extern struct { | ... | @@ -348,7 +348,5 @@ pub const ucontext_t = extern struct { |
| 348 | 348 | ||
| 349 | pub const Elf_Symndx = u32; | 349 | pub const Elf_Symndx = u32; |
| 350 | 350 | ||
| 351 | pub const MMAP2_UNIT = 4096; | ||
| 352 | |||
| 353 | /// TODO | 351 | /// TODO |
| 354 | pub const getcontext = {}; | 352 | pub const getcontext = {}; |
lib/std/os/linux/riscv32.zig-2| ... | @@ -256,8 +256,6 @@ pub const Stat = extern struct { | ... | @@ -256,8 +256,6 @@ pub const Stat = extern struct { |
| 256 | 256 | ||
| 257 | pub const Elf_Symndx = u32; | 257 | pub const Elf_Symndx = u32; |
| 258 | 258 | ||
| 259 | pub const MMAP2_UNIT = 4096; | ||
| 260 | |||
| 261 | pub const VDSO = struct { | 259 | pub const VDSO = struct { |
| 262 | pub const CGT_SYM = "__vdso_clock_gettime"; | 260 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| 263 | pub const CGT_VER = "LINUX_4.15"; | 261 | pub const CGT_VER = "LINUX_4.15"; |
lib/std/os/linux/tls.zig+14-18| ... | @@ -508,14 +508,7 @@ pub fn initStatic(phdrs: []elf.Phdr) void { | ... | @@ -508,14 +508,7 @@ pub fn initStatic(phdrs: []elf.Phdr) void { |
| 508 | break :blk main_thread_area_buffer[0..area_desc.size]; | 508 | break :blk main_thread_area_buffer[0..area_desc.size]; |
| 509 | } | 509 | } |
| 510 | 510 | ||
| 511 | const begin_addr = mmap( | 511 | const begin_addr = mmap_tls(area_desc.size + area_desc.alignment - 1); |
| 512 | null, | ||
| 513 | area_desc.size + area_desc.alignment - 1, | ||
| 514 | posix.PROT.READ | posix.PROT.WRITE, | ||
| 515 | .{ .TYPE = .PRIVATE, .ANONYMOUS = true }, | ||
| 516 | -1, | ||
| 517 | 0, | ||
| 518 | ); | ||
| 519 | if (@call(.always_inline, linux.E.init, .{begin_addr}) != .SUCCESS) @trap(); | 512 | if (@call(.always_inline, linux.E.init, .{begin_addr}) != .SUCCESS) @trap(); |
| 520 | 513 | ||
| 521 | const area_ptr: [*]align(page_size_min) u8 = @ptrFromInt(begin_addr); | 514 | const area_ptr: [*]align(page_size_min) u8 = @ptrFromInt(begin_addr); |
| ... | @@ -530,16 +523,19 @@ pub fn initStatic(phdrs: []elf.Phdr) void { | ... | @@ -530,16 +523,19 @@ pub fn initStatic(phdrs: []elf.Phdr) void { |
| 530 | setThreadPointer(tp_value); | 523 | setThreadPointer(tp_value); |
| 531 | } | 524 | } |
| 532 | 525 | ||
| 533 | inline fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: linux.MAP, fd: i32, offset: i64) usize { | 526 | inline fn mmap_tls(length: usize) usize { |
| 527 | const prot = posix.PROT.READ | posix.PROT.WRITE; | ||
| 528 | const flags: linux.MAP = .{ .TYPE = .PRIVATE, .ANONYMOUS = true }; | ||
| 529 | |||
| 534 | if (@hasField(linux.SYS, "mmap2")) { | 530 | if (@hasField(linux.SYS, "mmap2")) { |
| 535 | return @call(.always_inline, linux.syscall6, .{ | 531 | return @call(.always_inline, linux.syscall6, .{ |
| 536 | .mmap2, | 532 | .mmap2, |
| 537 | @intFromPtr(address), | 533 | 0, |
| 538 | length, | 534 | length, |
| 539 | prot, | 535 | prot, |
| 540 | @as(u32, @bitCast(flags)), | 536 | @as(u32, @bitCast(flags)), |
| 541 | @as(usize, @bitCast(@as(isize, fd))), | 537 | @as(usize, @bitCast(@as(isize, -1))), |
| 542 | @as(usize, @truncate(@as(u64, @bitCast(offset)) / linux.MMAP2_UNIT)), | 538 | 0, |
| 543 | }); | 539 | }); |
| 544 | } else { | 540 | } else { |
| 545 | // The s390x mmap() syscall existed before Linux supported syscalls with 5+ parameters, so | 541 | // The s390x mmap() syscall existed before Linux supported syscalls with 5+ parameters, so |
| ... | @@ -547,21 +543,21 @@ inline fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: linux.MAP, fd | ... | @@ -547,21 +543,21 @@ inline fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: linux.MAP, fd |
| 547 | return if (native_arch == .s390x) @call(.always_inline, linux.syscall1, .{ | 543 | return if (native_arch == .s390x) @call(.always_inline, linux.syscall1, .{ |
| 548 | .mmap, | 544 | .mmap, |
| 549 | @intFromPtr(&[_]usize{ | 545 | @intFromPtr(&[_]usize{ |
| 550 | @intFromPtr(address), | 546 | 0, |
| 551 | length, | 547 | length, |
| 552 | prot, | 548 | prot, |
| 553 | @as(u32, @bitCast(flags)), | 549 | @as(u32, @bitCast(flags)), |
| 554 | @as(usize, @bitCast(@as(isize, fd))), | 550 | @as(usize, @bitCast(@as(isize, -1))), |
| 555 | @as(u64, @bitCast(offset)), | 551 | 0, |
| 556 | }), | 552 | }), |
| 557 | }) else @call(.always_inline, linux.syscall6, .{ | 553 | }) else @call(.always_inline, linux.syscall6, .{ |
| 558 | .mmap, | 554 | .mmap, |
| 559 | @intFromPtr(address), | 555 | 0, |
| 560 | length, | 556 | length, |
| 561 | prot, | 557 | prot, |
| 562 | @as(u32, @bitCast(flags)), | 558 | @as(u32, @bitCast(flags)), |
| 563 | @as(usize, @bitCast(@as(isize, fd))), | 559 | @as(usize, @bitCast(@as(isize, -1))), |
| 564 | @as(u64, @bitCast(offset)), | 560 | 0, |
| 565 | }); | 561 | }); |
| 566 | } | 562 | } |
| 567 | } | 563 | } |
lib/std/os/linux/x86.zig-2| ... | @@ -230,8 +230,6 @@ pub const F = struct { | ... | @@ -230,8 +230,6 @@ pub const F = struct { |
| 230 | pub const UNLCK = 2; | 230 | pub const UNLCK = 2; |
| 231 | }; | 231 | }; |
| 232 | 232 | ||
| 233 | pub const MMAP2_UNIT = 4096; | ||
| 234 | |||
| 235 | pub const VDSO = struct { | 233 | pub const VDSO = struct { |
| 236 | pub const CGT_SYM = "__vdso_clock_gettime"; | 234 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| 237 | pub const CGT_VER = "LINUX_2.6"; | 235 | pub const CGT_VER = "LINUX_2.6"; |
lib/std/posix.zig-1| ... | @@ -82,7 +82,6 @@ pub const MADV = system.MADV; | ... | @@ -82,7 +82,6 @@ pub const MADV = system.MADV; |
| 82 | pub const MAP = system.MAP; | 82 | pub const MAP = system.MAP; |
| 83 | pub const MAX_ADDR_LEN = system.MAX_ADDR_LEN; | 83 | pub const MAX_ADDR_LEN = system.MAX_ADDR_LEN; |
| 84 | pub const MFD = system.MFD; | 84 | pub const MFD = system.MFD; |
| 85 | pub const MMAP2_UNIT = system.MMAP2_UNIT; | ||
| 86 | pub const MREMAP = system.MREMAP; | 85 | pub const MREMAP = system.MREMAP; |
| 87 | pub const MSF = system.MSF; | 86 | pub const MSF = system.MSF; |
| 88 | pub const MSG = system.MSG; | 87 | pub const MSG = system.MSG; |