| 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 | 1601 | }, |
| 1602 | 1602 | else => void, |
| 1603 | 1603 | }; |
| 1604 | pub const MMAP2_UNIT = switch (native_os) { | |
| 1605 | .linux => linux.MMAP2_UNIT, | |
| 1606 | else => void, | |
| 1607 | }; | |
| 1608 | 1604 | pub const NAME_MAX = switch (native_os) { |
| 1609 | 1605 | .linux => linux.NAME_MAX, |
| 1610 | 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 | 93 | pub const F = arch_bits.F; |
| 94 | 94 | pub const Flock = arch_bits.Flock; |
| 95 | 95 | pub const HWCAP = arch_bits.HWCAP; |
| 96 | pub const MMAP2_UNIT = arch_bits.MMAP2_UNIT; | |
| 97 | 96 | pub const REG = arch_bits.REG; |
| 98 | 97 | pub const SC = arch_bits.SC; |
| 99 | 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 | 927 | prot, |
| 929 | 928 | @as(u32, @bitCast(flags)), |
| 930 | 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 | 932 | } else { |
| 934 | 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 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | pub const MMAP2_UNIT = 4096; | |
| 174 | ||
| 175 | 173 | pub const F = struct { |
| 176 | 174 | pub const DUPFD = 0; |
| 177 | 175 | pub const GETFD = 1; |
lib/std/os/linux/hexagon.zig-2| ... | ... | @@ -251,8 +251,6 @@ pub const Stat = extern struct { |
| 251 | 251 | |
| 252 | 252 | pub const Elf_Symndx = u32; |
| 253 | 253 | |
| 254 | pub const MMAP2_UNIT = 4096; | |
| 255 | ||
| 256 | 254 | pub const VDSO = void; |
| 257 | 255 | |
| 258 | 256 | /// TODO |
lib/std/os/linux/m68k.zig-4| ... | ... | @@ -261,10 +261,6 @@ pub const Stat = extern struct { |
| 261 | 261 | |
| 262 | 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 | 264 | // No VDSO used as of glibc 112a0ae18b831bf31f44d81b82666980312511d6. |
| 269 | 265 | pub const VDSO = void; |
| 270 | 266 |
lib/std/os/linux/mips.zig-2| ... | ... | @@ -294,8 +294,6 @@ pub const F = struct { |
| 294 | 294 | pub const GETOWNER_UIDS = 17; |
| 295 | 295 | }; |
| 296 | 296 | |
| 297 | pub const MMAP2_UNIT = 4096; | |
| 298 | ||
| 299 | 297 | pub const VDSO = struct { |
| 300 | 298 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| 301 | 299 | pub const CGT_VER = "LINUX_2.6"; |
lib/std/os/linux/mips64.zig-2| ... | ... | @@ -273,8 +273,6 @@ pub const F = struct { |
| 273 | 273 | pub const GETOWNER_UIDS = 17; |
| 274 | 274 | }; |
| 275 | 275 | |
| 276 | pub const MMAP2_UNIT = 4096; | |
| 277 | ||
| 278 | 276 | pub const VDSO = struct { |
| 279 | 277 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| 280 | 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 | 348 | |
| 349 | 349 | pub const Elf_Symndx = u32; |
| 350 | 350 | |
| 351 | pub const MMAP2_UNIT = 4096; | |
| 352 | ||
| 353 | 351 | /// TODO |
| 354 | 352 | pub const getcontext = {}; |
lib/std/os/linux/riscv32.zig-2| ... | ... | @@ -256,8 +256,6 @@ pub const Stat = extern struct { |
| 256 | 256 | |
| 257 | 257 | pub const Elf_Symndx = u32; |
| 258 | 258 | |
| 259 | pub const MMAP2_UNIT = 4096; | |
| 260 | ||
| 261 | 259 | pub const VDSO = struct { |
| 262 | 260 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| 263 | 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 | 508 | break :blk main_thread_area_buffer[0..area_desc.size]; |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | const begin_addr = mmap( | |
| 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 | ); | |
| 511 | const begin_addr = mmap_tls(area_desc.size + area_desc.alignment - 1); | |
| 519 | 512 | if (@call(.always_inline, linux.E.init, .{begin_addr}) != .SUCCESS) @trap(); |
| 520 | 513 | |
| 521 | 514 | const area_ptr: [*]align(page_size_min) u8 = @ptrFromInt(begin_addr); |
| ... | ... | @@ -530,16 +523,19 @@ pub fn initStatic(phdrs: []elf.Phdr) void { |
| 530 | 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 | 530 | if (@hasField(linux.SYS, "mmap2")) { |
| 535 | 531 | return @call(.always_inline, linux.syscall6, .{ |
| 536 | 532 | .mmap2, |
| 537 | @intFromPtr(address), | |
| 533 | 0, | |
| 538 | 534 | length, |
| 539 | 535 | prot, |
| 540 | 536 | @as(u32, @bitCast(flags)), |
| 541 | @as(usize, @bitCast(@as(isize, fd))), | |
| 542 | @as(usize, @truncate(@as(u64, @bitCast(offset)) / linux.MMAP2_UNIT)), | |
| 537 | @as(usize, @bitCast(@as(isize, -1))), | |
| 538 | 0, | |
| 543 | 539 | }); |
| 544 | 540 | } else { |
| 545 | 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 | 543 | return if (native_arch == .s390x) @call(.always_inline, linux.syscall1, .{ |
| 548 | 544 | .mmap, |
| 549 | 545 | @intFromPtr(&[_]usize{ |
| 550 | @intFromPtr(address), | |
| 546 | 0, | |
| 551 | 547 | length, |
| 552 | 548 | prot, |
| 553 | 549 | @as(u32, @bitCast(flags)), |
| 554 | @as(usize, @bitCast(@as(isize, fd))), | |
| 555 | @as(u64, @bitCast(offset)), | |
| 550 | @as(usize, @bitCast(@as(isize, -1))), | |
| 551 | 0, | |
| 556 | 552 | }), |
| 557 | 553 | }) else @call(.always_inline, linux.syscall6, .{ |
| 558 | 554 | .mmap, |
| 559 | @intFromPtr(address), | |
| 555 | 0, | |
| 560 | 556 | length, |
| 561 | 557 | prot, |
| 562 | 558 | @as(u32, @bitCast(flags)), |
| 563 | @as(usize, @bitCast(@as(isize, fd))), | |
| 564 | @as(u64, @bitCast(offset)), | |
| 559 | @as(usize, @bitCast(@as(isize, -1))), | |
| 560 | 0, | |
| 565 | 561 | }); |
| 566 | 562 | } |
| 567 | 563 | } |
lib/std/os/linux/x86.zig-2| ... | ... | @@ -230,8 +230,6 @@ pub const F = struct { |
| 230 | 230 | pub const UNLCK = 2; |
| 231 | 231 | }; |
| 232 | 232 | |
| 233 | pub const MMAP2_UNIT = 4096; | |
| 234 | ||
| 235 | 233 | pub const VDSO = struct { |
| 236 | 234 | pub const CGT_SYM = "__vdso_clock_gettime"; |
| 237 | 235 | pub const CGT_VER = "LINUX_2.6"; |
lib/std/posix.zig-1| ... | ... | @@ -82,7 +82,6 @@ pub const MADV = system.MADV; |
| 82 | 82 | pub const MAP = system.MAP; |
| 83 | 83 | pub const MAX_ADDR_LEN = system.MAX_ADDR_LEN; |
| 84 | 84 | pub const MFD = system.MFD; |
| 85 | pub const MMAP2_UNIT = system.MMAP2_UNIT; | |
| 86 | 85 | pub const MREMAP = system.MREMAP; |
| 87 | 86 | pub const MSF = system.MSF; |
| 88 | 87 | pub const MSG = system.MSG; |