| ... | @@ -131,7 +131,7 @@ pub fn readlink(noalias path: [*]const u8, noalias buf_ptr: [*]u8, buf_len: usiz | ... | @@ -131,7 +131,7 @@ pub fn readlink(noalias path: [*]const u8, noalias buf_ptr: [*]u8, buf_len: usiz |
| 131 | if (@hasDecl(@This(), "SYS_readlink")) { | 131 | if (@hasDecl(@This(), "SYS_readlink")) { |
| 132 | return syscall3(SYS_readlink, @ptrToInt(path), @ptrToInt(buf_ptr), buf_len); | 132 | return syscall3(SYS_readlink, @ptrToInt(path), @ptrToInt(buf_ptr), buf_len); |
| 133 | } else { | 133 | } else { |
| 134 | return syscall4(SYS_readlinkat, AT_FDCWD, @ptrToInt(path), @ptrToInt(buf_ptr), buf_len); | 134 | return syscall4(SYS_readlinkat, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(path), @ptrToInt(buf_ptr), buf_len); |
| 135 | } | 135 | } |
| 136 | } | 136 | } |
| 137 | | 137 | |
| ... | @@ -145,7 +145,7 @@ pub fn mkdir(path: [*]const u8, mode: u32) usize { | ... | @@ -145,7 +145,7 @@ pub fn mkdir(path: [*]const u8, mode: u32) usize { |
| 145 | if (@hasDecl(@This(), "SYS_mkdir")) { | 145 | if (@hasDecl(@This(), "SYS_mkdir")) { |
| 146 | return syscall2(SYS_mkdir, @ptrToInt(path), mode); | 146 | return syscall2(SYS_mkdir, @ptrToInt(path), mode); |
| 147 | } else { | 147 | } else { |
| 148 | return syscall3(SYS_mkdirat, AT_FDCWD, @ptrToInt(path), mode); | 148 | return syscall3(SYS_mkdirat, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(path), mode); |
| 149 | } | 149 | } |
| 150 | } | 150 | } |
| 151 | | 151 | |
| ... | @@ -206,7 +206,7 @@ pub fn rmdir(path: [*]const u8) usize { | ... | @@ -206,7 +206,7 @@ pub fn rmdir(path: [*]const u8) usize { |
| 206 | if (@hasDecl(@This(), "SYS_rmdir")) { | 206 | if (@hasDecl(@This(), "SYS_rmdir")) { |
| 207 | return syscall1(SYS_rmdir, @ptrToInt(path)); | 207 | return syscall1(SYS_rmdir, @ptrToInt(path)); |
| 208 | } else { | 208 | } else { |
| 209 | return syscall3(SYS_unlinkat, AT_FDCWD, @ptrToInt(path), AT_REMOVEDIR); | 209 | return syscall3(SYS_unlinkat, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(path), AT_REMOVEDIR); |
| 210 | } | 210 | } |
| 211 | } | 211 | } |
| 212 | | 212 | |
| ... | @@ -215,7 +215,7 @@ pub fn symlink(existing: [*]const u8, new: [*]const u8) usize { | ... | @@ -215,7 +215,7 @@ pub fn symlink(existing: [*]const u8, new: [*]const u8) usize { |
| 215 | if (@hasDecl(@This(), "SYS_symlink")) { | 215 | if (@hasDecl(@This(), "SYS_symlink")) { |
| 216 | return syscall2(SYS_symlink, @ptrToInt(existing), @ptrToInt(new)); | 216 | return syscall2(SYS_symlink, @ptrToInt(existing), @ptrToInt(new)); |
| 217 | } else { | 217 | } else { |
| 218 | return syscall3(SYS_symlinkat, @ptrToInt(existing), AT_FDCWD, @ptrToInt(new)); | 218 | return syscall3(SYS_symlinkat, @ptrToInt(existing), @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(new)); |
| 219 | } | 219 | } |
| 220 | } | 220 | } |
| 221 | | 221 | |
| ... | @@ -231,12 +231,16 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: usize) usize { | ... | @@ -231,12 +231,16 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: usize) usize { |
| 231 | | 231 | |
| 232 | // TODO https://github.com/ziglang/zig/issues/265 | 232 | // TODO https://github.com/ziglang/zig/issues/265 |
| 233 | pub fn access(path: [*]const u8, mode: u32) usize { | 233 | pub fn access(path: [*]const u8, mode: u32) usize { |
| 234 | return syscall2(SYS_access, @ptrToInt(path), mode); | 234 | if (@hasDecl(@This(), "SYS_access")) { |
| | 235 | return syscall2(SYS_access, @ptrToInt(path), mode); |
| | 236 | } else { |
| | 237 | return syscall4(SYS_faccessat, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(path), mode, 0); |
| | 238 | } |
| 235 | } | 239 | } |
| 236 | | 240 | |
| 237 | // TODO https://github.com/ziglang/zig/issues/265 | 241 | // TODO https://github.com/ziglang/zig/issues/265 |
| 238 | pub fn faccessat(dirfd: i32, path: [*]const u8, mode: u32) usize { | 242 | pub fn faccessat(dirfd: i32, path: [*]const u8, mode: u32, flags: u32) usize { |
| 239 | return syscall3(SYS_faccessat, @bitCast(usize, isize(dirfd)), @ptrToInt(path), mode); | 243 | return syscall4(SYS_faccessat, @bitCast(usize, isize(dirfd)), @ptrToInt(path), mode, flags); |
| 240 | } | 244 | } |
| 241 | | 245 | |
| 242 | pub fn pipe(fd: *[2]i32) usize { | 246 | pub fn pipe(fd: *[2]i32) usize { |
| ... | @@ -264,9 +268,9 @@ pub fn rename(old: [*]const u8, new: [*]const u8) usize { | ... | @@ -264,9 +268,9 @@ pub fn rename(old: [*]const u8, new: [*]const u8) usize { |
| 264 | if (@hasDecl(@This(), "SYS_rename")) { | 268 | if (@hasDecl(@This(), "SYS_rename")) { |
| 265 | return syscall2(SYS_rename, @ptrToInt(old), @ptrToInt(new)); | 269 | return syscall2(SYS_rename, @ptrToInt(old), @ptrToInt(new)); |
| 266 | } else if (@hasDecl(@This(), "SYS_renameat")) { | 270 | } else if (@hasDecl(@This(), "SYS_renameat")) { |
| 267 | return syscall4(SYS_renameat, AT_FDCWD, @ptrToInt(old), AT_FDCWD, @ptrToInt(new)); | 271 | return syscall4(SYS_renameat, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(old), @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(new)); |
| 268 | } else { | 272 | } else { |
| 269 | return syscall5(SYS_renameat2, AT_FDCWD, @ptrToInt(old), AT_FDCWD, @ptrToInt(new), 0); | 273 | return syscall5(SYS_renameat2, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(old), @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(new), 0); |
| 270 | } | 274 | } |
| 271 | } | 275 | } |
| 272 | | 276 | |
| ... | @@ -305,7 +309,17 @@ pub fn renameat2(oldfd: i32, oldpath: [*]const u8, newfd: i32, newpath: [*]const | ... | @@ -305,7 +309,17 @@ pub fn renameat2(oldfd: i32, oldpath: [*]const u8, newfd: i32, newpath: [*]const |
| 305 | | 309 | |
| 306 | // TODO https://github.com/ziglang/zig/issues/265 | 310 | // TODO https://github.com/ziglang/zig/issues/265 |
| 307 | pub fn open(path: [*]const u8, flags: u32, perm: usize) usize { | 311 | pub fn open(path: [*]const u8, flags: u32, perm: usize) usize { |
| 308 | return syscall3(SYS_open, @ptrToInt(path), flags, perm); | 312 | if (@hasDecl(@This(), "SYS_open")) { |
| | 313 | return syscall3(SYS_open, @ptrToInt(path), flags, perm); |
| | 314 | } else { |
| | 315 | return syscall4( |
| | 316 | SYS_openat, |
| | 317 | @bitCast(usize, isize(AT_FDCWD)), |
| | 318 | @ptrToInt(path), |
| | 319 | flags, |
| | 320 | perm, |
| | 321 | ); |
| | 322 | } |
| 309 | } | 323 | } |
| 310 | | 324 | |
| 311 | // TODO https://github.com/ziglang/zig/issues/265 | 325 | // TODO https://github.com/ziglang/zig/issues/265 |
| ... | @@ -373,7 +387,7 @@ pub fn unlink(path: [*]const u8) usize { | ... | @@ -373,7 +387,7 @@ pub fn unlink(path: [*]const u8) usize { |
| 373 | if (@hasDecl(@This(), "SYS_unlink")) { | 387 | if (@hasDecl(@This(), "SYS_unlink")) { |
| 374 | return syscall1(SYS_unlink, @ptrToInt(path)); | 388 | return syscall1(SYS_unlink, @ptrToInt(path)); |
| 375 | } else { | 389 | } else { |
| 376 | return syscall3(SYS_unlinkat, AT_FDCWD, @ptrToInt(path), 0); | 390 | return syscall3(SYS_unlinkat, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(path), 0); |
| 377 | } | 391 | } |
| 378 | } | 392 | } |
| 379 | | 393 | |
| ... | @@ -759,18 +773,12 @@ pub fn epoll_create1(flags: usize) usize { | ... | @@ -759,18 +773,12 @@ pub fn epoll_create1(flags: usize) usize { |
| 759 | return syscall1(SYS_epoll_create1, flags); | 773 | return syscall1(SYS_epoll_create1, flags); |
| 760 | } | 774 | } |
| 761 | | 775 | |
| 762 | pub fn epoll_ctl(epoll_fd: i32, op: u32, fd: i32, ev: *epoll_event) usize { | 776 | pub fn epoll_ctl(epoll_fd: i32, op: u32, fd: i32, ev: ?*epoll_event) usize { |
| 763 | return syscall4(SYS_epoll_ctl, @bitCast(usize, isize(epoll_fd)), @intCast(usize, op), @bitCast(usize, isize(fd)), @ptrToInt(ev)); | 777 | return syscall4(SYS_epoll_ctl, @bitCast(usize, isize(epoll_fd)), @intCast(usize, op), @bitCast(usize, isize(fd)), @ptrToInt(ev)); |
| 764 | } | 778 | } |
| 765 | | 779 | |
| 766 | pub fn epoll_wait(epoll_fd: i32, events: [*]epoll_event, maxevents: u32, timeout: i32) usize { | 780 | pub fn epoll_wait(epoll_fd: i32, events: [*]epoll_event, maxevents: u32, timeout: i32) usize { |
| 767 | return syscall4( | 781 | return epoll_pwait(epoll_fd, events, maxevents, timeout, null); |
| 768 | SYS_epoll_wait, | | |
| 769 | @bitCast(usize, isize(epoll_fd)), | | |
| 770 | @ptrToInt(events), | | |
| 771 | maxevents, | | |
| 772 | @bitCast(usize, isize(timeout)), | | |
| 773 | ); | | |
| 774 | } | 782 | } |
| 775 | | 783 | |
| 776 | pub fn epoll_pwait(epoll_fd: i32, events: [*]epoll_event, maxevents: u32, timeout: i32, sigmask: ?*sigset_t) usize { | 784 | pub fn epoll_pwait(epoll_fd: i32, events: [*]epoll_event, maxevents: u32, timeout: i32, sigmask: ?*sigset_t) usize { |