aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os/linux.zig
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2020-03-02 23:30:53 +1100
committerAndrew Kelley <andrew@ziglang.org>2020-03-31 10:16:20 -0400
commit63409cf422c71fee64c55f2b77999ee94366400f (patch)
tree812702ccc1f2f89150b2a6763cd1801e1deb2b39 /lib/std/os/linux.zig
parent839d85e4405aef4856d1a35a6580226e997cc369 (diff)
downloadzig-63409cf422c71fee64c55f2b77999ee94366400f.tar.gz
zig-63409cf422c71fee64c55f2b77999ee94366400f.zip
std: linux syscall numbers are now an extensible enum
Diffstat (limited to 'lib/std/os/linux.zig')
-rw-r--r--lib/std/os/linux.zig454
1 files changed, 227 insertions, 227 deletions
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig
index 2e1437e6a9..1ed8370274 100644
--- a/lib/std/os/linux.zig
+++ b/lib/std/os/linux.zig
@@ -53,46 +53,46 @@ pub fn getErrno(r: usize) u12 {
}
pub fn dup2(old: i32, new: i32) usize {
- if (@hasDecl(@This(), "SYS_dup2")) {
- return syscall2(SYS_dup2, @bitCast(usize, @as(isize, old)), @bitCast(usize, @as(isize, new)));
+ if (@hasField(SYS, "dup2")) {
+ return syscall2(.dup2, @bitCast(usize, @as(isize, old)), @bitCast(usize, @as(isize, new)));
} else {
if (old == new) {
if (std.debug.runtime_safety) {
- const rc = syscall2(SYS_fcntl, @bitCast(usize, @as(isize, old)), F_GETFD);
+ const rc = syscall2(.fcntl, @bitCast(usize, @as(isize, old)), F_GETFD);
if (@bitCast(isize, rc) < 0) return rc;
}
return @intCast(usize, old);
} else {
- return syscall3(SYS_dup3, @bitCast(usize, @as(isize, old)), @bitCast(usize, @as(isize, new)), 0);
+ return syscall3(.dup3, @bitCast(usize, @as(isize, old)), @bitCast(usize, @as(isize, new)), 0);
}
}
}
pub fn dup3(old: i32, new: i32, flags: u32) usize {
- return syscall3(SYS_dup3, @bitCast(usize, @as(isize, old)), @bitCast(usize, @as(isize, new)), flags);
+ return syscall3(.dup3, @bitCast(usize, @as(isize, old)), @bitCast(usize, @as(isize, new)), flags);
}
pub fn chdir(path: [*:0]const u8) usize {
- return syscall1(SYS_chdir, @ptrToInt(path));
+ return syscall1(.chdir, @ptrToInt(path));
}
pub fn fchdir(fd: fd_t) usize {
- return syscall1(SYS_fchdir, @bitCast(usize, @as(isize, fd)));
+ return syscall1(.fchdir, @bitCast(usize, @as(isize, fd)));
}
pub fn chroot(path: [*:0]const u8) usize {
- return syscall1(SYS_chroot, @ptrToInt(path));
+ return syscall1(.chroot, @ptrToInt(path));
}
pub fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) usize {
- return syscall3(SYS_execve, @ptrToInt(path), @ptrToInt(argv), @ptrToInt(envp));
+ return syscall3(.execve, @ptrToInt(path), @ptrToInt(argv), @ptrToInt(envp));
}
pub fn fork() usize {
- if (@hasDecl(@This(), "SYS_fork")) {
- return syscall0(SYS_fork);
+ if (@hasField(SYS, "fork")) {
+ return syscall0(.fork);
} else {
- return syscall2(SYS_clone, SIGCHLD, 0);
+ return syscall2(.clone, SIGCHLD, 0);
}
}
@@ -102,7 +102,7 @@ pub fn fork() usize {
/// the compiler is not aware of how vfork affects control flow and you may
/// see different results in optimized builds.
pub inline fn vfork() usize {
- return @call(.{ .modifier = .always_inline }, syscall0, .{SYS_vfork});
+ return @call(.{ .modifier = .always_inline }, syscall0, .{.vfork});
}
pub fn futimens(fd: i32, times: *const [2]timespec) usize {
@@ -110,24 +110,24 @@ pub fn futimens(fd: i32, times: *const [2]timespec) usize {
}
pub fn utimensat(dirfd: i32, path: ?[*:0]const u8, times: *const [2]timespec, flags: u32) usize {
- return syscall4(SYS_utimensat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(times), flags);
+ return syscall4(.utimensat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(times), flags);
}
pub fn futex_wait(uaddr: *const i32, futex_op: u32, val: i32, timeout: ?*timespec) usize {
- return syscall4(SYS_futex, @ptrToInt(uaddr), futex_op, @bitCast(u32, val), @ptrToInt(timeout));
+ return syscall4(.futex, @ptrToInt(uaddr), futex_op, @bitCast(u32, val), @ptrToInt(timeout));
}
pub fn futex_wake(uaddr: *const i32, futex_op: u32, val: i32) usize {
- return syscall3(SYS_futex, @ptrToInt(uaddr), futex_op, @bitCast(u32, val));
+ return syscall3(.futex, @ptrToInt(uaddr), futex_op, @bitCast(u32, val));
}
pub fn getcwd(buf: [*]u8, size: usize) usize {
- return syscall2(SYS_getcwd, @ptrToInt(buf), size);
+ return syscall2(.getcwd, @ptrToInt(buf), size);
}
pub fn getdents(fd: i32, dirp: [*]u8, len: usize) usize {
return syscall3(
- SYS_getdents,
+ .getdents,
@bitCast(usize, @as(isize, fd)),
@ptrToInt(dirp),
std.math.min(len, maxInt(c_int)),
@@ -136,7 +136,7 @@ pub fn getdents(fd: i32, dirp: [*]u8, len: usize) usize {
pub fn getdents64(fd: i32, dirp: [*]u8, len: usize) usize {
return syscall3(
- SYS_getdents64,
+ .getdents64,
@bitCast(usize, @as(isize, fd)),
@ptrToInt(dirp),
std.math.min(len, maxInt(c_int)),
@@ -144,61 +144,61 @@ pub fn getdents64(fd: i32, dirp: [*]u8, len: usize) usize {
}
pub fn inotify_init1(flags: u32) usize {
- return syscall1(SYS_inotify_init1, flags);
+ return syscall1(.inotify_init1, flags);
}
pub fn inotify_add_watch(fd: i32, pathname: [*:0]const u8, mask: u32) usize {
- return syscall3(SYS_inotify_add_watch, @bitCast(usize, @as(isize, fd)), @ptrToInt(pathname), mask);
+ return syscall3(.inotify_add_watch, @bitCast(usize, @as(isize, fd)), @ptrToInt(pathname), mask);
}
pub fn inotify_rm_watch(fd: i32, wd: i32) usize {
- return syscall2(SYS_inotify_rm_watch, @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, wd)));
+ return syscall2(.inotify_rm_watch, @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, wd)));
}
pub fn readlink(noalias path: [*:0]const u8, noalias buf_ptr: [*]u8, buf_len: usize) usize {
- if (@hasDecl(@This(), "SYS_readlink")) {
- return syscall3(SYS_readlink, @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
+ if (@hasField(SYS, "readlink")) {
+ return syscall3(.readlink, @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
} else {
- return syscall4(SYS_readlinkat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
+ return syscall4(.readlinkat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
}
}
pub fn readlinkat(dirfd: i32, noalias path: [*:0]const u8, noalias buf_ptr: [*]u8, buf_len: usize) usize {
- return syscall4(SYS_readlinkat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
+ return syscall4(.readlinkat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
}
pub fn mkdir(path: [*:0]const u8, mode: u32) usize {
- if (@hasDecl(@This(), "SYS_mkdir")) {
- return syscall2(SYS_mkdir, @ptrToInt(path), mode);
+ if (@hasField(SYS, "mkdir")) {
+ return syscall2(.mkdir, @ptrToInt(path), mode);
} else {
- return syscall3(SYS_mkdirat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(path), mode);
+ return syscall3(.mkdirat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(path), mode);
}
}
pub fn mkdirat(dirfd: i32, path: [*:0]const u8, mode: u32) usize {
- return syscall3(SYS_mkdirat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), mode);
+ return syscall3(.mkdirat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), mode);
}
pub fn mount(special: [*:0]const u8, dir: [*:0]const u8, fstype: [*:0]const u8, flags: u32, data: usize) usize {
- return syscall5(SYS_mount, @ptrToInt(special), @ptrToInt(dir), @ptrToInt(fstype), flags, data);
+ return syscall5(.mount, @ptrToInt(special), @ptrToInt(dir), @ptrToInt(fstype), flags, data);
}
pub fn umount(special: [*:0]const u8) usize {
- return syscall2(SYS_umount2, @ptrToInt(special), 0);
+ return syscall2(.umount2, @ptrToInt(special), 0);
}
pub fn umount2(special: [*:0]const u8, flags: u32) usize {
- return syscall2(SYS_umount2, @ptrToInt(special), flags);
+ return syscall2(.umount2, @ptrToInt(special), flags);
}
pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, offset: u64) usize {
- if (@hasDecl(@This(), "SYS_mmap2")) {
+ if (@hasField(SYS, "mmap2")) {
// Make sure the offset is also specified in multiples of page size
if ((offset & (MMAP2_UNIT - 1)) != 0)
return @bitCast(usize, @as(isize, -EINVAL));
return syscall6(
- SYS_mmap2,
+ .mmap2,
@ptrToInt(address),
length,
prot,
@@ -208,7 +208,7 @@ pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, of
);
} else {
return syscall6(
- SYS_mmap,
+ .mmap,
@ptrToInt(address),
length,
prot,
@@ -220,19 +220,19 @@ pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, of
}
pub fn mprotect(address: [*]const u8, length: usize, protection: usize) usize {
- return syscall3(SYS_mprotect, @ptrToInt(address), length, protection);
+ return syscall3(.mprotect, @ptrToInt(address), length, protection);
}
pub fn munmap(address: [*]const u8, length: usize) usize {
- return syscall2(SYS_munmap, @ptrToInt(address), length);
+ return syscall2(.munmap, @ptrToInt(address), length);
}
pub fn poll(fds: [*]pollfd, n: nfds_t, timeout: i32) usize {
- if (@hasDecl(@This(), "SYS_poll")) {
- return syscall3(SYS_poll, @ptrToInt(fds), n, @bitCast(u32, timeout));
+ if (@hasField(SYS, "poll")) {
+ return syscall3(.poll, @ptrToInt(fds), n, @bitCast(u32, timeout));
} else {
return syscall6(
- SYS_ppoll,
+ .ppoll,
@ptrToInt(fds),
n,
@ptrToInt(if (timeout >= 0)
@@ -250,12 +250,12 @@ pub fn poll(fds: [*]pollfd, n: nfds_t, timeout: i32) usize {
}
pub fn read(fd: i32, buf: [*]u8, count: usize) usize {
- return syscall3(SYS_read, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), count);
+ return syscall3(.read, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), count);
}
pub fn preadv(fd: i32, iov: [*]const iovec, count: usize, offset: u64) usize {
return syscall5(
- SYS_preadv,
+ .preadv,
@bitCast(usize, @as(isize, fd)),
@ptrToInt(iov),
count,
@@ -266,7 +266,7 @@ pub fn preadv(fd: i32, iov: [*]const iovec, count: usize, offset: u64) usize {
pub fn preadv2(fd: i32, iov: [*]const iovec, count: usize, offset: u64, flags: kernel_rwf) usize {
return syscall6(
- SYS_preadv2,
+ .preadv2,
@bitCast(usize, @as(isize, fd)),
@ptrToInt(iov),
count,
@@ -277,16 +277,16 @@ pub fn preadv2(fd: i32, iov: [*]const iovec, count: usize, offset: u64, flags: k
}
pub fn readv(fd: i32, iov: [*]const iovec, count: usize) usize {
- return syscall3(SYS_readv, @bitCast(usize, @as(isize, fd)), @ptrToInt(iov), count);
+ return syscall3(.readv, @bitCast(usize, @as(isize, fd)), @ptrToInt(iov), count);
}
pub fn writev(fd: i32, iov: [*]const iovec_const, count: usize) usize {
- return syscall3(SYS_writev, @bitCast(usize, @as(isize, fd)), @ptrToInt(iov), count);
+ return syscall3(.writev, @bitCast(usize, @as(isize, fd)), @ptrToInt(iov), count);
}
pub fn pwritev(fd: i32, iov: [*]const iovec_const, count: usize, offset: u64) usize {
return syscall5(
- SYS_pwritev,
+ .pwritev,
@bitCast(usize, @as(isize, fd)),
@ptrToInt(iov),
count,
@@ -297,7 +297,7 @@ pub fn pwritev(fd: i32, iov: [*]const iovec_const, count: usize, offset: u64) us
pub fn pwritev2(fd: i32, iov: [*]const iovec_const, count: usize, offset: u64, flags: kernel_rwf) usize {
return syscall6(
- SYS_pwritev2,
+ .pwritev2,
@bitCast(usize, @as(isize, fd)),
@ptrToInt(iov),
count,
@@ -308,30 +308,30 @@ pub fn pwritev2(fd: i32, iov: [*]const iovec_const, count: usize, offset: u64, f
}
pub fn rmdir(path: [*:0]const u8) usize {
- if (@hasDecl(@This(), "SYS_rmdir")) {
- return syscall1(SYS_rmdir, @ptrToInt(path));
+ if (@hasField(SYS, "rmdir")) {
+ return syscall1(.rmdir, @ptrToInt(path));
} else {
- return syscall3(SYS_unlinkat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(path), AT_REMOVEDIR);
+ return syscall3(.unlinkat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(path), AT_REMOVEDIR);
}
}
pub fn symlink(existing: [*:0]const u8, new: [*:0]const u8) usize {
- if (@hasDecl(@This(), "SYS_symlink")) {
- return syscall2(SYS_symlink, @ptrToInt(existing), @ptrToInt(new));
+ if (@hasField(SYS, "symlink")) {
+ return syscall2(.symlink, @ptrToInt(existing), @ptrToInt(new));
} else {
- return syscall3(SYS_symlinkat, @ptrToInt(existing), @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(new));
+ return syscall3(.symlinkat, @ptrToInt(existing), @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(new));
}
}
pub fn symlinkat(existing: [*:0]const u8, newfd: i32, newpath: [*:0]const u8) usize {
- return syscall3(SYS_symlinkat, @ptrToInt(existing), @bitCast(usize, @as(isize, newfd)), @ptrToInt(newpath));
+ return syscall3(.symlinkat, @ptrToInt(existing), @bitCast(usize, @as(isize, newfd)), @ptrToInt(newpath));
}
pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: u64) usize {
- if (@hasDecl(@This(), "SYS_pread64")) {
+ if (@hasField(SYS, "pread64")) {
if (require_aligned_register_pair) {
return syscall6(
- SYS_pread64,
+ .pread64,
@bitCast(usize, @as(isize, fd)),
@ptrToInt(buf),
count,
@@ -341,7 +341,7 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: u64) usize {
);
} else {
return syscall5(
- SYS_pread64,
+ .pread64,
@bitCast(usize, @as(isize, fd)),
@ptrToInt(buf),
count,
@@ -351,7 +351,7 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: u64) usize {
}
} else {
return syscall4(
- SYS_pread,
+ .pread,
@bitCast(usize, @as(isize, fd)),
@ptrToInt(buf),
count,
@@ -361,40 +361,40 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: u64) usize {
}
pub fn access(path: [*:0]const u8, mode: u32) usize {
- if (@hasDecl(@This(), "SYS_access")) {
- return syscall2(SYS_access, @ptrToInt(path), mode);
+ if (@hasField(SYS, "access")) {
+ return syscall2(.access, @ptrToInt(path), mode);
} else {
- return syscall4(SYS_faccessat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(path), mode, 0);
+ return syscall4(.faccessat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(path), mode, 0);
}
}
pub fn faccessat(dirfd: i32, path: [*:0]const u8, mode: u32, flags: u32) usize {
- return syscall4(SYS_faccessat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), mode, flags);
+ return syscall4(.faccessat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), mode, flags);
}
pub fn pipe(fd: *[2]i32) usize {
if (comptime builtin.arch.isMIPS()) {
return syscall_pipe(fd);
- } else if (@hasDecl(@This(), "SYS_pipe")) {
- return syscall1(SYS_pipe, @ptrToInt(fd));
+ } else if (@hasField(SYS, "pipe")) {
+ return syscall1(.pipe, @ptrToInt(fd));
} else {
- return syscall2(SYS_pipe2, @ptrToInt(fd), 0);
+ return syscall2(.pipe2, @ptrToInt(fd), 0);
}
}
pub fn pipe2(fd: *[2]i32, flags: u32) usize {
- return syscall2(SYS_pipe2, @ptrToInt(fd), flags);
+ return syscall2(.pipe2, @ptrToInt(fd), flags);
}
pub fn write(fd: i32, buf: [*]const u8, count: usize) usize {
- return syscall3(SYS_write, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), count);
+ return syscall3(.write, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), count);
}
pub fn ftruncate(fd: i32, length: u64) usize {
- if (@hasDecl(@This(), "SYS_ftruncate64")) {
+ if (@hasField(SYS, "ftruncate64")) {
if (require_aligned_register_pair) {
return syscall4(
- SYS_ftruncate64,
+ .ftruncate64,
@bitCast(usize, @as(isize, fd)),
0,
@truncate(usize, length),
@@ -402,7 +402,7 @@ pub fn ftruncate(fd: i32, length: u64) usize {
);
} else {
return syscall3(
- SYS_ftruncate64,
+ .ftruncate64,
@bitCast(usize, @as(isize, fd)),
@truncate(usize, length),
@truncate(usize, length >> 32),
@@ -410,7 +410,7 @@ pub fn ftruncate(fd: i32, length: u64) usize {
}
} else {
return syscall2(
- SYS_ftruncate,
+ .ftruncate,
@bitCast(usize, @as(isize, fd)),
@truncate(usize, length),
);
@@ -418,10 +418,10 @@ pub fn ftruncate(fd: i32, length: u64) usize {
}
pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: usize) usize {
- if (@hasDecl(@This(), "SYS_pwrite64")) {
+ if (@hasField(SYS, "pwrite64")) {
if (require_aligned_register_pair) {
return syscall6(
- SYS_pwrite64,
+ .pwrite64,
@bitCast(usize, @as(isize, fd)),
@ptrToInt(buf),
count,
@@ -431,7 +431,7 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: usize) usize {
);
} else {
return syscall5(
- SYS_pwrite64,
+ .pwrite64,
@bitCast(usize, @as(isize, fd)),
@ptrToInt(buf),
count,
@@ -441,7 +441,7 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: usize) usize {
}
} else {
return syscall4(
- SYS_pwrite,
+ .pwrite,
@bitCast(usize, @as(isize, fd)),
@ptrToInt(buf),
count,
@@ -451,19 +451,19 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: usize) usize {
}
pub fn rename(old: [*:0]const u8, new: [*:0]const u8) usize {
- if (@hasDecl(@This(), "SYS_rename")) {
- return syscall2(SYS_rename, @ptrToInt(old), @ptrToInt(new));
- } else if (@hasDecl(@This(), "SYS_renameat")) {
- return syscall4(SYS_renameat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(old), @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(new));
+ if (@hasField(SYS, "rename")) {
+ return syscall2(.rename, @ptrToInt(old), @ptrToInt(new));
+ } else if (@hasField(SYS, "renameat")) {
+ return syscall4(.renameat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(old), @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(new));
} else {
- return syscall5(SYS_renameat2, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(old), @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(new), 0);
+ return syscall5(.renameat2, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(old), @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(new), 0);
}
}
pub fn renameat(oldfd: i32, oldpath: [*]const u8, newfd: i32, newpath: [*]const u8) usize {
- if (@hasDecl(@This(), "SYS_renameat")) {
+ if (@hasField(SYS, "renameat")) {
return syscall4(
- SYS_renameat,
+ .renameat,
@bitCast(usize, @as(isize, oldfd)),
@ptrToInt(oldpath),
@bitCast(usize, @as(isize, newfd)),
@@ -471,7 +471,7 @@ pub fn renameat(oldfd: i32, oldpath: [*]const u8, newfd: i32, newpath: [*]const
);
} else {
return syscall5(
- SYS_renameat2,
+ .renameat2,
@bitCast(usize, @as(isize, oldfd)),
@ptrToInt(oldpath),
@bitCast(usize, @as(isize, newfd)),
@@ -483,7 +483,7 @@ pub fn renameat(oldfd: i32, oldpath: [*]const u8, newfd: i32, newpath: [*]const
pub fn renameat2(oldfd: i32, oldpath: [*:0]const u8, newfd: i32, newpath: [*:0]const u8, flags: u32) usize {
return syscall5(
- SYS_renameat2,
+ .renameat2,
@bitCast(usize, @as(isize, oldfd)),
@ptrToInt(oldpath),
@bitCast(usize, @as(isize, newfd)),
@@ -493,11 +493,11 @@ pub fn renameat2(oldfd: i32, oldpath: [*:0]const u8, newfd: i32, newpath: [*:0]c
}
pub fn open(path: [*:0]const u8, flags: u32, perm: usize) usize {
- if (@hasDecl(@This(), "SYS_open")) {
- return syscall3(SYS_open, @ptrToInt(path), flags, perm);
+ if (@hasField(SYS, "open")) {
+ return syscall3(.open, @ptrToInt(path), flags, perm);
} else {
return syscall4(
- SYS_openat,
+ .openat,
@bitCast(usize, @as(isize, AT_FDCWD)),
@ptrToInt(path),
flags,
@@ -507,32 +507,32 @@ pub fn open(path: [*:0]const u8, flags: u32, perm: usize) usize {
}
pub fn create(path: [*:0]const u8, perm: usize) usize {
- return syscall2(SYS_creat, @ptrToInt(path), perm);
+ return syscall2(.creat, @ptrToInt(path), perm);
}
pub fn openat(dirfd: i32, path: [*:0]const u8, flags: u32, mode: usize) usize {
// dirfd could be negative, for example AT_FDCWD is -100
- return syscall4(SYS_openat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), flags, mode);
+ return syscall4(.openat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), flags, mode);
}
/// See also `clone` (from the arch-specific include)
pub fn clone5(flags: usize, child_stack_ptr: usize, parent_tid: *i32, child_tid: *i32, newtls: usize) usize {
- return syscall5(SYS_clone, flags, child_stack_ptr, @ptrToInt(parent_tid), @ptrToInt(child_tid), newtls);
+ return syscall5(.clone, flags, child_stack_ptr, @ptrToInt(parent_tid), @ptrToInt(child_tid), newtls);
}
/// See also `clone` (from the arch-specific include)
pub fn clone2(flags: u32, child_stack_ptr: usize) usize {
- return syscall2(SYS_clone, flags, child_stack_ptr);
+ return syscall2(.clone, flags, child_stack_ptr);
}
pub fn close(fd: i32) usize {
- return syscall1(SYS_close, @bitCast(usize, @as(isize, fd)));
+ return syscall1(.close, @bitCast(usize, @as(isize, fd)));
}
/// Can only be called on 32 bit systems. For 64 bit see `lseek`.
pub fn llseek(fd: i32, offset: u64, result: ?*u64, whence: usize) usize {
return syscall5(
- SYS__llseek,
+ ._llseek,
@bitCast(usize, @as(isize, fd)),
@truncate(usize, offset >> 32),
@truncate(usize, offset),
@@ -543,53 +543,53 @@ pub fn llseek(fd: i32, offset: u64, result: ?*u64, whence: usize) usize {
/// Can only be called on 64 bit systems. For 32 bit see `llseek`.
pub fn lseek(fd: i32, offset: i64, whence: usize) usize {
- return syscall3(SYS_lseek, @bitCast(usize, @as(isize, fd)), @bitCast(usize, offset), whence);
+ return syscall3(.lseek, @bitCast(usize, @as(isize, fd)), @bitCast(usize, offset), whence);
}
pub fn exit(status: i32) noreturn {
- _ = syscall1(SYS_exit, @bitCast(usize, @as(isize, status)));
+ _ = syscall1(.exit, @bitCast(usize, @as(isize, status)));
unreachable;
}
pub fn exit_group(status: i32) noreturn {
- _ = syscall1(SYS_exit_group, @bitCast(usize, @as(isize, status)));
+ _ = syscall1(.exit_group, @bitCast(usize, @as(isize, status)));
unreachable;
}
pub fn getrandom(buf: [*]u8, count: usize, flags: u32) usize {
- return syscall3(SYS_getrandom, @ptrToInt(buf), count, flags);
+ return syscall3(.getrandom, @ptrToInt(buf), count, flags);
}
pub fn kill(pid: pid_t, sig: i32) usize {
- return syscall2(SYS_kill, @bitCast(usize, @as(isize, pid)), @bitCast(usize, @as(isize, sig)));
+ return syscall2(.kill, @bitCast(usize, @as(isize, pid)), @bitCast(usize, @as(isize, sig)));
}
pub fn tkill(tid: pid_t, sig: i32) usize {
- return syscall2(SYS_tkill, @bitCast(usize, @as(isize, tid)), @bitCast(usize, @as(isize, sig)));
+ return syscall2(.tkill, @bitCast(usize, @as(isize, tid)), @bitCast(usize, @as(isize, sig)));
}
pub fn tgkill(tgid: pid_t, tid: pid_t, sig: i32) usize {
- return syscall2(SYS_tgkill, @bitCast(usize, @as(isize, tgid)), @bitCast(usize, @as(isize, tid)), @bitCast(usize, @as(isize, sig)));
+ return syscall2(.tgkill, @bitCast(usize, @as(isize, tgid)), @bitCast(usize, @as(isize, tid)), @bitCast(usize, @as(isize, sig)));
}
pub fn unlink(path: [*:0]const u8) usize {
- if (@hasDecl(@This(), "SYS_unlink")) {
- return syscall1(SYS_unlink, @ptrToInt(path));
+ if (@hasField(SYS, "unlink")) {
+ return syscall1(.unlink, @ptrToInt(path));
} else {
- return syscall3(SYS_unlinkat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(path), 0);
+ return syscall3(.unlinkat, @bitCast(usize, @as(isize, AT_FDCWD)), @ptrToInt(path), 0);
}
}
pub fn unlinkat(dirfd: i32, path: [*:0]const u8, flags: u32) usize {
- return syscall3(SYS_unlinkat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), flags);
+ return syscall3(.unlinkat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), flags);
}
pub fn waitpid(pid: pid_t, status: *u32, flags: u32) usize {
- return syscall4(SYS_wait4, @bitCast(usize, @as(isize, pid)), @ptrToInt(status), flags, 0);
+ return syscall4(.wait4, @bitCast(usize, @as(isize, pid)), @ptrToInt(status), flags, 0);
}
pub fn fcntl(fd: fd_t, cmd: i32, arg: usize) usize {
- return syscall3(SYS_fcntl, @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, cmd)), arg);
+ return syscall3(.fcntl, @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, cmd)), arg);
}
var vdso_clock_gettime = @ptrCast(?*const c_void, init_vdso_clock_gettime);
@@ -609,7 +609,7 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {
}
}
}
- return syscall2(SYS_clock_gettime, @bitCast(usize, @as(isize, clk_id)), @ptrToInt(tp));
+ return syscall2(.clock_gettime, @bitCast(usize, @as(isize, clk_id)), @ptrToInt(tp));
}
fn init_vdso_clock_gettime(clk: i32, ts: *timespec) callconv(.C) usize {
@@ -626,86 +626,86 @@ fn init_vdso_clock_gettime(clk: i32, ts: *timespec) callconv(.C) usize {
}
pub fn clock_getres(clk_id: i32, tp: *timespec) usize {
- return syscall2(SYS_clock_getres, @bitCast(usize, @as(isize, clk_id)), @ptrToInt(tp));
+ return syscall2(.clock_getres, @bitCast(usize, @as(isize, clk_id)), @ptrToInt(tp));
}
pub fn clock_settime(clk_id: i32, tp: *const timespec) usize {
- return syscall2(SYS_clock_settime, @bitCast(usize, @as(isize, clk_id)), @ptrToInt(tp));
+ return syscall2(.clock_settime, @bitCast(usize, @as(isize, clk_id)), @ptrToInt(tp));
}
pub fn gettimeofday(tv: *timeval, tz: *timezone) usize {
- return syscall2(SYS_gettimeofday, @ptrToInt(tv), @ptrToInt(tz));
+ return syscall2(.gettimeofday, @ptrToInt(tv), @ptrToInt(tz));
}
pub fn settimeofday(tv: *const timeval, tz: *const timezone) usize {
- return syscall2(SYS_settimeofday, @ptrToInt(tv), @ptrToInt(tz));
+ return syscall2(.settimeofday, @ptrToInt(tv), @ptrToInt(tz));
}
pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize {
- return syscall2(SYS_nanosleep, @ptrToInt(req), @ptrToInt(rem));
+ return syscall2(.nanosleep, @ptrToInt(req), @ptrToInt(rem));
}
pub fn setuid(uid: u32) usize {
- if (@hasDecl(@This(), "SYS_setuid32")) {
- return syscall1(SYS_setuid32, uid);
+ if (@hasField(SYS, "setuid32")) {
+ return syscall1(.setuid32, uid);
} else {
- return syscall1(SYS_setuid, uid);
+ return syscall1(.setuid, uid);
}
}
pub fn setgid(gid: u32) usize {
- if (@hasDecl(@This(), "SYS_setgid32")) {
- return syscall1(SYS_setgid32, gid);
+ if (@hasField(SYS, "setgid32")) {
+ return syscall1(.setgid32, gid);
} else {
- return syscall1(SYS_setgid, gid);
+ return syscall1(.setgid, gid);
}
}
pub fn setreuid(ruid: u32, euid: u32) usize {
- if (@hasDecl(@This(), "SYS_setreuid32")) {
- return syscall2(SYS_setreuid32, ruid, euid);
+ if (@hasField(SYS, "setreuid32")) {
+ return syscall2(.setreuid32, ruid, euid);
} else {
- return syscall2(SYS_setreuid, ruid, euid);
+ return syscall2(.setreuid, ruid, euid);
}
}
pub fn setregid(rgid: u32, egid: u32) usize {
- if (@hasDecl(@This(), "SYS_setregid32")) {
- return syscall2(SYS_setregid32, rgid, egid);
+ if (@hasField(SYS, "setregid32")) {
+ return syscall2(.setregid32, rgid, egid);
} else {
- return syscall2(SYS_setregid, rgid, egid);
+ return syscall2(.setregid, rgid, egid);
}
}
pub fn getuid() u32 {
- if (@hasDecl(@This(), "SYS_getuid32")) {
- return @as(u32, syscall0(SYS_getuid32));
+ if (@hasField(SYS, "getuid32")) {
+ return @as(u32, syscall0(.getuid32));
} else {
- return @as(u32, syscall0(SYS_getuid));
+ return @as(u32, syscall0(.getuid));
}
}
pub fn getgid() u32 {
- if (@hasDecl(@This(), "SYS_getgid32")) {
- return @as(u32, syscall0(SYS_getgid32));
+ if (@hasField(SYS, "getgid32")) {
+ return @as(u32, syscall0(.getgid32));
} else {
- return @as(u32, syscall0(SYS_getgid));
+ return @as(u32, syscall0(.getgid));
}
}
pub fn geteuid() u32 {
- if (@hasDecl(@This(), "SYS_geteuid32")) {
- return @as(u32, syscall0(SYS_geteuid32));
+ if (@hasField(SYS, "geteuid32")) {
+ return @as(u32, syscall0(.geteuid32));
} else {
- return @as(u32, syscall0(SYS_geteuid));
+ return @as(u32, syscall0(.geteuid));
}
}
pub fn getegid() u32 {
- if (@hasDecl(@This(), "SYS_getegid32")) {
- return @as(u32, syscall0(SYS_getegid32));
+ if (@hasField(SYS, "getegid32")) {
+ return @as(u32, syscall0(.getegid32));
} else {
- return @as(u32, syscall0(SYS_getegid));
+ return @as(u32, syscall0(.getegid));
}
}
@@ -718,63 +718,63 @@ pub fn setegid(egid: u32) usize {
}
pub fn getresuid(ruid: *u32, euid: *u32, suid: *u32) usize {
- if (@hasDecl(@This(), "SYS_getresuid32")) {
- return syscall3(SYS_getresuid32, @ptrToInt(ruid), @ptrToInt(euid), @ptrToInt(suid));
+ if (@hasField(SYS, "getresuid32")) {
+ return syscall3(.getresuid32, @ptrToInt(ruid), @ptrToInt(euid), @ptrToInt(suid));
} else {
- return syscall3(SYS_getresuid, @ptrToInt(ruid), @ptrToInt(euid), @ptrToInt(suid));
+ return syscall3(.getresuid, @ptrToInt(ruid), @ptrToInt(euid), @ptrToInt(suid));
}
}
pub fn getresgid(rgid: *u32, egid: *u32, sgid: *u32) usize {
- if (@hasDecl(@This(), "SYS_getresgid32")) {
- return syscall3(SYS_getresgid32, @ptrToInt(rgid), @ptrToInt(egid), @ptrToInt(sgid));
+ if (@hasField(SYS, "getresgid32")) {
+ return syscall3(.getresgid32, @ptrToInt(rgid), @ptrToInt(egid), @ptrToInt(sgid));
} else {
- return syscall3(SYS_getresgid, @ptrToInt(rgid), @ptrToInt(egid), @ptrToInt(sgid));
+ return syscall3(.getresgid, @ptrToInt(rgid), @ptrToInt(egid), @ptrToInt(sgid));
}
}
pub fn setresuid(ruid: u32, euid: u32, suid: u32) usize {
- if (@hasDecl(@This(), "SYS_setresuid32")) {
- return syscall3(SYS_setresuid32, ruid, euid, suid);
+ if (@hasField(SYS, "setresuid32")) {
+ return syscall3(.setresuid32, ruid, euid, suid);
} else {
- return syscall3(SYS_setresuid, ruid, euid, suid);
+ return syscall3(.setresuid, ruid, euid, suid);
}
}
pub fn setresgid(rgid: u32, egid: u32, sgid: u32) usize {
- if (@hasDecl(@This(), "SYS_setresgid32")) {
- return syscall3(SYS_setresgid32, rgid, egid, sgid);
+ if (@hasField(SYS, "setresgid32")) {
+ return syscall3(.setresgid32, rgid, egid, sgid);
} else {
- return syscall3(SYS_setresgid, rgid, egid, sgid);
+ return syscall3(.setresgid, rgid, egid, sgid);
}
}
pub fn getgroups(size: usize, list: *u32) usize {
- if (@hasDecl(@This(), "SYS_getgroups32")) {
- return syscall2(SYS_getgroups32, size, @ptrToInt(list));
+ if (@hasField(SYS, "getgroups32")) {
+ return syscall2(.getgroups32, size, @ptrToInt(list));
} else {
- return syscall2(SYS_getgroups, size, @ptrToInt(list));
+ return syscall2(.getgroups, size, @ptrToInt(list));
}
}
pub fn setgroups(size: usize, list: *const u32) usize {
- if (@hasDecl(@This(), "SYS_setgroups32")) {
- return syscall2(SYS_setgroups32, size, @ptrToInt(list));
+ if (@hasField(SYS, "setgroups32")) {
+ return syscall2(.setgroups32, size, @ptrToInt(list));
} else {
- return syscall2(SYS_setgroups, size, @ptrToInt(list));
+ return syscall2(.setgroups, size, @ptrToInt(list));
}
}
pub fn getpid() pid_t {
- return @bitCast(pid_t, @truncate(u32, syscall0(SYS_getpid)));
+ return @bitCast(pid_t, @truncate(u32, syscall0(.getpid)));
}
pub fn gettid() pid_t {
- return @bitCast(pid_t, @truncate(u32, syscall0(SYS_gettid)));
+ return @bitCast(pid_t, @truncate(u32, syscall0(.gettid)));
}
pub fn sigprocmask(flags: u32, noalias set: ?*const sigset_t, noalias oldset: ?*sigset_t) usize {
- return syscall4(SYS_rt_sigprocmask, flags, @ptrToInt(set), @ptrToInt(oldset), NSIG / 8);
+ return syscall4(.rt_sigprocmask, flags, @ptrToInt(set), @ptrToInt(oldset), NSIG / 8);
}
pub fn sigaction(sig: u6, noalias act: *const Sigaction, noalias oact: ?*Sigaction) usize {
@@ -792,7 +792,7 @@ pub fn sigaction(sig: u6, noalias act: *const Sigaction, noalias oact: ?*Sigacti
var ksa_old: k_sigaction = undefined;
const ksa_mask_size = @sizeOf(@TypeOf(ksa_old.mask));
@memcpy(@ptrCast([*]u8, &ksa.mask), @ptrCast([*]const u8, &act.mask), ksa_mask_size);
- const result = syscall4(SYS_rt_sigaction, sig, @ptrToInt(&ksa), @ptrToInt(&ksa_old), ksa_mask_size);
+ const result = syscall4(.rt_sigaction, sig, @ptrToInt(&ksa), @ptrToInt(&ksa_old), ksa_mask_size);
const err = getErrno(result);
if (err != 0) {
return result;
@@ -819,42 +819,42 @@ pub fn getsockname(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) us
if (builtin.arch == .i386) {
return socketcall(SC_getsockname, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) });
}
- return syscall3(SYS_getsockname, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len));
+ return syscall3(.getsockname, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len));
}
pub fn getpeername(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize {
if (builtin.arch == .i386) {
return socketcall(SC_getpeername, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) });
}
- return syscall3(SYS_getpeername, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len));
+ return syscall3(.getpeername, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len));
}
pub fn socket(domain: u32, socket_type: u32, protocol: u32) usize {
if (builtin.arch == .i386) {
return socketcall(SC_socket, &[3]usize{ domain, socket_type, protocol });
}
- return syscall3(SYS_socket, domain, socket_type, protocol);
+ return syscall3(.socket, domain, socket_type, protocol);
}
pub fn setsockopt(fd: i32, level: u32, optname: u32, optval: [*]const u8, optlen: socklen_t) usize {
if (builtin.arch == .i386) {
return socketcall(SC_setsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen) });
}
- return syscall5(SYS_setsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen));
+ return syscall5(.setsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen));
}
pub fn getsockopt(fd: i32, level: u32, optname: u32, noalias optval: [*]u8, noalias optlen: *socklen_t) usize {
if (builtin.arch == .i386) {
return socketcall(SC_getsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen) });
}
- return syscall5(SYS_getsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen));
+ return syscall5(.getsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen));
}
pub fn sendmsg(fd: i32, msg: *msghdr_const, flags: u32) usize {
if (builtin.arch == .i386) {
return socketcall(SC_sendmsg, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), flags });
}
- return syscall3(SYS_sendmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), flags);
+ return syscall3(.sendmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), flags);
}
pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize {
@@ -872,7 +872,7 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize
// batch-send all messages up to the current message
if (next_unsent < i) {
const batch_size = i - next_unsent;
- const r = syscall4(SYS_sendmmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(&msgvec[next_unsent]), batch_size, flags);
+ const r = syscall4(.sendmmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(&msgvec[next_unsent]), batch_size, flags);
if (getErrno(r) != 0) return next_unsent;
if (r < batch_size) return next_unsent + r;
}
@@ -888,68 +888,68 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize
}
if (next_unsent < kvlen or next_unsent == 0) { // want to make sure at least one syscall occurs (e.g. to trigger MSG_EOR)
const batch_size = kvlen - next_unsent;
- const r = syscall4(SYS_sendmmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(&msgvec[next_unsent]), batch_size, flags);
+ const r = syscall4(.sendmmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(&msgvec[next_unsent]), batch_size, flags);
if (getErrno(r) != 0) return r;
return next_unsent + r;
}
return kvlen;
}
- return syscall4(SYS_sendmmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msgvec), vlen, flags);
+ return syscall4(.sendmmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msgvec), vlen, flags);
}
pub fn connect(fd: i32, addr: *const c_void, len: socklen_t) usize {
if (builtin.arch == .i386) {
return socketcall(SC_connect, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), len });
}
- return syscall3(SYS_connect, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), len);
+ return syscall3(.connect, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), len);
}
pub fn recvmsg(fd: i32, msg: *msghdr, flags: u32) usize {
if (builtin.arch == .i386) {
return socketcall(SC_recvmsg, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), flags });
}
- return syscall3(SYS_recvmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), flags);
+ return syscall3(.recvmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), flags);
}
pub fn recvfrom(fd: i32, noalias buf: [*]u8, len: usize, flags: u32, noalias addr: ?*sockaddr, noalias alen: ?*socklen_t) usize {
if (builtin.arch == .i386) {
return socketcall(SC_recvfrom, &[6]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @ptrToInt(alen) });
}
- return syscall6(SYS_recvfrom, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @ptrToInt(alen));
+ return syscall6(.recvfrom, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @ptrToInt(alen));
}
pub fn shutdown(fd: i32, how: i32) usize {
if (builtin.arch == .i386) {
return socketcall(SC_shutdown, &[2]usize{ @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, how)) });
}
- return syscall2(SYS_shutdown, @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, how)));
+ return syscall2(.shutdown, @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, how)));
}
pub fn bind(fd: i32, addr: *const sockaddr, len: socklen_t) usize {
if (builtin.arch == .i386) {
return socketcall(SC_bind, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len) });
}
- return syscall3(SYS_bind, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len));
+ return syscall3(.bind, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len));
}
pub fn listen(fd: i32, backlog: u32) usize {
if (builtin.arch == .i386) {
return socketcall(SC_listen, &[2]usize{ @bitCast(usize, @as(isize, fd)), backlog });
}
- return syscall2(SYS_listen, @bitCast(usize, @as(isize, fd)), backlog);
+ return syscall2(.listen, @bitCast(usize, @as(isize, fd)), backlog);
}
pub fn sendto(fd: i32, buf: [*]const u8, len: usize, flags: u32, addr: ?*const sockaddr, alen: socklen_t) usize {
if (builtin.arch == .i386) {
return socketcall(SC_sendto, &[6]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen) });
}
- return syscall6(SYS_sendto, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen));
+ return syscall6(.sendto, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen));
}
pub fn sendfile(outfd: i32, infd: i32, offset: ?*i64, count: usize) usize {
- if (@hasDecl(@This(), "SYS_sendfile64")) {
+ if (@hasField(SYS, "sendfile64")) {
return syscall4(
- SYS_sendfile64,
+ .sendfile64,
@bitCast(usize, @as(isize, outfd)),
@bitCast(usize, @as(isize, infd)),
@ptrToInt(offset),
@@ -957,7 +957,7 @@ pub fn sendfile(outfd: i32, infd: i32, offset: ?*i64, count: usize) usize {
);
} else {
return syscall4(
- SYS_sendfile,
+ .sendfile,
@bitCast(usize, @as(isize, outfd)),
@bitCast(usize, @as(isize, infd)),
@ptrToInt(offset),
@@ -970,7 +970,7 @@ pub fn socketpair(domain: i32, socket_type: i32, protocol: i32, fd: [2]i32) usiz
if (builtin.arch == .i386) {
return socketcall(SC_socketpair, &[4]usize{ @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(&fd[0]) });
}
- return syscall4(SYS_socketpair, @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(&fd[0]));
+ return syscall4(.socketpair, @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(&fd[0]));
}
pub fn accept(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize {
@@ -984,45 +984,45 @@ pub fn accept4(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t, flags:
if (builtin.arch == .i386) {
return socketcall(SC_accept4, &[4]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags });
}
- return syscall4(SYS_accept4, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags);
+ return syscall4(.accept4, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags);
}
pub fn fstat(fd: i32, stat_buf: *Stat) usize {
- if (@hasDecl(@This(), "SYS_fstat64")) {
- return syscall2(SYS_fstat64, @bitCast(usize, @as(isize, fd)), @ptrToInt(stat_buf));
+ if (@hasField(SYS, "fstat64")) {
+ return syscall2(.fstat64, @bitCast(usize, @as(isize, fd)), @ptrToInt(stat_buf));
} else {
- return syscall2(SYS_fstat, @bitCast(usize, @as(isize, fd)), @ptrToInt(stat_buf));
+ return syscall2(.fstat, @bitCast(usize, @as(isize, fd)), @ptrToInt(stat_buf));
}
}
pub fn stat(pathname: [*:0]const u8, statbuf: *Stat) usize {
- if (@hasDecl(@This(), "SYS_stat64")) {
- return syscall2(SYS_stat64, @ptrToInt(pathname), @ptrToInt(statbuf));
+ if (@hasField(SYS, "stat64")) {
+ return syscall2(.stat64, @ptrToInt(pathname), @ptrToInt(statbuf));
} else {
- return syscall2(SYS_stat, @ptrToInt(pathname), @ptrToInt(statbuf));
+ return syscall2(.stat, @ptrToInt(pathname), @ptrToInt(statbuf));
}
}
pub fn lstat(pathname: [*:0]const u8, statbuf: *Stat) usize {
- if (@hasDecl(@This(), "SYS_lstat64")) {
- return syscall2(SYS_lstat64, @ptrToInt(pathname), @ptrToInt(statbuf));
+ if (@hasField(SYS, "lstat64")) {
+ return syscall2(.lstat64, @ptrToInt(pathname), @ptrToInt(statbuf));
} else {
- return syscall2(SYS_lstat, @ptrToInt(pathname), @ptrToInt(statbuf));
+ return syscall2(.lstat, @ptrToInt(pathname), @ptrToInt(statbuf));
}
}
pub fn fstatat(dirfd: i32, path: [*:0]const u8, stat_buf: *Stat, flags: u32) usize {
- if (@hasDecl(@This(), "SYS_fstatat64")) {
- return syscall4(SYS_fstatat64, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags);
+ if (@hasField(SYS, "fstatat64")) {
+ return syscall4(.fstatat64, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags);
} else {
- return syscall4(SYS_fstatat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags);
+ return syscall4(.fstatat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags);
}
}
pub fn statx(dirfd: i32, path: [*]const u8, flags: u32, mask: u32, statx_buf: *Statx) usize {
- if (@hasDecl(@This(), "SYS_statx")) {
+ if (@hasField(SYS, "statx")) {
return syscall5(
- SYS_statx,
+ .statx,
@bitCast(usize, @as(isize, dirfd)),
@ptrToInt(path),
flags,
@@ -1034,59 +1034,59 @@ pub fn statx(dirfd: i32, path: [*]const u8, flags: u32, mask: u32, statx_buf: *S
}
pub fn listxattr(path: [*:0]const u8, list: [*]u8, size: usize) usize {
- return syscall3(SYS_listxattr, @ptrToInt(path), @ptrToInt(list), size);
+ return syscall3(.listxattr, @ptrToInt(path), @ptrToInt(list), size);
}
pub fn llistxattr(path: [*:0]const u8, list: [*]u8, size: usize) usize {
- return syscall3(SYS_llistxattr, @ptrToInt(path), @ptrToInt(list), size);
+ return syscall3(.llistxattr, @ptrToInt(path), @ptrToInt(list), size);
}
pub fn flistxattr(fd: usize, list: [*]u8, size: usize) usize {
- return syscall3(SYS_flistxattr, fd, @ptrToInt(list), size);
+ return syscall3(.flistxattr, fd, @ptrToInt(list), size);
}
pub fn getxattr(path: [*:0]const u8, name: [*:0]const u8, value: [*]u8, size: usize) usize {
- return syscall4(SYS_getxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size);
+ return syscall4(.getxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size);
}
pub fn lgetxattr(path: [*:0]const u8, name: [*:0]const u8, value: [*]u8, size: usize) usize {
- return syscall4(SYS_lgetxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size);
+ return syscall4(.lgetxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size);
}
pub fn fgetxattr(fd: usize, name: [*:0]const u8, value: [*]u8, size: usize) usize {
- return syscall4(SYS_lgetxattr, fd, @ptrToInt(name), @ptrToInt(value), size);
+ return syscall4(.lgetxattr, fd, @ptrToInt(name), @ptrToInt(value), size);
}
pub fn setxattr(path: [*:0]const u8, name: [*:0]const u8, value: *const void, size: usize, flags: usize) usize {
- return syscall5(SYS_setxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size, flags);
+ return syscall5(.setxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size, flags);
}
pub fn lsetxattr(path: [*:0]const u8, name: [*:0]const u8, value: *const void, size: usize, flags: usize) usize {
- return syscall5(SYS_lsetxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size, flags);
+ return syscall5(.lsetxattr, @ptrToInt(path), @ptrToInt(name), @ptrToInt(value), size, flags);
}
pub fn fsetxattr(fd: usize, name: [*:0]const u8, value: *const void, size: usize, flags: usize) usize {
- return syscall5(SYS_fsetxattr, fd, @ptrToInt(name), @ptrToInt(value), size, flags);
+ return syscall5(.fsetxattr, fd, @ptrToInt(name), @ptrToInt(value), size, flags);
}
pub fn removexattr(path: [*:0]const u8, name: [*:0]const u8) usize {
- return syscall2(SYS_removexattr, @ptrToInt(path), @ptrToInt(name));
+ return syscall2(.removexattr, @ptrToInt(path), @ptrToInt(name));
}
pub fn lremovexattr(path: [*:0]const u8, name: [*:0]const u8) usize {
- return syscall2(SYS_lremovexattr, @ptrToInt(path), @ptrToInt(name));
+ return syscall2(.lremovexattr, @ptrToInt(path), @ptrToInt(name));
}
pub fn fremovexattr(fd: usize, name: [*:0]const u8) usize {
- return syscall2(SYS_fremovexattr, fd, @ptrToInt(name));
+ return syscall2(.fremovexattr, fd, @ptrToInt(name));
}
pub fn sched_yield() usize {
- return syscall0(SYS_sched_yield);
+ return syscall0(.sched_yield);
}
pub fn sched_getaffinity(pid: pid_t, size: usize, set: *cpu_set_t) usize {
- const rc = syscall3(SYS_sched_getaffinity, @bitCast(usize, @as(isize, pid)), size, @ptrToInt(set));
+ const rc = syscall3(.sched_getaffinity, @bitCast(usize, @as(isize, pid)), size, @ptrToInt(set));
if (@bitCast(isize, rc) < 0) return rc;
if (rc < size) @memset(@ptrCast([*]u8, set) + rc, 0, size - rc);
return 0;
@@ -1097,11 +1097,11 @@ pub fn epoll_create() usize {
}
pub fn epoll_create1(flags: usize) usize {
- return syscall1(SYS_epoll_create1, flags);
+ return syscall1(.epoll_create1, flags);
}
pub fn epoll_ctl(epoll_fd: i32, op: u32, fd: i32, ev: ?*epoll_event) usize {
- return syscall4(SYS_epoll_ctl, @bitCast(usize, @as(isize, epoll_fd)), @intCast(usize, op), @bitCast(usize, @as(isize, fd)), @ptrToInt(ev));
+ return syscall4(.epoll_ctl, @bitCast(usize, @as(isize, epoll_fd)), @intCast(usize, op), @bitCast(usize, @as(isize, fd)), @ptrToInt(ev));
}
pub fn epoll_wait(epoll_fd: i32, events: [*]epoll_event, maxevents: u32, timeout: i32) usize {
@@ -1110,7 +1110,7 @@ pub fn epoll_wait(epoll_fd: i32, events: [*]epoll_event, maxevents: u32, timeout
pub fn epoll_pwait(epoll_fd: i32, events: [*]epoll_event, maxevents: u32, timeout: i32, sigmask: ?*sigset_t) usize {
return syscall6(
- SYS_epoll_pwait,
+ .epoll_pwait,
@bitCast(usize, @as(isize, epoll_fd)),
@ptrToInt(events),
@intCast(usize, maxevents),
@@ -1121,11 +1121,11 @@ pub fn epoll_pwait(epoll_fd: i32, events: [*]epoll_event, maxevents: u32, timeou
}
pub fn eventfd(count: u32, flags: u32) usize {
- return syscall2(SYS_eventfd2, count, flags);
+ return syscall2(.eventfd2, count, flags);
}
pub fn timerfd_create(clockid: i32, flags: u32) usize {
- return syscall2(SYS_timerfd_create, @bitCast(usize, @as(isize, clockid)), flags);
+ return syscall2(.timerfd_create, @bitCast(usize, @as(isize, clockid)), flags);
}
pub const itimerspec = extern struct {
@@ -1134,59 +1134,59 @@ pub const itimerspec = extern struct {
};
pub fn timerfd_gettime(fd: i32, curr_value: *itimerspec) usize {
- return syscall2(SYS_timerfd_gettime, @bitCast(usize, @as(isize, fd)), @ptrToInt(curr_value));
+ return syscall2(.timerfd_gettime, @bitCast(usize, @as(isize, fd)), @ptrToInt(curr_value));
}
pub fn timerfd_settime(fd: i32, flags: u32, new_value: *const itimerspec, old_value: ?*itimerspec) usize {
- return syscall4(SYS_timerfd_settime, @bitCast(usize, @as(isize, fd)), flags, @ptrToInt(new_value), @ptrToInt(old_value));
+ return syscall4(.timerfd_settime, @bitCast(usize, @as(isize, fd)), flags, @ptrToInt(new_value), @ptrToInt(old_value));
}
pub fn unshare(flags: usize) usize {
- return syscall1(SYS_unshare, flags);
+ return syscall1(.unshare, flags);
}
pub fn capget(hdrp: *cap_user_header_t, datap: *cap_user_data_t) usize {
- return syscall2(SYS_capget, @ptrToInt(hdrp), @ptrToInt(datap));
+ return syscall2(.capget, @ptrToInt(hdrp), @ptrToInt(datap));
}
pub fn capset(hdrp: *cap_user_header_t, datap: *const cap_user_data_t) usize {
- return syscall2(SYS_capset, @ptrToInt(hdrp), @ptrToInt(datap));
+ return syscall2(.capset, @ptrToInt(hdrp), @ptrToInt(datap));
}
pub fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) usize {
- return syscall2(SYS_sigaltstack, @ptrToInt(ss), @ptrToInt(old_ss));
+ return syscall2(.sigaltstack, @ptrToInt(ss), @ptrToInt(old_ss));
}
pub fn uname(uts: *utsname) usize {
- return syscall1(SYS_uname, @ptrToInt(uts));
+ return syscall1(.uname, @ptrToInt(uts));
}
pub fn io_uring_setup(entries: u32, p: *io_uring_params) usize {
- return syscall2(SYS_io_uring_setup, entries, @ptrToInt(p));
+ return syscall2(.io_uring_setup, entries, @ptrToInt(p));
}
pub fn io_uring_enter(fd: i32, to_submit: u32, min_complete: u32, flags: u32, sig: ?*sigset_t) usize {
- return syscall6(SYS_io_uring_enter, @bitCast(usize, @as(isize, fd)), to_submit, min_complete, flags, @ptrToInt(sig), NSIG / 8);
+ return syscall6(.io_uring_enter, @bitCast(usize, @as(isize, fd)), to_submit, min_complete, flags, @ptrToInt(sig), NSIG / 8);
}
pub fn io_uring_register(fd: i32, opcode: IORING_REGISTER, arg: ?*const c_void, nr_args: u32) usize {
- return syscall4(SYS_io_uring_register, @bitCast(usize, @as(isize, fd)), @enumToInt(opcode), @ptrToInt(arg), nr_args);
+ return syscall4(.io_uring_register, @bitCast(usize, @as(isize, fd)), @enumToInt(opcode), @ptrToInt(arg), nr_args);
}
pub fn memfd_create(name: [*:0]const u8, flags: u32) usize {
- return syscall2(SYS_memfd_create, @ptrToInt(name), flags);
+ return syscall2(.memfd_create, @ptrToInt(name), flags);
}
pub fn getrusage(who: i32, usage: *rusage) usize {
- return syscall2(SYS_getrusage, @bitCast(usize, @as(isize, who)), @ptrToInt(usage));
+ return syscall2(.getrusage, @bitCast(usize, @as(isize, who)), @ptrToInt(usage));
}
pub fn tcgetattr(fd: fd_t, termios_p: *termios) usize {
- return syscall3(SYS_ioctl, @bitCast(usize, @as(isize, fd)), TCGETS, @ptrToInt(termios_p));
+ return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), TCGETS, @ptrToInt(termios_p));
}
pub fn tcsetattr(fd: fd_t, optional_action: TCSA, termios_p: *const termios) usize {
- return syscall3(SYS_ioctl, @bitCast(usize, @as(isize, fd)), TCSETS + @enumToInt(optional_action), @ptrToInt(termios_p));
+ return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), TCSETS + @enumToInt(optional_action), @ptrToInt(termios_p));
}
test "" {