| author | |
| committer | |
| log | b21bcbd7755d236a313c06e6ff167f5395ab8ed4 |
| tree | 23fef3cf665a6d396347ee3b88c6142aad92b8fa |
| parent | 6376d96824c5205ecc02b2c621bcef5dc78f1a81 |
4 files changed, 14 insertions(+), 12 deletions(-)
std/heap.zig+3-3| ... | @@ -91,7 +91,7 @@ pub const DirectAllocator = struct { | ... | @@ -91,7 +91,7 @@ pub const DirectAllocator = struct { |
| 91 | const unused_start = addr; | 91 | const unused_start = addr; |
| 92 | const unused_len = aligned_addr - 1 - unused_start; | 92 | const unused_len = aligned_addr - 1 - unused_start; |
| 93 | 93 | ||
| 94 | var err = p.munmap(@intToPtr(&u8, unused_start), unused_len); | 94 | var err = p.munmap(unused_start, unused_len); |
| 95 | debug.assert(p.getErrno(err) == 0); | 95 | debug.assert(p.getErrno(err) == 0); |
| 96 | 96 | ||
| 97 | //It is impossible that there is an unoccupied page at the top of our | 97 | //It is impossible that there is an unoccupied page at the top of our |
| ... | @@ -132,7 +132,7 @@ pub const DirectAllocator = struct { | ... | @@ -132,7 +132,7 @@ pub const DirectAllocator = struct { |
| 132 | const rem = @rem(new_addr_end, os.page_size); | 132 | const rem = @rem(new_addr_end, os.page_size); |
| 133 | const new_addr_end_rounded = new_addr_end + if (rem == 0) 0 else (os.page_size - rem); | 133 | const new_addr_end_rounded = new_addr_end + if (rem == 0) 0 else (os.page_size - rem); |
| 134 | if (old_addr_end > new_addr_end_rounded) { | 134 | if (old_addr_end > new_addr_end_rounded) { |
| 135 | _ = os.posix.munmap(@intToPtr(&u8, new_addr_end_rounded), old_addr_end - new_addr_end_rounded); | 135 | _ = os.posix.munmap(new_addr_end_rounded, old_addr_end - new_addr_end_rounded); |
| 136 | } | 136 | } |
| 137 | return old_mem[0..new_size]; | 137 | return old_mem[0..new_size]; |
| 138 | } | 138 | } |
| ... | @@ -170,7 +170,7 @@ pub const DirectAllocator = struct { | ... | @@ -170,7 +170,7 @@ pub const DirectAllocator = struct { |
| 170 | 170 | ||
| 171 | switch (builtin.os) { | 171 | switch (builtin.os) { |
| 172 | Os.linux, Os.macosx, Os.ios => { | 172 | Os.linux, Os.macosx, Os.ios => { |
| 173 | _ = os.posix.munmap(bytes.ptr, bytes.len); | 173 | _ = os.posix.munmap(@ptrToInt(bytes.ptr), bytes.len); |
| 174 | }, | 174 | }, |
| 175 | Os.windows => { | 175 | Os.windows => { |
| 176 | const record_addr = @ptrToInt(bytes.ptr) + bytes.len; | 176 | const record_addr = @ptrToInt(bytes.ptr) + bytes.len; |
std/os/darwin.zig+4-4| ... | @@ -184,7 +184,7 @@ pub fn write(fd: i32, buf: &const u8, nbyte: usize) usize { | ... | @@ -184,7 +184,7 @@ pub fn write(fd: i32, buf: &const u8, nbyte: usize) usize { |
| 184 | return errnoWrap(c.write(fd, @ptrCast(&const c_void, buf), nbyte)); | 184 | return errnoWrap(c.write(fd, @ptrCast(&const c_void, buf), nbyte)); |
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | pub fn mmap(address: ?&u8, length: usize, prot: usize, flags: usize, fd: i32, | 187 | pub fn mmap(address: ?&u8, length: usize, prot: usize, flags: u32, fd: i32, |
| 188 | offset: isize) usize | 188 | offset: isize) usize |
| 189 | { | 189 | { |
| 190 | const ptr_result = c.mmap(@ptrCast(&c_void, address), length, | 190 | const ptr_result = c.mmap(@ptrCast(&c_void, address), length, |
| ... | @@ -193,8 +193,8 @@ pub fn mmap(address: ?&u8, length: usize, prot: usize, flags: usize, fd: i32, | ... | @@ -193,8 +193,8 @@ pub fn mmap(address: ?&u8, length: usize, prot: usize, flags: usize, fd: i32, |
| 193 | return errnoWrap(isize_result); | 193 | return errnoWrap(isize_result); |
| 194 | } | 194 | } |
| 195 | 195 | ||
| 196 | pub fn munmap(address: &u8, length: usize) usize { | 196 | pub fn munmap(address: usize, length: usize) usize { |
| 197 | return errnoWrap(c.munmap(@ptrCast(&c_void, address), length)); | 197 | return errnoWrap(c.munmap(@intToPtr(&c_void, address), length)); |
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | pub fn unlink(path: &const u8) usize { | 200 | pub fn unlink(path: &const u8) usize { |
| ... | @@ -341,4 +341,4 @@ pub const timeval = c.timeval; | ... | @@ -341,4 +341,4 @@ pub const timeval = c.timeval; |
| 341 | pub const mach_timebase_info_data = c.mach_timebase_info_data; | 341 | pub const mach_timebase_info_data = c.mach_timebase_info_data; |
| 342 | 342 | ||
| 343 | pub const mach_absolute_time = c.mach_absolute_time; | 343 | pub const mach_absolute_time = c.mach_absolute_time; |
| 344 | pub const mach_timebase_info = c.mach_timebase_info; | ||
| \ No newline at end of file | |||
| 344 | pub const mach_timebase_info = c.mach_timebase_info; | ||
std/os/index.zig+4-2| ... | @@ -2497,11 +2497,13 @@ pub fn spawnThread(context: var, comptime startFn: var) SpawnThreadError!&Thread | ... | @@ -2497,11 +2497,13 @@ pub fn spawnThread(context: var, comptime startFn: var) SpawnThreadError!&Thread |
| 2497 | } | 2497 | } |
| 2498 | }; | 2498 | }; |
| 2499 | 2499 | ||
| 2500 | const MAP_GROWSDOWN = if (builtin.os == builtin.Os.linux) linux.MAP_GROWSDOWN else 0; | ||
| 2501 | |||
| 2500 | const stack_len = default_stack_size; | 2502 | const stack_len = default_stack_size; |
| 2501 | const stack_addr = posix.mmap(null, stack_len, posix.PROT_READ|posix.PROT_WRITE, | 2503 | const stack_addr = posix.mmap(null, stack_len, posix.PROT_READ|posix.PROT_WRITE, |
| 2502 | posix.MAP_PRIVATE|posix.MAP_ANONYMOUS|posix.MAP_GROWSDOWN, -1, 0); | 2504 | posix.MAP_PRIVATE|posix.MAP_ANONYMOUS|MAP_GROWSDOWN, -1, 0); |
| 2503 | if (stack_addr == posix.MAP_FAILED) return error.OutOfMemory; | 2505 | if (stack_addr == posix.MAP_FAILED) return error.OutOfMemory; |
| 2504 | errdefer _ = posix.munmap(stack_addr, stack_len); | 2506 | errdefer assert(posix.munmap(stack_addr, stack_len) == 0); |
| 2505 | 2507 | ||
| 2506 | var stack_end: usize = stack_addr + stack_len; | 2508 | var stack_end: usize = stack_addr + stack_len; |
| 2507 | var arg: usize = undefined; | 2509 | var arg: usize = undefined; |
std/os/linux/index.zig+3-3| ... | @@ -706,13 +706,13 @@ pub fn umount2(special: &const u8, flags: u32) usize { | ... | @@ -706,13 +706,13 @@ pub fn umount2(special: &const u8, flags: u32) usize { |
| 706 | return syscall2(SYS_umount2, @ptrToInt(special), flags); | 706 | return syscall2(SYS_umount2, @ptrToInt(special), flags); |
| 707 | } | 707 | } |
| 708 | 708 | ||
| 709 | pub fn mmap(address: ?&u8, length: usize, prot: usize, flags: usize, fd: i32, offset: isize) usize { | 709 | pub fn mmap(address: ?&u8, length: usize, prot: usize, flags: u32, fd: i32, offset: isize) usize { |
| 710 | return syscall6(SYS_mmap, @ptrToInt(address), length, prot, flags, usize(fd), | 710 | return syscall6(SYS_mmap, @ptrToInt(address), length, prot, flags, usize(fd), |
| 711 | @bitCast(usize, offset)); | 711 | @bitCast(usize, offset)); |
| 712 | } | 712 | } |
| 713 | 713 | ||
| 714 | pub fn munmap(address: &u8, length: usize) usize { | 714 | pub fn munmap(address: usize, length: usize) usize { |
| 715 | return syscall2(SYS_munmap, @ptrToInt(address), length); | 715 | return syscall2(SYS_munmap, address, length); |
| 716 | } | 716 | } |
| 717 | 717 | ||
| 718 | pub fn read(fd: i32, buf: &u8, count: usize) usize { | 718 | pub fn read(fd: i32, buf: &u8, count: usize) usize { |