Skip to content

Commit

Permalink
fix linux stat struct on aarch64
Browse files Browse the repository at this point in the history
The ABI was incorrect.
  • Loading branch information
andrewrk committed Sep 22, 2019
1 parent dc2463d commit 2510ede
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions std/os/bits/linux/arm64.zig
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// arm64-specific declarations that are intended to be imported into the POSIX namespace.
// This does include Linux-only APIs.

const std = @import("../../std.zig");
const std = @import("../../../std.zig");
const linux = std.os.linux;
const socklen_t = linux.socklen_t;
const iovec = linux.iovec;
const iovec_const = linux.iovec_const;
const uid_t = linux.uid_t;
const gid_t = linux.gid_t;

pub const SYS_io_setup = 0;
pub const SYS_io_destroy = 1;
Expand Down Expand Up @@ -382,7 +384,14 @@ pub const msghdr_const = extern struct {
msg_flags: i32,
};

pub const off_t = i64;
pub const blksize_t = i32;
pub const nlink_t = u32;
pub const time_t = isize;
pub const mode_t = u32;
pub const off_t = isize;
pub const ino_t = usize;
pub const dev_t = usize;
pub const blkcnt_t = isize;

/// Renamed to Stat to not conflict with the stat function.
/// atime, mtime, and ctime have functions to return `timespec`,
Expand All @@ -391,23 +400,22 @@ pub const off_t = i64;
/// in C, macros are used to hide the differences. Here we use
/// methods to accomplish this.
pub const Stat = extern struct {
dev: u64,
ino: u64,
nlink: usize,

mode: u32,
uid: u32,
gid: u32,
__pad0: u32,
rdev: u64,
dev: dev_t,
ino: ino_t,
mode: mode_t,
nlink: nlink_t,
uid: uid_t,
gid: gid_t,
rdev: dev_t,
__pad: usize,
size: off_t,
blksize: isize,
blocks: i64,

blksize: blksize_t,
__pad2: i32,
blocks: blkcnt_t,
atim: timespec,
mtim: timespec,
ctim: timespec,
__unused: [3]isize,
__unused: [2]u32,

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

pub const timespec = extern struct {
tv_sec: isize,
tv_sec: time_t,
tv_nsec: isize,
};

Expand Down

0 comments on commit 2510ede

Please sign in to comment.