Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions lib/std/Io/Threaded.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1276,11 +1276,18 @@ fn dirStatPathLinux(
dir.handle,
sub_path_posix,
flags,
linux.STATX_TYPE | linux.STATX_MODE | linux.STATX_ATIME | linux.STATX_MTIME | linux.STATX_CTIME,
.{ .TYPE = true, .MODE = true, .ATIME = true, .MTIME = true, .CTIME = true },
&statx,
);
switch (linux.E.init(rc)) {
.SUCCESS => return statFromLinux(&statx),
.SUCCESS => {
assert(statx.mask.TYPE);
assert(statx.mask.MODE);
assert(statx.mask.ATIME);
assert(statx.mask.MTIME);
assert(statx.mask.CTIME);
return statFromLinux(&statx);
},
.INTR => continue,
.CANCELED => return error.Canceled,

Expand Down Expand Up @@ -1423,11 +1430,18 @@ fn fileStatLinux(userdata: ?*anyopaque, file: Io.File) Io.File.StatError!Io.File
file.handle,
"",
linux.AT.EMPTY_PATH,
linux.STATX_TYPE | linux.STATX_MODE | linux.STATX_ATIME | linux.STATX_MTIME | linux.STATX_CTIME,
.{ .TYPE = true, .MODE = true, .ATIME = true, .MTIME = true, .CTIME = true },
&statx,
);
switch (linux.E.init(rc)) {
.SUCCESS => return statFromLinux(&statx),
.SUCCESS => {
assert(statx.mask.TYPE);
assert(statx.mask.MODE);
assert(statx.mask.ATIME);
assert(statx.mask.MTIME);
assert(statx.mask.CTIME);
return statFromLinux(&statx);
},
.INTR => continue,
.CANCELED => return error.Canceled,

Expand Down
176 changes: 5 additions & 171 deletions lib/std/c.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7477,166 +7477,6 @@ pub const EAI = if (builtin.abi.isAndroid()) enum(c_int) {
pub const dl_iterate_phdr_callback = *const fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.c) c_int;

pub const Stat = switch (native_os) {
.linux => switch (native_arch) {
.sparc64 => extern struct {
dev: u64,
__pad1: u16,
ino: ino_t,
mode: u32,
nlink: u32,

uid: u32,
gid: u32,
rdev: u64,
__pad2: u16,

size: off_t,
blksize: isize,
blocks: i64,

atim: timespec,
mtim: timespec,
ctim: timespec,
__reserved: [2]usize,

pub fn atime(self: @This()) timespec {
return self.atim;
}

pub fn mtime(self: @This()) timespec {
return self.mtim;
}

pub fn ctime(self: @This()) timespec {
return self.ctim;
}
},
.mips, .mipsel => if (builtin.target.abi.isMusl()) extern struct {
dev: dev_t,
__pad0: [2]i32,
ino: ino_t,
mode: mode_t,
nlink: nlink_t,
uid: uid_t,
gid: gid_t,
rdev: dev_t,
__pad1: [2]i32,
size: off_t,
atim: timespec,
mtim: timespec,
ctim: timespec,
blksize: blksize_t,
__pad3: i32,
blocks: blkcnt_t,
__pad4: [14]i32,

pub fn atime(self: @This()) timespec {
return self.atim;
}

pub fn mtime(self: @This()) timespec {
return self.mtim;
}

pub fn ctime(self: @This()) timespec {
return self.ctim;
}
} else extern struct {
dev: u32,
__pad0: [3]u32,
ino: ino_t,
mode: mode_t,
nlink: nlink_t,
uid: uid_t,
gid: gid_t,
rdev: u32,
__pad1: [3]u32,
size: off_t,
atim: timespec,
mtim: timespec,
ctim: timespec,
blksize: blksize_t,
__pad3: u32,
blocks: blkcnt_t,
__pad4: [14]u32,

pub fn atime(self: @This()) timespec {
return self.atim;
}

pub fn mtime(self: @This()) timespec {
return self.mtim;
}

pub fn ctime(self: @This()) timespec {
return self.ctim;
}
},
.mips64, .mips64el => if (builtin.target.abi.isMusl()) extern struct {
dev: dev_t,
__pad0: [3]i32,
ino: ino_t,
mode: mode_t,
nlink: nlink_t,
uid: uid_t,
gid: gid_t,
rdev: dev_t,
__pad1: [2]u32,
size: off_t,
__pad2: i32,
atim: timespec,
mtim: timespec,
ctim: timespec,
blksize: blksize_t,
__pad3: u32,
blocks: blkcnt_t,
__pad4: [14]i32,

pub fn atime(self: @This()) timespec {
return self.atim;
}

pub fn mtime(self: @This()) timespec {
return self.mtim;
}

pub fn ctime(self: @This()) timespec {
return self.ctim;
}
} else extern struct {
dev: dev_t,
__pad0: [3]u32,
ino: ino_t,
mode: mode_t,
nlink: nlink_t,
uid: uid_t,
gid: gid_t,
rdev: dev_t,
__pad1: [3]u32,
size: off_t,
atim: timespec,
mtim: timespec,
ctim: timespec,
blksize: blksize_t,
__pad3: u32,
blocks: blkcnt_t,
__pad4: [14]i32,

pub fn atime(self: @This()) timespec {
return self.atim;
}

pub fn mtime(self: @This()) timespec {
return self.mtim;
}

pub fn ctime(self: @This()) timespec {
return self.ctim;
}
},

else => std.os.linux.Stat, // libc stat is the same as kernel stat.
},
.emscripten => emscripten.Stat,
.wasi => extern struct {
// Match wasi-libc's `struct stat` in lib/libc/include/wasm-wasi-musl/__struct_stat.h
Expand Down Expand Up @@ -10274,6 +10114,7 @@ pub const fstat = switch (native_os) {
else => private.fstat,
},
.netbsd => private.__fstat50,
.linux => {},
else => private.fstat,
};

Expand All @@ -10282,8 +10123,12 @@ pub const fstatat = switch (native_os) {
.x86_64 => private.@"fstatat$INODE64",
else => private.fstatat,
},
.linux => {},
else => private.fstatat,
};

pub extern "c" fn statx(dirfd: fd_t, path: [*:0]const u8, flags: u32, mask: linux.STATX, buf: *linux.Statx) c_int;

pub extern "c" fn getpwent() ?*passwd;
pub extern "c" fn endpwent() void;
pub extern "c" fn setpwent() void;
Expand Down Expand Up @@ -10357,8 +10202,6 @@ pub extern "c" fn inotify_init1(flags: c_uint) c_int;
pub extern "c" fn inotify_add_watch(fd: fd_t, pathname: [*:0]const u8, mask: u32) c_int;
pub extern "c" fn inotify_rm_watch(fd: fd_t, wd: c_int) c_int;

pub extern "c" fn fstat64(fd: fd_t, buf: *Stat) c_int;
pub extern "c" fn fstatat64(dirfd: fd_t, noalias path: [*:0]const u8, noalias stat_buf: *Stat, flags: u32) c_int;
pub extern "c" fn fallocate64(fd: fd_t, mode: c_int, offset: off_t, len: off_t) c_int;
pub extern "c" fn fopen64(noalias filename: [*:0]const u8, noalias modes: [*:0]const u8) ?*FILE;
pub extern "c" fn ftruncate64(fd: c_int, length: off_t) c_int;
Expand Down Expand Up @@ -10533,14 +10376,6 @@ pub const socketpair = switch (native_os) {
else => private.socketpair,
};

pub const stat = switch (native_os) {
.macos => switch (native_arch) {
.x86_64 => private.@"stat$INODE64",
else => private.stat,
},
else => private.stat,
};

pub const _msize = switch (native_os) {
.windows => private._msize,
else => {},
Expand Down Expand Up @@ -11383,7 +11218,6 @@ const private = struct {
extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
extern "c" fn socketpair(domain: c_uint, sock_type: c_uint, protocol: c_uint, sv: *[2]fd_t) c_int;
extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int;
extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
extern "c" fn sysconf(sc: c_int) c_long;
extern "c" fn shm_open(name: [*:0]const u8, flag: c_int, mode: mode_t) c_int;
Expand Down
Loading
Loading