authorgravatar for shawn@git.icuShawn Landden <shawn@git.icu> 2018-10-05 11:32:31-07:00
committergravatar for shawn@git.icuShawn Landden <shawn@git.icu> 2018-10-06 03:31:52+00:00
log2d2734172484871eb56705e77acca50a8c83d8ae
tree278d83eae31e9c2703fa3c5bb89778455695daab
parent17cb69cebcb05bbc9d9f7cf01c41a97b71f8a499

arm64: respond to code review


6 files changed, 106 insertions(+), 51 deletions(-)

src/os.cpp+1-1
...@@ -839,7 +839,7 @@ static int os_exec_process_posix(const char *exe, ZigList<const char *> &args,...@@ -839,7 +839,7 @@ static int os_exec_process_posix(const char *exe, ZigList<const char *> &args,
839 if ((err = pipe(stderr_pipe)))839 if ((err = pipe(stderr_pipe)))
840 zig_panic("pipe failed");840 zig_panic("pipe failed");
841841
842 pid_t pid = vfork();842 pid_t pid = fork();
843 if (pid == -1)843 if (pid == -1)
844 zig_panic("fork failed: %s", strerror(errno));844 zig_panic("fork failed: %s", strerror(errno));
845 if (pid == 0) {845 if (pid == 0) {
std/fmt/index.zig+7
...@@ -1034,6 +1034,13 @@ test "fmt.format" {...@@ -1034,6 +1034,13 @@ test "fmt.format" {
1034 const result = try bufPrint(buf1[0..], "f64: {}\n", math.nan_f64);1034 const result = try bufPrint(buf1[0..], "f64: {}\n", math.nan_f64);
1035 assert(mem.eql(u8, result, "f64: nan\n"));1035 assert(mem.eql(u8, result, "f64: nan\n"));
1036 }1036 }
1037 if (builtin.arch != builtin.Arch.armv8) {
1038 // negative nan is not defined by IEE 754,
1039 // and ARM thus normalizes it to positive nan
1040 var buf1: [32]u8 = undefined;
1041 const result = try bufPrint(buf1[0..], "f64: {}\n", -math.nan_f64);
1042 assert(mem.eql(u8, result, "f64: -nan\n"));
1043 }
1037 {1044 {
1038 var buf1: [32]u8 = undefined;1045 var buf1: [32]u8 = undefined;
1039 const result = try bufPrint(buf1[0..], "f64: {}\n", math.inf_f64);1046 const result = try bufPrint(buf1[0..], "f64: {}\n", math.inf_f64);
std/os/index.zig+1-1
...@@ -633,7 +633,7 @@ fn posixExecveErrnoToErr(err: usize) PosixExecveError {...@@ -633,7 +633,7 @@ fn posixExecveErrnoToErr(err: usize) PosixExecveError {
633 };633 };
634}634}
635635
636pub var linux_elf_aux_maybe: ?[*]std.elf.Auxv = undefined;636pub var linux_elf_aux_maybe: ?[*]std.elf.Auxv = null;
637pub var posix_environ_raw: [][*]u8 = undefined;637pub var posix_environ_raw: [][*]u8 = undefined;
638638
639/// See std.elf for the constants.639/// See std.elf for the constants.
std/os/linux/arm64.zig+48
...@@ -281,6 +281,54 @@ pub const SYS_statx = 291;...@@ -281,6 +281,54 @@ pub const SYS_statx = 291;
281pub const SYS_io_pgetevents = 292;281pub const SYS_io_pgetevents = 292;
282pub const SYS_syscalls = 293;282pub const SYS_syscalls = 293;
283283
284pub const O_CREAT = 0o100;
285pub const O_EXCL = 0o200;
286pub const O_NOCTTY = 0o400;
287pub const O_TRUNC = 0o1000;
288pub const O_APPEND = 0o2000;
289pub const O_NONBLOCK = 0o4000;
290pub const O_DSYNC = 0o10000;
291pub const O_SYNC = 0o4010000;
292pub const O_RSYNC = 0o4010000;
293pub const O_DIRECTORY = 0o200000;
294pub const O_NOFOLLOW = 0o400000;
295pub const O_CLOEXEC = 0o2000000;
296
297pub const O_ASYNC = 0o20000;
298pub const O_DIRECT = 0o40000;
299pub const O_LARGEFILE = 0;
300pub const O_NOATIME = 0o1000000;
301pub const O_PATH = 0o10000000;
302pub const O_TMPFILE = 0o20200000;
303pub const O_NDELAY = O_NONBLOCK;
304
305pub const F_DUPFD = 0;
306pub const F_GETFD = 1;
307pub const F_SETFD = 2;
308pub const F_GETFL = 3;
309pub const F_SETFL = 4;
310
311pub const F_SETOWN = 8;
312pub const F_GETOWN = 9;
313pub const F_SETSIG = 10;
314pub const F_GETSIG = 11;
315
316pub const F_GETLK = 5;
317pub const F_SETLK = 6;
318pub const F_SETLKW = 7;
319
320pub const F_SETOWN_EX = 15;
321pub const F_GETOWN_EX = 16;
322
323pub const F_GETOWNER_UIDS = 17;
324
325pub const AT_FDCWD = -100;
326pub const AT_SYMLINK_NOFOLLOW = 0x100;
327pub const AT_REMOVEDIR = 0x200;
328pub const AT_SYMLINK_FOLLOW = 0x400;
329pub const AT_NO_AUTOMOUNT = 0x800;
330pub const AT_EMPTY_PATH = 0x1000;
331
284pub const VDSO_USEFUL = true;332pub const VDSO_USEFUL = true;
285pub const VDSO_CGT_SYM = "__kernel_clock_gettime";333pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
286pub const VDSO_CGT_VER = "LINUX_2.6.39";334pub const VDSO_CGT_VER = "LINUX_2.6.39";
std/os/linux/index.zig+1-49
...@@ -625,54 +625,6 @@ pub const S_IWOTH = 0o002;...@@ -625,54 +625,6 @@ pub const S_IWOTH = 0o002;
625pub const S_IXOTH = 0o001;625pub const S_IXOTH = 0o001;
626pub const S_IRWXO = 0o007;626pub const S_IRWXO = 0o007;
627627
628pub const O_CREAT = 0o100;
629pub const O_EXCL = 0o200;
630pub const O_NOCTTY = 0o400;
631pub const O_TRUNC = 0o1000;
632pub const O_APPEND = 0o2000;
633pub const O_NONBLOCK = 0o4000;
634pub const O_DSYNC = 0o10000;
635pub const O_SYNC = 0o4010000;
636pub const O_RSYNC = 0o4010000;
637pub const O_DIRECTORY = 0o200000;
638pub const O_NOFOLLOW = 0o400000;
639pub const O_CLOEXEC = 0o2000000;
640
641pub const O_ASYNC = 0o20000;
642pub const O_DIRECT = 0o40000;
643pub const O_LARGEFILE = 0;
644pub const O_NOATIME = 0o1000000;
645pub const O_PATH = 0o10000000;
646pub const O_TMPFILE = 0o20200000;
647pub const O_NDELAY = O_NONBLOCK;
648
649pub const F_DUPFD = 0;
650pub const F_GETFD = 1;
651pub const F_SETFD = 2;
652pub const F_GETFL = 3;
653pub const F_SETFL = 4;
654
655pub const F_SETOWN = 8;
656pub const F_GETOWN = 9;
657pub const F_SETSIG = 10;
658pub const F_GETSIG = 11;
659
660pub const F_GETLK = 5;
661pub const F_SETLK = 6;
662pub const F_SETLKW = 7;
663
664pub const F_SETOWN_EX = 15;
665pub const F_GETOWN_EX = 16;
666
667pub const F_GETOWNER_UIDS = 17;
668
669pub const AT_FDCWD = -100;
670pub const AT_SYMLINK_NOFOLLOW = 0x100;
671pub const AT_REMOVEDIR = 0x200;
672pub const AT_SYMLINK_FOLLOW = 0x400;
673pub const AT_NO_AUTOMOUNT = 0x800;
674pub const AT_EMPTY_PATH = 0x1000;
675
676pub fn S_ISREG(m: u32) bool {628pub fn S_ISREG(m: u32) bool {
677 return m & S_IFMT == S_IFREG;629 return m & S_IFMT == S_IFREG;
678}630}
...@@ -1272,7 +1224,7 @@ pub fn accept4(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t, flags:...@@ -1272,7 +1224,7 @@ pub fn accept4(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t, flags:
1272}1224}
12731225
1274pub fn fstat(fd: i32, stat_buf: *Stat) usize {1226pub fn fstat(fd: i32, stat_buf: *Stat) usize {
1275 return fstatat(fd, c"", stat_buf, AT_EMPTY_PATH);1227 return syscall2(SYS_fstat, @intCast(usize, fd), @ptrToInt(stat_buf));
1276}1228}
12771229
1278// TODO https://github.com/ziglang/zig/issues/2651230// TODO https://github.com/ziglang/zig/issues/265
std/os/linux/x86_64.zig+48
...@@ -332,6 +332,54 @@ pub const SYS_userfaultfd = 323;...@@ -332,6 +332,54 @@ pub const SYS_userfaultfd = 323;
332pub const SYS_membarrier = 324;332pub const SYS_membarrier = 324;
333pub const SYS_mlock2 = 325;333pub const SYS_mlock2 = 325;
334334
335pub const O_CREAT = 0o100;
336pub const O_EXCL = 0o200;
337pub const O_NOCTTY = 0o400;
338pub const O_TRUNC = 0o1000;
339pub const O_APPEND = 0o2000;
340pub const O_NONBLOCK = 0o4000;
341pub const O_DSYNC = 0o10000;
342pub const O_SYNC = 0o4010000;
343pub const O_RSYNC = 0o4010000;
344pub const O_DIRECTORY = 0o200000;
345pub const O_NOFOLLOW = 0o400000;
346pub const O_CLOEXEC = 0o2000000;
347
348pub const O_ASYNC = 0o20000;
349pub const O_DIRECT = 0o40000;
350pub const O_LARGEFILE = 0;
351pub const O_NOATIME = 0o1000000;
352pub const O_PATH = 0o10000000;
353pub const O_TMPFILE = 0o20200000;
354pub const O_NDELAY = O_NONBLOCK;
355
356pub const F_DUPFD = 0;
357pub const F_GETFD = 1;
358pub const F_SETFD = 2;
359pub const F_GETFL = 3;
360pub const F_SETFL = 4;
361
362pub const F_SETOWN = 8;
363pub const F_GETOWN = 9;
364pub const F_SETSIG = 10;
365pub const F_GETSIG = 11;
366
367pub const F_GETLK = 5;
368pub const F_SETLK = 6;
369pub const F_SETLKW = 7;
370
371pub const F_SETOWN_EX = 15;
372pub const F_GETOWN_EX = 16;
373
374pub const F_GETOWNER_UIDS = 17;
375
376pub const AT_FDCWD = -100;
377pub const AT_SYMLINK_NOFOLLOW = 0x100;
378pub const AT_REMOVEDIR = 0x200;
379pub const AT_SYMLINK_FOLLOW = 0x400;
380pub const AT_NO_AUTOMOUNT = 0x800;
381pub const AT_EMPTY_PATH = 0x1000;
382
335pub const VDSO_USEFUL = true;383pub const VDSO_USEFUL = true;
336pub const VDSO_CGT_SYM = "__vdso_clock_gettime";384pub const VDSO_CGT_SYM = "__vdso_clock_gettime";
337pub const VDSO_CGT_VER = "LINUX_2.6";385pub const VDSO_CGT_VER = "LINUX_2.6";