authorgravatar for i@mgxm.meMarcio <i@mgxm.me> 2018-12-20 22:55:14+00:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2018-12-20 22:55:14+00:00
logac1b2a3c7319b099211acdca91c644a8533d0970
treeb2e4f137b03592c11e7d3a81f351607d54b2ae80
parente5b4748101ca40f5dc4082ce2cb46df0c8607417
parent76efc462e7ea90be02fd28254f8c452ba994ea8a
signature Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #1 from myfreeweb/fbsd2

Fix dirent/stat, add preadv

2 files changed, 15 insertions(+), 8 deletions(-)

std/c/freebsd.zig+13-6
......@@ -15,6 +15,8 @@ pub extern "c" fn sysctlbyname(name: [*]const u8, oldp: ?*c_void, oldlenp: ?*usi
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;
1717pub 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 pwritev(fd: c_int, iov: *const c_void, iovcnt: c_int, offset: usize) isize;
1820
1921/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
2022pub const Kevent = extern struct {
......@@ -50,18 +52,23 @@ pub const Stat = extern struct {
5052 nlink: usize,
5153
5254 mode: u32,
55 __pad0: u16,
5356 uid: u32,
5457 gid: u32,
55 __pad0: u32,
58 __pad1: u32,
5659 rdev: u64,
57 size: i64,
58 blksize: isize,
59 blocks: i64,
6060
6161 atim: timespec,
6262 mtim: timespec,
6363 ctim: timespec,
64 __unused: [3]isize,
64 birthtim: timespec,
65
66 size: i64,
67 blocks: i64,
68 blksize: isize,
69 flags: u32,
70 gen: u64,
71 __spare: [10]u64,
6572};
6673
6774pub const timespec = extern struct {
......@@ -72,7 +79,7 @@ pub const timespec = extern struct {
7279pub const dirent = extern struct {
7380 d_fileno: usize,
7481 d_off: i64,
75 d_reclen: u64,
82 d_reclen: u16,
7683 d_type: u8,
7784 d_pad0: u8,
7885 d_namlen: u16,
std/os/freebsd/index.zig+2-2
......@@ -626,7 +626,7 @@ pub fn pread(fd: i32, buf: [*]u8, nbyte: usize, offset: u64) usize {
626626}
627627
628628pub fn preadv(fd: i32, iov: [*]const iovec, count: usize, offset: usize) usize {
629 return arch.syscall4(SYS_preadv, @bitCast(usize, isize(fd)), @ptrToInt(iov), count, offset);
629 return errnoWrap(c.preadv(fd, @ptrCast(*const c_void, iov), @intCast(c_int, count), offset));
630630}
631631
632632pub fn pipe(fd: *[2]i32) usize {
......@@ -647,7 +647,7 @@ pub fn pwrite(fd: i32, buf: [*]const u8, nbyte: usize, offset: u64) usize {
647647}
648648
649649pub fn pwritev(fd: i32, iov: [*]const iovec_const, count: usize, offset: usize) usize {
650 return arch.syscall4(SYS_pwritev, @bitCast(usize, isize(fd)), @ptrToInt(iov), count, offset);
650 return errnoWrap(c.pwritev(fd, @ptrCast(*const c_void, iov), @intCast(c_int, count), offset));
651651}
652652
653653pub fn rename(old: [*]const u8, new: [*]const u8) usize {