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
signaturelock-open 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...@@ -14,9 +14,14 @@ pub extern "c" fn sysctl(name: [*]c_int, namelen: c_uint, oldp: ?*c_void, oldlen
14pub extern "c" fn sysctlbyname(name: [*]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;14pub extern "c" fn sysctlbyname(name: [*]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
15pub extern "c" fn sysctlnametomib(name: [*]const u8, mibp: ?*c_int, sizep: ?*usize) c_int;15pub extern "c" fn sysctlnametomib(name: [*]const u8, mibp: ?*c_int, sizep: ?*usize) c_int;
16pub extern "c" fn getdirentries(fd: c_int, buf_ptr: [*]u8, nbytes: usize, basep: *i64) usize;16pub 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;
17pub extern "c" fn pipe2(arg0: *[2]c_int, arg1: u32) c_int;18pub extern "c" fn pipe2(arg0: *[2]c_int, arg1: u32) c_int;
18pub extern "c" fn preadv(fd: c_int, iov: *const c_void, iovcnt: c_int, offset: usize) isize;19pub extern "c" fn preadv(fd: c_int, iov: *const c_void, iovcnt: c_int, offset: usize) isize;
19pub extern "c" fn pwritev(fd: c_int, iov: *const c_void, iovcnt: c_int, offset: usize) isize;20pub 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
21/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.26/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
22pub const Kevent = extern struct {27pub const Kevent = extern struct {
std/os/freebsd/index.zig+5-5
...@@ -573,7 +573,7 @@ pub fn getcwd(buf: [*]u8, size: usize) usize {...@@ -573,7 +573,7 @@ pub fn getcwd(buf: [*]u8, size: usize) usize {
573}573}
574574
575pub fn getdents(fd: i32, dirp: [*]u8, count: usize) usize {575pub 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)));
577}577}
578578
579pub fn getdirentries(fd: i32, buf_ptr: [*]u8, buf_len: usize, basep: *i64) usize {579pub 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 {...@@ -667,7 +667,7 @@ pub fn create(path: [*]const u8, perm: usize) usize {
667}667}
668668
669pub fn openat(dirfd: i32, path: [*]const u8, flags: usize, mode: usize) usize {669pub 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));
671}671}
672672
673pub fn close(fd: i32) usize {673pub fn close(fd: i32) usize {
...@@ -683,7 +683,7 @@ pub fn exit(code: i32) noreturn {...@@ -683,7 +683,7 @@ pub fn exit(code: i32) noreturn {
683}683}
684684
685pub fn kill(pid: i32, sig: i32) usize {685pub 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));
687}687}
688688
689pub fn unlink(path: [*]const u8) usize {689pub fn unlink(path: [*]const u8) usize {
...@@ -700,11 +700,11 @@ pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize {...@@ -700,11 +700,11 @@ pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize {
700}700}
701701
702pub fn setuid(uid: u32) usize {702pub fn setuid(uid: u32) usize {
703 return arch.syscall1(SYS_setuid, uid);703 return errnoWrap(c.setuid(uid));
704}704}
705705
706pub fn setgid(gid: u32) usize {706pub fn setgid(gid: u32) usize {
707 return arch.syscall1(SYS_setgid, gid);707 return errnoWrap(c.setgid(gid));
708}708}
709709
710pub fn setreuid(ruid: u32, euid: u32) usize {710pub fn setreuid(ruid: u32, euid: u32) usize {