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...@@ -15,6 +15,8 @@ pub extern "c" fn sysctlbyname(name: [*]const u8, oldp: ?*c_void, oldlenp: ?*usi
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 pipe2(arg0: *[2]c_int, arg1: u32) c_int;17pub 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
19/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.21/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
20pub const Kevent = extern struct {22pub const Kevent = extern struct {
...@@ -50,18 +52,23 @@ pub const Stat = extern struct {...@@ -50,18 +52,23 @@ pub const Stat = extern struct {
50 nlink: usize,52 nlink: usize,
5153
52 mode: u32,54 mode: u32,
55 __pad0: u16,
53 uid: u32,56 uid: u32,
54 gid: u32,57 gid: u32,
55 __pad0: u32,58 __pad1: u32,
56 rdev: u64,59 rdev: u64,
57 size: i64,
58 blksize: isize,
59 blocks: i64,
6060
61 atim: timespec,61 atim: timespec,
62 mtim: timespec,62 mtim: timespec,
63 ctim: timespec,63 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,
65};72};
6673
67pub const timespec = extern struct {74pub const timespec = extern struct {
...@@ -72,7 +79,7 @@ pub const timespec = extern struct {...@@ -72,7 +79,7 @@ pub const timespec = extern struct {
72pub const dirent = extern struct {79pub const dirent = extern struct {
73 d_fileno: usize,80 d_fileno: usize,
74 d_off: i64,81 d_off: i64,
75 d_reclen: u64,82 d_reclen: u16,
76 d_type: u8,83 d_type: u8,
77 d_pad0: u8,84 d_pad0: u8,
78 d_namlen: u16,85 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 {...@@ -626,7 +626,7 @@ pub fn pread(fd: i32, buf: [*]u8, nbyte: usize, offset: u64) usize {
626}626}
627627
628pub fn preadv(fd: i32, iov: [*]const iovec, count: usize, offset: usize) usize {628pub 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));
630}630}
631631
632pub fn pipe(fd: *[2]i32) usize {632pub fn pipe(fd: *[2]i32) usize {
...@@ -647,7 +647,7 @@ pub fn pwrite(fd: i32, buf: [*]const u8, nbyte: usize, offset: u64) usize {...@@ -647,7 +647,7 @@ pub fn pwrite(fd: i32, buf: [*]const u8, nbyte: usize, offset: u64) usize {
647}647}
648648
649pub fn pwritev(fd: i32, iov: [*]const iovec_const, count: usize, offset: usize) usize {649pub 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));
651}651}
652652
653pub fn rename(old: [*]const u8, new: [*]const u8) usize {653pub fn rename(old: [*]const u8, new: [*]const u8) usize {