authorgravatar for i@mgxm.meMarcio Giaxa <i@mgxm.me> 2018-12-23 23:30:31-02:00
committergravatar for i@mgxm.meMarcio Giaxa <i@mgxm.me> 2018-12-23 23:30:31-02:00
log682815f6e9df8fa7ec25f0b327b4eab7c3d52f2a
tree444249d1aeab4e2aaceef47d7d8eb1210181eabd
parent773bf8013391d2b309cfcb50bf9e1c7db25cc3f2
signature Commit is signed but in an unrecognized format.

freebsd: remove syscall and use libc

Use libc interface for: - getdents - kill - openat - setgid - setuid

2 files changed, 10 insertions(+), 5 deletions(-)

std/c/freebsd.zig+5
......@@ -14,9 +14,14 @@ pub extern "c" fn sysctl(name: [*]c_int, namelen: c_uint, oldp: ?*c_void, oldlen
1414pub extern "c" fn sysctlbyname(name: [*]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
1515pub extern "c" fn sysctlnametomib(name: [*]const u8, mibp: ?*c_int, sizep: ?*usize) c_int;
1616pub extern "c" fn getdirentries(fd: c_int, buf_ptr: [*]u8, nbytes: usize, basep: *i64) usize;
17pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize;
1718pub extern "c" fn pipe2(arg0: *[2]c_int, arg1: u32) c_int;
1819pub extern "c" fn preadv(fd: c_int, iov: *const c_void, iovcnt: c_int, offset: usize) isize;
1920pub extern "c" fn pwritev(fd: c_int, iov: *const c_void, iovcnt: c_int, offset: usize) isize;
21pub extern "c" fn openat(fd: c_int, path: ?[*]const u8, flags: c_int) c_int;
22pub extern "c" fn setgid(ruid: c_uint, euid: c_uint) c_int;
23pub extern "c" fn setuid(uid: c_uint) c_int;
24pub extern "c" fn kill(pid: c_int, sig: c_int) c_int;
2025
2126/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
2227pub const Kevent = extern struct {
std/os/freebsd/index.zig+5-5
......@@ -573,7 +573,7 @@ pub fn getcwd(buf: [*]u8, size: usize) usize {
573573}
574574
575575pub fn getdents(fd: i32, dirp: [*]u8, count: usize) usize {
576 return arch.syscall3(SYS_getdents, @bitCast(usize, isize(fd)), @ptrToInt(dirp), count);
576 return errnoWrap(@bitCast(isize, c.getdents(fd, drip, count)));
577577}
578578
579579pub 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 {
667667}
668668
669669pub fn openat(dirfd: i32, path: [*]const u8, flags: usize, mode: usize) usize {
670 return arch.syscall4(SYS_openat, @bitCast(usize, isize(dirfd)), @ptrToInt(path), flags, mode);
670 return errnoWrap(c.openat(@bitCast(usize, isize(dirfd)), @ptrToInt(path), flags, mode));
671671}
672672
673673pub fn close(fd: i32) usize {
......@@ -683,7 +683,7 @@ pub fn exit(code: i32) noreturn {
683683}
684684
685685pub fn kill(pid: i32, sig: i32) usize {
686 return arch.syscall2(SYS_kill, @bitCast(usize, isize(pid)), @bitCast(usize, isize(sig)));
686 return errnoWrap(c.kill(pid, sig));
687687}
688688
689689pub fn unlink(path: [*]const u8) usize {
......@@ -700,11 +700,11 @@ pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize {
700700}
701701
702702pub fn setuid(uid: u32) usize {
703 return arch.syscall1(SYS_setuid, uid);
703 return errnoWrap(c.setuid(uid));
704704}
705705
706706pub fn setgid(gid: u32) usize {
707 return arch.syscall1(SYS_setgid, gid);
707 return errnoWrap(c.setgid(gid));
708708}
709709
710710pub fn setreuid(ruid: u32, euid: u32) usize {