Skip to content

Commit 2d27341

Browse files
committed
arm64: respond to code review
1 parent 17cb69c commit 2d27341

File tree

6 files changed

+106
-51
lines changed

6 files changed

+106
-51
lines changed

src/os.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ static int os_exec_process_posix(const char *exe, ZigList<const char *> &args,
839839
if ((err = pipe(stderr_pipe)))
840840
zig_panic("pipe failed");
841841

842-
pid_t pid = vfork();
842+
pid_t pid = fork();
843843
if (pid == -1)
844844
zig_panic("fork failed: %s", strerror(errno));
845845
if (pid == 0) {

std/fmt/index.zig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,13 @@ test "fmt.format" {
10341034
const result = try bufPrint(buf1[0..], "f64: {}\n", math.nan_f64);
10351035
assert(mem.eql(u8, result, "f64: nan\n"));
10361036
}
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+
}
10371044
{
10381045
var buf1: [32]u8 = undefined;
10391046
const result = try bufPrint(buf1[0..], "f64: {}\n", math.inf_f64);

std/os/index.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ fn posixExecveErrnoToErr(err: usize) PosixExecveError {
633633
};
634634
}
635635

636-
pub var linux_elf_aux_maybe: ?[*]std.elf.Auxv = undefined;
636+
pub var linux_elf_aux_maybe: ?[*]std.elf.Auxv = null;
637637
pub var posix_environ_raw: [][*]u8 = undefined;
638638

639639
/// See std.elf for the constants.

std/os/linux/arm64.zig

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,54 @@ pub const SYS_statx = 291;
281281
pub const SYS_io_pgetevents = 292;
282282
pub const SYS_syscalls = 293;
283283

284+
pub const O_CREAT = 0o100;
285+
pub const O_EXCL = 0o200;
286+
pub const O_NOCTTY = 0o400;
287+
pub const O_TRUNC = 0o1000;
288+
pub const O_APPEND = 0o2000;
289+
pub const O_NONBLOCK = 0o4000;
290+
pub const O_DSYNC = 0o10000;
291+
pub const O_SYNC = 0o4010000;
292+
pub const O_RSYNC = 0o4010000;
293+
pub const O_DIRECTORY = 0o200000;
294+
pub const O_NOFOLLOW = 0o400000;
295+
pub const O_CLOEXEC = 0o2000000;
296+
297+
pub const O_ASYNC = 0o20000;
298+
pub const O_DIRECT = 0o40000;
299+
pub const O_LARGEFILE = 0;
300+
pub const O_NOATIME = 0o1000000;
301+
pub const O_PATH = 0o10000000;
302+
pub const O_TMPFILE = 0o20200000;
303+
pub const O_NDELAY = O_NONBLOCK;
304+
305+
pub const F_DUPFD = 0;
306+
pub const F_GETFD = 1;
307+
pub const F_SETFD = 2;
308+
pub const F_GETFL = 3;
309+
pub const F_SETFL = 4;
310+
311+
pub const F_SETOWN = 8;
312+
pub const F_GETOWN = 9;
313+
pub const F_SETSIG = 10;
314+
pub const F_GETSIG = 11;
315+
316+
pub const F_GETLK = 5;
317+
pub const F_SETLK = 6;
318+
pub const F_SETLKW = 7;
319+
320+
pub const F_SETOWN_EX = 15;
321+
pub const F_GETOWN_EX = 16;
322+
323+
pub const F_GETOWNER_UIDS = 17;
324+
325+
pub const AT_FDCWD = -100;
326+
pub const AT_SYMLINK_NOFOLLOW = 0x100;
327+
pub const AT_REMOVEDIR = 0x200;
328+
pub const AT_SYMLINK_FOLLOW = 0x400;
329+
pub const AT_NO_AUTOMOUNT = 0x800;
330+
pub const AT_EMPTY_PATH = 0x1000;
331+
284332
pub const VDSO_USEFUL = true;
285333
pub const VDSO_CGT_SYM = "__kernel_clock_gettime";
286334
pub const VDSO_CGT_VER = "LINUX_2.6.39";

std/os/linux/index.zig

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -625,54 +625,6 @@ pub const S_IWOTH = 0o002;
625625
pub const S_IXOTH = 0o001;
626626
pub const S_IRWXO = 0o007;
627627

628-
pub const O_CREAT = 0o100;
629-
pub const O_EXCL = 0o200;
630-
pub const O_NOCTTY = 0o400;
631-
pub const O_TRUNC = 0o1000;
632-
pub const O_APPEND = 0o2000;
633-
pub const O_NONBLOCK = 0o4000;
634-
pub const O_DSYNC = 0o10000;
635-
pub const O_SYNC = 0o4010000;
636-
pub const O_RSYNC = 0o4010000;
637-
pub const O_DIRECTORY = 0o200000;
638-
pub const O_NOFOLLOW = 0o400000;
639-
pub const O_CLOEXEC = 0o2000000;
640-
641-
pub const O_ASYNC = 0o20000;
642-
pub const O_DIRECT = 0o40000;
643-
pub const O_LARGEFILE = 0;
644-
pub const O_NOATIME = 0o1000000;
645-
pub const O_PATH = 0o10000000;
646-
pub const O_TMPFILE = 0o20200000;
647-
pub const O_NDELAY = O_NONBLOCK;
648-
649-
pub const F_DUPFD = 0;
650-
pub const F_GETFD = 1;
651-
pub const F_SETFD = 2;
652-
pub const F_GETFL = 3;
653-
pub const F_SETFL = 4;
654-
655-
pub const F_SETOWN = 8;
656-
pub const F_GETOWN = 9;
657-
pub const F_SETSIG = 10;
658-
pub const F_GETSIG = 11;
659-
660-
pub const F_GETLK = 5;
661-
pub const F_SETLK = 6;
662-
pub const F_SETLKW = 7;
663-
664-
pub const F_SETOWN_EX = 15;
665-
pub const F_GETOWN_EX = 16;
666-
667-
pub const F_GETOWNER_UIDS = 17;
668-
669-
pub const AT_FDCWD = -100;
670-
pub const AT_SYMLINK_NOFOLLOW = 0x100;
671-
pub const AT_REMOVEDIR = 0x200;
672-
pub const AT_SYMLINK_FOLLOW = 0x400;
673-
pub const AT_NO_AUTOMOUNT = 0x800;
674-
pub const AT_EMPTY_PATH = 0x1000;
675-
676628
pub fn S_ISREG(m: u32) bool {
677629
return m & S_IFMT == S_IFREG;
678630
}
@@ -1272,7 +1224,7 @@ pub fn accept4(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t, flags:
12721224
}
12731225

12741226
pub 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));
12761228
}
12771229

