authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-05-30 15:48:22-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2019-05-30 15:48:22-04:00
log0ccd91faea5ec27a1dce9d3bae84e1feca7fc0ea
tree6aa7ef4a698b9ed7d634e88cf4e1a3a29dfdc082
parent78f32259daa79aaced1c49bcdace936121a2ccc5
parent51fc375b0d17f50bb6e0a542e9eebfff1534c581
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #2593 from LemonBoy/aarch64-stuff

Fix some syscalls on arm64

6 files changed, 41 insertions(+), 33 deletions(-)

std/c/linux.zig+1-1
......@@ -7,7 +7,7 @@ pub const _errno = __errno_location;
77pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) c_int;
88pub extern "c" fn sched_getaffinity(pid: c_int, size: usize, set: *cpu_set_t) c_int;
99pub extern "c" fn eventfd(initval: c_uint, flags: c_uint) c_int;
10pub extern "c" fn epoll_ctl(epfd: fd_t, op: c_uint, fd: fd_t, event: *epoll_event) c_int;
10pub extern "c" fn epoll_ctl(epfd: fd_t, op: c_uint, fd: fd_t, event: ?*epoll_event) c_int;
1111pub extern "c" fn epoll_create1(flags: c_uint) c_int;
1212pub extern "c" fn epoll_wait(epfd: fd_t, events: [*]epoll_event, maxevents: c_uint, timeout: c_int) c_int;
1313pub extern "c" fn epoll_pwait(
std/event/loop.zig+1-1
......@@ -421,7 +421,7 @@ pub const Loop = struct {
421421 }
422422
423423 pub fn linuxRemoveFd(self: *Loop, fd: i32) void {
424 os.epoll_ctl(self.os_data.epollfd, os.linux.EPOLL_CTL_DEL, fd, undefined) catch {};
424 os.epoll_ctl(self.os_data.epollfd, os.linux.EPOLL_CTL_DEL, fd, null) catch {};
425425 self.finishOneEvent();
426426 }
427427
std/os.zig+1-1
......@@ -1509,7 +1509,7 @@ pub const EpollCtlError = error{
15091509 Unexpected,
15101510};
15111511
1512pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: *epoll_event) EpollCtlError!void {
1512pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: ?*epoll_event) EpollCtlError!void {
15131513 const rc = system.epoll_ctl(epfd, op, fd, event);
15141514 switch (errno(rc)) {
15151515 0 => return,
std/os/bits/linux.zig+6-6
......@@ -762,16 +762,16 @@ pub const epoll_data = extern union {
762762
763763// On x86_64 the structure is packed so that it matches the definition of its
764764// 32bit counterpart
765pub const epoll_event = if (builtin.arch != .x86_64)
766 extern struct {
765pub const epoll_event = switch (builtin.arch) {
766 .x86_64 => packed struct {
767767 events: u32,
768768 data: epoll_data,
769 }
770else
771 packed struct {
769 },
770 else => extern struct {
772771 events: u32,
773772 data: epoll_data,
774 };
773 },
774};
775775
776776pub const _LINUX_CAPABILITY_VERSION_1 = 0x19980330;
777777pub const _LINUX_CAPABILITY_U32S_1 = 1;
std/os/bits/linux/arm64.zig+5-5
......@@ -299,16 +299,16 @@ pub const O_NONBLOCK = 0o4000;
299299pub const O_DSYNC = 0o10000;
300300pub const O_SYNC = 0o4010000;
301301pub const O_RSYNC = 0o4010000;
302pub const O_DIRECTORY = 0o200000;
303pub const O_NOFOLLOW = 0o400000;
302pub const O_DIRECTORY = 0o40000;
303pub const O_NOFOLLOW = 0o100000;
304304pub const O_CLOEXEC = 0o2000000;
305305
306306pub const O_ASYNC = 0o20000;
307pub const O_DIRECT = 0o40000;
308pub const O_LARGEFILE = 0;
307pub const O_DIRECT = 0o200000;
308pub const O_LARGEFILE = 0o400000;
309309pub const O_NOATIME = 0o1000000;
310310pub const O_PATH = 0o10000000;
311pub const O_TMPFILE = 0o20200000;
311pub const O_TMPFILE = 0o20040000;
312312pub const O_NDELAY = O_NONBLOCK;
313313
314314pub const F_DUPFD = 0;
std/os/linux.zig+27-19
......@@ -131,7 +131,7 @@ pub fn readlink(noalias path: [*]const u8, noalias buf_ptr: [*]u8, buf_len: usiz
131131 if (@hasDecl(@This(), "SYS_readlink")) {
132132 return syscall3(SYS_readlink, @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
133133 } else {
134 return syscall4(SYS_readlinkat, AT_FDCWD, @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
134 return syscall4(SYS_readlinkat, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(path), @ptrToInt(buf_ptr), buf_len);
135135 }
136136}
137137
......@@ -145,7 +145,7 @@ pub fn mkdir(path: [*]const u8, mode: u32) usize {
145145 if (@hasDecl(@This(), "SYS_mkdir")) {
146146 return syscall2(SYS_mkdir, @ptrToInt(path), mode);
147147 } else {
148 return syscall3(SYS_mkdirat, AT_FDCWD, @ptrToInt(path), mode);
148 return syscall3(SYS_mkdirat, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(path), mode);
149149 }
150150}
151151
......@@ -206,7 +206,7 @@ pub fn rmdir(path: [*]const u8) usize {
206206 if (@hasDecl(@This(), "SYS_rmdir")) {
207207 return syscall1(SYS_rmdir, @ptrToInt(path));
208208 } else {
209 return syscall3(SYS_unlinkat, AT_FDCWD, @ptrToInt(path), AT_REMOVEDIR);
209 return syscall3(SYS_unlinkat, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(path), AT_REMOVEDIR);
210210 }
211211}
212212
......@@ -215,7 +215,7 @@ pub fn symlink(existing: [*]const u8, new: [*]const u8) usize {
215215 if (@hasDecl(@This(), "SYS_symlink")) {
216216 return syscall2(SYS_symlink, @ptrToInt(existing), @ptrToInt(new));
217217 } else {
218 return syscall3(SYS_symlinkat, @ptrToInt(existing), AT_FDCWD, @ptrToInt(new));
218 return syscall3(SYS_symlinkat, @ptrToInt(existing), @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(new));
219219 }
220220}
221221
......@@ -231,12 +231,16 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: usize) usize {
231231
232232// TODO https://github.com/ziglang/zig/issues/265
233233pub fn access(path: [*]const u8, mode: u32) usize {
234 return syscall2(SYS_access, @ptrToInt(path), mode);
234 if (@hasDecl(@This(), "SYS_access")) {
235 return syscall2(SYS_access, @ptrToInt(path), mode);
236 } else {
237 return syscall4(SYS_faccessat, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(path), mode, 0);
238 }
235239}
236240
237241// TODO https://github.com/ziglang/zig/issues/265
238pub fn faccessat(dirfd: i32, path: [*]const u8, mode: u32) usize {
239 return syscall3(SYS_faccessat, @bitCast(usize, isize(dirfd)), @ptrToInt(path), mode);
242pub fn faccessat(dirfd: i32, path: [*]const u8, mode: u32, flags: u32) usize {
243 return syscall4(SYS_faccessat, @bitCast(usize, isize(dirfd)), @ptrToInt(path), mode, flags);
240244}
241245
242246pub fn pipe(fd: *[2]i32) usize {
......@@ -264,9 +268,9 @@ pub fn rename(old: [*]const u8, new: [*]const u8) usize {
264268 if (@hasDecl(@This(), "SYS_rename")) {
265269 return syscall2(SYS_rename, @ptrToInt(old), @ptrToInt(new));
266270 } else if (@hasDecl(@This(), "SYS_renameat")) {
267 return syscall4(SYS_renameat, AT_FDCWD, @ptrToInt(old), AT_FDCWD, @ptrToInt(new));
271 return syscall4(SYS_renameat, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(old), @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(new));
268272 } else {
269 return syscall5(SYS_renameat2, AT_FDCWD, @ptrToInt(old), AT_FDCWD, @ptrToInt(new), 0);
273 return syscall5(SYS_renameat2, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(old), @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(new), 0);
270274 }
271275}
272276
......@@ -305,7 +309,17 @@ pub fn renameat2(oldfd: i32, oldpath: [*]const u8, newfd: i32, newpath: [*]const
305309
306310// TODO https://github.com/ziglang/zig/issues/265
307311pub fn open(path: [*]const u8, flags: u32, perm: usize) usize {
308 return syscall3(SYS_open, @ptrToInt(path), flags, perm);
312 if (@hasDecl(@This(), "SYS_open")) {
313 return syscall3(SYS_open, @ptrToInt(path), flags, perm);
314 } else {
315 return syscall4(
316 SYS_openat,
317 @bitCast(usize, isize(AT_FDCWD)),
318 @ptrToInt(path),
319 flags,
320 perm,
321 );
322 }
309323}
310324
311325// TODO https://github.com/ziglang/zig/issues/265
......@@ -373,7 +387,7 @@ pub fn unlink(path: [*]const u8) usize {
373387 if (@hasDecl(@This(), "SYS_unlink")) {
374388 return syscall1(SYS_unlink, @ptrToInt(path));
375389 } else {
376 return syscall3(SYS_unlinkat, AT_FDCWD, @ptrToInt(path), 0);
390 return syscall3(SYS_unlinkat, @bitCast(usize, isize(AT_FDCWD)), @ptrToInt(path), 0);
377391 }
378392}
379393
......@@ -759,18 +773,12 @@ pub fn epoll_create1(flags: usize) usize {
759773 return syscall1(SYS_epoll_create1, flags);
760774}
761775
762pub fn epoll_ctl(epoll_fd: i32, op: u32, fd: i32, ev: *epoll_event) usize {
776pub fn epoll_ctl(epoll_fd: i32, op: u32, fd: i32, ev: ?*epoll_event) usize {
763777 return syscall4(SYS_epoll_ctl, @bitCast(usize, isize(epoll_fd)), @intCast(usize, op), @bitCast(usize, isize(fd)), @ptrToInt(ev));
764778}
765779
766780pub fn epoll_wait(epoll_fd: i32, events: [*]epoll_event, maxevents: u32, timeout: i32) usize {
767 return syscall4(
768 SYS_epoll_wait,
769 @bitCast(usize, isize(epoll_fd)),
770 @ptrToInt(events),
771 maxevents,
772 @bitCast(usize, isize(timeout)),
773 );
781 return epoll_pwait(epoll_fd, events, maxevents, timeout, null);
774782}
775783
776784pub fn epoll_pwait(epoll_fd: i32, events: [*]epoll_event, maxevents: u32, timeout: i32, sigmask: ?*sigset_t) usize {