Commit 2d27341724

Shawn Landden <shawn@git.icu>
2018-10-05 20:32:31
arm64: respond to code review
1 parent 17cb69c
Changed files (6)
src/os.cpp
@@ -839,7 +839,7 @@ static int os_exec_process_posix(const char *exe, ZigList<const char *> &args,
     if ((err = pipe(stderr_pipe)))
         zig_panic("pipe failed");
 
-    pid_t pid = vfork();
+    pid_t pid = fork();
     if (pid == -1)
         zig_panic("fork failed: %s", strerror(errno));
     if (pid == 0) {
std/fmt/index.zig
@@ -1034,6 +1034,13 @@ test "fmt.format" {
         const result = try bufPrint(buf1[0..], "f64: {}\n", math.nan_f64);
         assert(mem.eql(u8, result, "f64: nan\n"));
     }
+    if (builtin.arch != builtin.Arch.armv8) {
+    // negative nan is not defined by IEE 754,
+    // and ARM thus normalizes it to positive nan
+        var buf1: [32]u8 = undefined;
+        const result = try bufPrint(buf1[0..], "f64: {}\n", -math.nan_f64);
+        assert(mem.eql(u8, result, "f64: -nan\n"));
+    }
     {
         var buf1: [32]u8 = undefined;
         const result = try bufPrint(buf1[0..], "f64: {}\n", math.inf_f64);
std/os/linux/arm64.zig
@@ -281,6 +281,54 @@ pub const SYS_statx = 291;
 pub const SYS_io_pgetevents = 292;
 pub const SYS_syscalls = 293;
 
+pub const O_CREAT = 0o100;
+pub const O_EXCL = 0o200;
+pub const O_NOCTTY = 0o400;
+pub const O_TRUNC = 0o1000;
+pub const O_APPEND = 0o2000;
+pub const O_NONBLOCK = 0o4000;
+pub const O_DSYNC = 0o10000;
+pub const O_SYNC = 0o4010000;
+pub const O_RSYNC = 0o4010000;
+pub const O_DIRECTORY = 0o200000;
+pub const O_NOFOLLOW = 0o400000;
+pub const O_CLOEXEC = 0o2000000;
+
+pub const O_ASYNC = 0o20000;
+pub const O_DIRECT = 0o40000;
+pub const O_LARGEFILE = 0;
+pub const O_NOATIME = 0o1000000;
+pub const O_PATH = 0o10000000;
+pub const O_TMPFILE = 0o20200000;
+pub const O_NDELAY = O_NONBLOCK;
+
+pub const F_DUPFD = 0;
+pub const F_GETFD = 1;
+pub const F_SETFD = 2;
+pub const F_GETFL = 3;
+pub const F_SETFL = 4;
+
+pub const F_SETOWN = 8;
+pub const F_GETOWN = 9;
+pub const F_SETSIG = 10;
+pub const F_GETSIG = 11;
+
+pub const F_GETLK = 5;
+pub const F_SETLK = 6;
+pub const F_SETLKW = 7;
+
+pub const F_SETOWN_EX = 15;
+pub const F_GETOWN_EX = 16;
+
+pub const F_GETOWNER_UIDS = 17;
+
+pub const AT_FDCWD = -100;
+pub const AT_SYMLINK_NOFOLLOW = 0x100;
+pub const AT_REMOVEDIR = 0x200;
+pub const AT_SYMLINK_FOLLOW = 0x400;
+pub const AT_NO_AUTOMOUNT = 0x800;
+pub const AT_EMPTY_PATH = 0x1000;
+
 pub const VDSO_USEFUL = true;
 pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
 pub const VDSO_CGT_VER = "LINUX_2.6.39";
std/os/linux/index.zig
@@ -625,54 +625,6 @@ pub const S_IWOTH = 0o002;
 pub const S_IXOTH = 0o001;
 pub const S_IRWXO = 0o007;
 
-pub const O_CREAT = 0o100;
-pub const O_EXCL = 0o200;
-pub const O_NOCTTY = 0o400;
-pub const O_TRUNC = 0o1000;
-pub const O_APPEND = 0o2000;
-pub const O_NONBLOCK = 0o4000;
-pub const O_DSYNC = 0o10000;
-pub const O_SYNC = 0o4010000;
-pub const O_RSYNC = 0o4010000;
-pub const O_DIRECTORY = 0o200000;
-pub const O_NOFOLLOW = 0o400000;
-pub const O_CLOEXEC = 0o2000000;
-
-pub const O_ASYNC = 0o20000;
-pub const O_DIRECT = 0o40000;
-pub const O_LARGEFILE = 0;
-pub const O_NOATIME = 0o1000000;
-pub const O_PATH = 0o10000000;
-pub const O_TMPFILE = 0o20200000;
-pub const O_NDELAY = O_NONBLOCK;
-
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_SETFD = 2;
-pub const F_GETFL = 3;
-pub const F_SETFL = 4;
-
-pub const F_SETOWN = 8;
-pub const F_GETOWN = 9;
-pub const F_SETSIG = 10;
-pub const F_GETSIG = 11;
-
-pub const F_GETLK = 5;
-pub const F_SETLK = 6;
-pub const F_SETLKW = 7;
-
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
-pub const AT_FDCWD = -100;
-pub const AT_SYMLINK_NOFOLLOW = 0x100;
-pub const AT_REMOVEDIR = 0x200;
-pub const AT_SYMLINK_FOLLOW = 0x400;
-pub const AT_NO_AUTOMOUNT = 0x800;
-pub const AT_EMPTY_PATH = 0x1000;
-
 pub fn S_ISREG(m: u32) bool {
     return m & S_IFMT == S_IFREG;
 }
@@ -1272,7 +1224,7 @@ pub fn accept4(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t, flags:
 }
 
 pub fn fstat(fd: i32, stat_buf: *Stat) usize {
-    return fstatat(fd, c"", stat_buf, AT_EMPTY_PATH);
+    return syscall2(SYS_fstat, @intCast(usize, fd), @ptrToInt(stat_buf));
 }
 
 // TODO https://github.com/ziglang/zig/issues/265
std/os/linux/x86_64.zig
@@ -332,6 +332,54 @@ pub const SYS_userfaultfd = 323;
 pub const SYS_membarrier = 324;
 pub const SYS_mlock2 = 325;
 
+pub const O_CREAT = 0o100;
+pub const O_EXCL = 0o200;
+pub const O_NOCTTY = 0o400;
+pub const O_TRUNC = 0o1000;
+pub const O_APPEND = 0o2000;
+pub const O_NONBLOCK = 0o4000;
+pub const O_DSYNC = 0o10000;
+pub const O_SYNC = 0o4010000;
+pub const O_RSYNC = 0o4010000;
+pub const O_DIRECTORY = 0o200000;
+pub const O_NOFOLLOW = 0o400000;
+pub const O_CLOEXEC = 0o2000000;
+
+pub const O_ASYNC = 0o20000;
+pub const O_DIRECT = 0o40000;
+pub const O_LARGEFILE = 0;
+pub const O_NOATIME = 0o1000000;
+pub const O_PATH = 0o10000000;
+pub const O_TMPFILE = 0o20200000;
+pub const O_NDELAY = O_NONBLOCK;
+
+pub const F_DUPFD = 0;
+pub const F_GETFD = 1;
+pub const F_SETFD = 2;
+pub const F_GETFL = 3;
+pub const F_SETFL = 4;
+
+pub const F_SETOWN = 8;
+pub const F_GETOWN = 9;
+pub const F_SETSIG = 10;
+pub const F_GETSIG = 11;
+
+pub const F_GETLK = 5;
+pub const F_SETLK = 6;
+pub const F_SETLKW = 7;
+
+pub const F_SETOWN_EX = 15;
+pub const F_GETOWN_EX = 16;
+
+pub const F_GETOWNER_UIDS = 17;
+
+pub const AT_FDCWD = -100;
+pub const AT_SYMLINK_NOFOLLOW = 0x100;
+pub const AT_REMOVEDIR = 0x200;
+pub const AT_SYMLINK_FOLLOW = 0x400;
+pub const AT_NO_AUTOMOUNT = 0x800;
+pub const AT_EMPTY_PATH = 0x1000;
+
 pub const VDSO_USEFUL = true;
 pub const VDSO_CGT_SYM = "__vdso_clock_gettime";
 pub const VDSO_CGT_VER = "LINUX_2.6";
std/os/index.zig
@@ -633,7 +633,7 @@ fn posixExecveErrnoToErr(err: usize) PosixExecveError {
     };
 }
 
-pub var linux_elf_aux_maybe: ?[*]std.elf.Auxv = undefined;
+pub var linux_elf_aux_maybe: ?[*]std.elf.Auxv = null;
 pub var posix_environ_raw: [][*]u8 = undefined;
 
 /// See std.elf for the constants.