From 682815f6e9df8fa7ec25f0b327b4eab7c3d52f2a Mon Sep 17 00:00:00 2001 From: Marcio Giaxa Date: Sun, 23 Dec 2018 23:30:31 -0200 Subject: freebsd: remove syscall and use libc Use libc interface for: - getdents - kill - openat - setgid - setuid --- std/c/freebsd.zig | 5 +++++ std/os/freebsd/index.zig | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'std') diff --git a/std/c/freebsd.zig b/std/c/freebsd.zig index 9aa1859988..eae5516db3 100644 --- a/std/c/freebsd.zig +++ b/std/c/freebsd.zig @@ -14,9 +14,14 @@ pub extern "c" fn sysctl(name: [*]c_int, namelen: c_uint, oldp: ?*c_void, oldlen pub extern "c" fn sysctlbyname(name: [*]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int; pub extern "c" fn sysctlnametomib(name: [*]const u8, mibp: ?*c_int, sizep: ?*usize) c_int; pub extern "c" fn getdirentries(fd: c_int, buf_ptr: [*]u8, nbytes: usize, basep: *i64) usize; +pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize; pub extern "c" fn pipe2(arg0: *[2]c_int, arg1: u32) c_int; pub extern "c" fn preadv(fd: c_int, iov: *const c_void, iovcnt: c_int, offset: usize) isize; pub extern "c" fn pwritev(fd: c_int, iov: *const c_void, iovcnt: c_int, offset: usize) isize; +pub extern "c" fn openat(fd: c_int, path: ?[*]const u8, flags: c_int) c_int; +pub extern "c" fn setgid(ruid: c_uint, euid: c_uint) c_int; +pub extern "c" fn setuid(uid: c_uint) c_int; +pub extern "c" fn kill(pid: c_int, sig: c_int) c_int; /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. pub const Kevent = extern struct { diff --git a/std/os/freebsd/index.zig b/std/os/freebsd/index.zig index f1533ec098..ebea64fdf6 100644 --- a/std/os/freebsd/index.zig +++ b/std/os/freebsd/index.zig @@ -573,7 +573,7 @@ pub fn getcwd(buf: [*]u8, size: usize) usize { } pub fn getdents(fd: i32, dirp: [*]u8, count: usize) usize { - return arch.syscall3(SYS_getdents, @bitCast(usize, isize(fd)), @ptrToInt(dirp), count); + return errnoWrap(@bitCast(isize, c.getdents(fd, drip, count))); } pub fn getdirentries(fd: i32, buf_ptr: [*]u8, buf_len: usize, basep: *i64) usize { @@ -667,7 +667,7 @@ pub fn create(path: [*]const u8, perm: usize) usize { } pub fn openat(dirfd: i32, path: [*]const u8, flags: usize, mode: usize) usize { - return arch.syscall4(SYS_openat, @bitCast(usize, isize(dirfd)), @ptrToInt(path), flags, mode); + return errnoWrap(c.openat(@bitCast(usize, isize(dirfd)), @ptrToInt(path), flags, mode)); } pub fn close(fd: i32) usize { @@ -683,7 +683,7 @@ pub fn exit(code: i32) noreturn { } pub fn kill(pid: i32, sig: i32) usize { - return arch.syscall2(SYS_kill, @bitCast(usize, isize(pid)), @bitCast(usize, isize(sig))); + return errnoWrap(c.kill(pid, sig)); } pub fn unlink(path: [*]const u8) usize { @@ -700,11 +700,11 @@ pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize { } pub fn setuid(uid: u32) usize { - return arch.syscall1(SYS_setuid, uid); + return errnoWrap(c.setuid(uid)); } pub fn setgid(gid: u32) usize { - return arch.syscall1(SYS_setgid, gid); + return errnoWrap(c.setgid(gid)); } pub fn setreuid(ruid: u32, euid: u32) usize { -- cgit v1.2.3