Skip to content

Commit 2510ede

Browse files
committed
fix linux stat struct on aarch64
The ABI was incorrect.
1 parent dc2463d commit 2510ede

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

std/os/bits/linux/arm64.zig

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// arm64-specific declarations that are intended to be imported into the POSIX namespace.
22
// This does include Linux-only APIs.
33

4-
const std = @import("../../std.zig");
4+
const std = @import("../../../std.zig");
55
const linux = std.os.linux;
66
const socklen_t = linux.socklen_t;
77
const iovec = linux.iovec;
88
const iovec_const = linux.iovec_const;
9+
const uid_t = linux.uid_t;
10+
const gid_t = linux.gid_t;
911

1012
pub const SYS_io_setup = 0;
1113
pub const SYS_io_destroy = 1;
@@ -382,7 +384,14 @@ pub const msghdr_const = extern struct {
382384
msg_flags: i32,
383385
};
384386

385-
pub const off_t = i64;
387+
pub const blksize_t = i32;
388+
pub const nlink_t = u32;
389+
pub const time_t = isize;
390+
pub const mode_t = u32;
391+
pub const off_t = isize;
392+
pub const ino_t = usize;
393+
pub const dev_t = usize;
394+
pub const blkcnt_t = isize;
386395

387396
/// Renamed to Stat to not conflict with the stat function.
388397
/// atime, mtime, and ctime have functions to return `timespec`,
@@ -391,23 +400,22 @@ pub const off_t = i64;
391400
/// in C, macros are used to hide the differences. Here we use
392401
/// methods to accomplish this.
393402
pub const Stat = extern struct {
394-
dev: u64,
395-
ino: u64,
396-
nlink: usize,
397-
398-
mode: u32,
399-
uid: u32,
400-
gid: u32,
401-
__pad0: u32,
402-
rdev: u64,
403+
dev: dev_t,
404+
ino: ino_t,
405+
mode: mode_t,
406+
nlink: nlink_t,
407+
uid: uid_t,
408+
gid: gid_t,
409+
rdev: dev_t,
410+
__pad: usize,
403411
size: off_t,
404-
blksize: isize,
405-
blocks: i64,
406-
412+
blksize: blksize_t,
413+
__pad2: i32,
414+
blocks: blkcnt_t,
407415
atim: timespec,
408416
mtim: timespec,
409417
ctim: timespec,
410-
__unused: [3]isize,
418+
__unused: [2]u32,
411419

412420
pub fn atime(self: Stat) timespec {
413421
return self.atim;
@@ -423,7 +431,7 @@ pub const Stat = extern struct {
423431
};
424432

425433
pub const timespec = extern struct {
426-
tv_sec: isize,
434+
tv_sec: time_t,
427435
tv_nsec: isize,
428436
};
429437

0 commit comments

Comments
 (0)