12781230
// TODO https://github.com/ziglang/zig/issues/265

std/os/linux/x86_64.zig

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,54 @@ pub const SYS_userfaultfd = 323;
332332
pub const SYS_membarrier = 324;
333333
pub const SYS_mlock2 = 325;
334334

335+
pub const O_CREAT = 0o100;
336+
pub const O_EXCL = 0o200;
337+
pub const O_NOCTTY = 0o400;
338+
pub const O_TRUNC = 0o1000;
339+
pub const O_APPEND = 0o2000;
340+
pub const O_NONBLOCK = 0o4000;
341+
pub const O_DSYNC = 0o10000;
342+
pub const O_SYNC = 0o4010000;
343+
pub const O_RSYNC = 0o4010000;
344+
pub const O_DIRECTORY = 0o200000;
345+
pub const O_NOFOLLOW = 0o400000;
346+
pub const O_CLOEXEC = 0o2000000;
347+
348+
pub const O_ASYNC = 0o20000;
349+
pub const O_DIRECT = 0o40000;
350+
pub const O_LARGEFILE = 0;
351+
pub const O_NOATIME = 0o1000000;
352+
pub const O_PATH = 0o10000000;
353+
pub const O_TMPFILE = 0o20200000;
354+
pub const O_NDELAY = O_NONBLOCK;
355+
356+
pub const F_DUPFD = 0;
357+
pub const F_GETFD = 1;
358+
pub const F_SETFD = 2;
359+
pub const F_GETFL = 3;
360+
pub const F_SETFL = 4;
361+
362+
pub const F_SETOWN = 8;
363+
pub const F_GETOWN = 9;
364+
pub const F_SETSIG = 10;
365+
pub const F_GETSIG = 11;
366+
367+
pub const F_GETLK = 5;
368+
pub const F_SETLK = 6;
369+
pub const F_SETLKW = 7;
370+
371+
pub const F_SETOWN_EX = 15;
372+
pub const F_GETOWN_EX = 16;
373+
374+
pub const F_GETOWNER_UIDS = 17;
375+
376+
pub const AT_FDCWD = -100;
377+
pub const AT_SYMLINK_NOFOLLOW = 0x100;
378+
pub const AT_REMOVEDIR = 0x200;
379+
pub const AT_SYMLINK_FOLLOW = 0x400;
380+
pub const AT_NO_AUTOMOUNT = 0x800;
381+
pub const AT_EMPTY_PATH = 0x1000;
382+
335383
pub const VDSO_USEFUL = true;
336384
pub const VDSO_CGT_SYM = "__vdso_clock_gettime";
337385
pub const VDSO_CGT_VER = "LINUX_2.6";

0 commit comments

Comments
 (0)