| author | |
| committer | |
| log | c9551652b01bf47a94c139846f22c5df85d07283 |
| tree | 9f7c957dedad2c8e7e72c28ae065a58619c417ba |
| parent | cf7505da1f60757d9fabda20560191bba72ebdbe |
| parent | cca6b1113825e5d9723568a398d270ceac6da92c |
| signature |
Decouple kernel and libc stat definitions21 files changed, 178 insertions(+), 175 deletions(-)
lib/std/c.zig+6-6| ... | @@ -128,7 +128,7 @@ pub usingnamespace switch (builtin.os.tag) { | ... | @@ -128,7 +128,7 @@ pub usingnamespace switch (builtin.os.tag) { |
| 128 | }, | 128 | }, |
| 129 | else => struct { | 129 | else => struct { |
| 130 | pub extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8; | 130 | pub extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8; |
| 131 | pub extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *Stat, flags: u32) c_int; | 131 | pub extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *libc_stat, flags: u32) c_int; |
| 132 | }, | 132 | }, |
| 133 | }; | 133 | }; |
| 134 | 134 | ||
| ... | @@ -202,26 +202,26 @@ pub usingnamespace switch (builtin.os.tag) { | ... | @@ -202,26 +202,26 @@ pub usingnamespace switch (builtin.os.tag) { |
| 202 | pub extern "c" fn sigaction(sig: c_int, noalias act: *const Sigaction, noalias oact: ?*Sigaction) c_int; | 202 | pub extern "c" fn sigaction(sig: c_int, noalias act: *const Sigaction, noalias oact: ?*Sigaction) c_int; |
| 203 | pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; | 203 | pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; |
| 204 | pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int; | 204 | pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int; |
| 205 | pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int; | 205 | pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *libc_stat) c_int; |
| 206 | }, | 206 | }, |
| 207 | .windows => struct { | 207 | .windows => struct { |
| 208 | // TODO: copied the else case and removed the socket function (because its in ws2_32) | 208 | // TODO: copied the else case and removed the socket function (because its in ws2_32) |
| 209 | // need to verify which of these is actually supported on windows | 209 | // need to verify which of these is actually supported on windows |
| 210 | pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int; | 210 | pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int; |
| 211 | pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int; | 211 | pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int; |
| 212 | pub extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int; | 212 | pub extern "c" fn fstat(fd: fd_t, buf: *libc_stat) c_int; |
| 213 | pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int; | 213 | pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int; |
| 214 | pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int; | 214 | pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int; |
| 215 | pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int; | 215 | pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int; |
| 216 | pub extern "c" fn sched_yield() c_int; | 216 | pub extern "c" fn sched_yield() c_int; |
| 217 | pub extern "c" fn sigaction(sig: c_int, noalias act: *const Sigaction, noalias oact: ?*Sigaction) c_int; | 217 | pub extern "c" fn sigaction(sig: c_int, noalias act: *const Sigaction, noalias oact: ?*Sigaction) c_int; |
| 218 | pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; | 218 | pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; |
| 219 | pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int; | 219 | pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *libc_stat) c_int; |
| 220 | }, | 220 | }, |
| 221 | else => struct { | 221 | else => struct { |
| 222 | pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int; | 222 | pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int; |
| 223 | pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int; | 223 | pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int; |
| 224 | pub extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int; | 224 | pub extern "c" fn fstat(fd: fd_t, buf: *libc_stat) c_int; |
| 225 | pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int; | 225 | pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int; |
| 226 | pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int; | 226 | pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int; |
| 227 | pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int; | 227 | pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int; |
| ... | @@ -229,7 +229,7 @@ pub usingnamespace switch (builtin.os.tag) { | ... | @@ -229,7 +229,7 @@ pub usingnamespace switch (builtin.os.tag) { |
| 229 | pub extern "c" fn sigaction(sig: c_int, noalias act: *const Sigaction, noalias oact: ?*Sigaction) c_int; | 229 | pub extern "c" fn sigaction(sig: c_int, noalias act: *const Sigaction, noalias oact: ?*Sigaction) c_int; |
| 230 | pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; | 230 | pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int; |
| 231 | pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int; | 231 | pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int; |
| 232 | pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int; | 232 | pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *libc_stat) c_int; |
| 233 | }, | 233 | }, |
| 234 | }; | 234 | }; |
| 235 | 235 |
lib/std/c/darwin.zig+4-4| ... | @@ -30,16 +30,16 @@ pub extern "c" fn @"realpath$DARWIN_EXTSN"(noalias file_name: [*:0]const u8, noa | ... | @@ -30,16 +30,16 @@ pub extern "c" fn @"realpath$DARWIN_EXTSN"(noalias file_name: [*:0]const u8, noa |
| 30 | 30 | ||
| 31 | pub extern "c" fn __getdirentries64(fd: c_int, buf_ptr: [*]u8, buf_len: usize, basep: *i64) isize; | 31 | pub extern "c" fn __getdirentries64(fd: c_int, buf_ptr: [*]u8, buf_len: usize, basep: *i64) isize; |
| 32 | 32 | ||
| 33 | extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int; | 33 | extern "c" fn fstat(fd: fd_t, buf: *libc_stat) c_int; |
| 34 | /// On x86_64 Darwin, fstat has to be manully linked with $INODE64 suffix to force 64bit version. | 34 | /// On x86_64 Darwin, fstat has to be manully linked with $INODE64 suffix to force 64bit version. |
| 35 | /// Note that this is fixed on aarch64 and no longer necessary. | 35 | /// Note that this is fixed on aarch64 and no longer necessary. |
| 36 | extern "c" fn @"fstat$INODE64"(fd: fd_t, buf: *Stat) c_int; | 36 | extern "c" fn @"fstat$INODE64"(fd: fd_t, buf: *libc_stat) c_int; |
| 37 | pub const _fstat = if (builtin.arch == .aarch64) fstat else @"fstat$INODE64"; | 37 | pub const _fstat = if (builtin.arch == .aarch64) fstat else @"fstat$INODE64"; |
| 38 | 38 | ||
| 39 | extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *Stat, flags: u32) c_int; | 39 | extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *libc_stat, flags: u32) c_int; |
| 40 | /// On x86_64 Darwin, fstatat has to be manully linked with $INODE64 suffix to force 64bit version. | 40 | /// On x86_64 Darwin, fstatat has to be manully linked with $INODE64 suffix to force 64bit version. |
| 41 | /// Note that this is fixed on aarch64 and no longer necessary. | 41 | /// Note that this is fixed on aarch64 and no longer necessary. |
| 42 | extern "c" fn @"fstatat$INODE64"(dirfd: fd_t, path_name: [*:0]const u8, buf: *Stat, flags: u32) c_int; | 42 | extern "c" fn @"fstatat$INODE64"(dirfd: fd_t, path_name: [*:0]const u8, buf: *libc_stat, flags: u32) c_int; |
| 43 | pub const _fstatat = if (builtin.arch == .aarch64) fstatat else @"fstatat$INODE64"; | 43 | pub const _fstatat = if (builtin.arch == .aarch64) fstatat else @"fstatat$INODE64"; |
| 44 | 44 | ||
| 45 | pub extern "c" fn mach_absolute_time() u64; | 45 | pub extern "c" fn mach_absolute_time() u64; |
lib/std/os.zig+5| ... | @@ -3267,6 +3267,11 @@ pub fn waitpid(pid: pid_t, flags: u32) WaitPidResult { | ... | @@ -3267,6 +3267,11 @@ pub fn waitpid(pid: pid_t, flags: u32) WaitPidResult { |
| 3267 | } | 3267 | } |
| 3268 | } | 3268 | } |
| 3269 | 3269 | ||
| 3270 | pub const Stat = if (builtin.link_libc) | ||
| 3271 | system.libc_stat | ||
| 3272 | else | ||
| 3273 | system.kernel_stat; | ||
| 3274 | |||
| 3270 | pub const FStatError = error{ | 3275 | pub const FStatError = error{ |
| 3271 | SystemResources, | 3276 | SystemResources, |
| 3272 | 3277 |
lib/std/os/bits/darwin.zig+4-10| ... | @@ -72,13 +72,7 @@ pub const Flock = extern struct { | ... | @@ -72,13 +72,7 @@ pub const Flock = extern struct { |
| 72 | l_whence: i16, | 72 | l_whence: i16, |
| 73 | }; | 73 | }; |
| 74 | 74 | ||
| 75 | /// Renamed to Stat to not conflict with the stat function. | 75 | pub const libc_stat = extern struct { |
| 76 | /// atime, mtime, and ctime have functions to return `timespec`, | ||
| 77 | /// because although this is a POSIX API, the layout and names of | ||
| 78 | /// the structs are inconsistent across operating systems, and | ||
| 79 | /// in C, macros are used to hide the differences. Here we use | ||
| 80 | /// methods to accomplish this. | ||
| 81 | pub const Stat = extern struct { | ||
| 82 | dev: i32, | 76 | dev: i32, |
| 83 | mode: u16, | 77 | mode: u16, |
| 84 | nlink: u16, | 78 | nlink: u16, |
| ... | @@ -102,21 +96,21 @@ pub const Stat = extern struct { | ... | @@ -102,21 +96,21 @@ pub const Stat = extern struct { |
| 102 | lspare: i32, | 96 | lspare: i32, |
| 103 | qspare: [2]i64, | 97 | qspare: [2]i64, |
| 104 | 98 | ||
| 105 | pub fn atime(self: Stat) timespec { | 99 | pub fn atime(self: @This()) timespec { |
| 106 | return timespec{ | 100 | return timespec{ |
| 107 | .tv_sec = self.atimesec, | 101 | .tv_sec = self.atimesec, |
| 108 | .tv_nsec = self.atimensec, | 102 | .tv_nsec = self.atimensec, |
| 109 | }; | 103 | }; |
| 110 | } | 104 | } |
| 111 | 105 | ||
| 112 | pub fn mtime(self: Stat) timespec { | 106 | pub fn mtime(self: @This()) timespec { |
| 113 | return timespec{ | 107 | return timespec{ |
| 114 | .tv_sec = self.mtimesec, | 108 | .tv_sec = self.mtimesec, |
| 115 | .tv_nsec = self.mtimensec, | 109 | .tv_nsec = self.mtimensec, |
| 116 | }; | 110 | }; |
| 117 | } | 111 | } |
| 118 | 112 | ||
| 119 | pub fn ctime(self: Stat) timespec { | 113 | pub fn ctime(self: @This()) timespec { |
| 120 | return timespec{ | 114 | return timespec{ |
| 121 | .tv_sec = self.ctimesec, | 115 | .tv_sec = self.ctimesec, |
| 122 | .tv_nsec = self.ctimensec, | 116 | .tv_nsec = self.ctimensec, |
lib/std/os/bits/dragonfly.zig+4-4| ... | @@ -152,7 +152,7 @@ pub const PATH_MAX = 1024; | ... | @@ -152,7 +152,7 @@ pub const PATH_MAX = 1024; |
| 152 | 152 | ||
| 153 | pub const ino_t = c_ulong; | 153 | pub const ino_t = c_ulong; |
| 154 | 154 | ||
| 155 | pub const Stat = extern struct { | 155 | pub const libc_stat = extern struct { |
| 156 | ino: ino_t, | 156 | ino: ino_t, |
| 157 | nlink: c_uint, | 157 | nlink: c_uint, |
| 158 | dev: c_uint, | 158 | dev: c_uint, |
| ... | @@ -172,15 +172,15 @@ pub const Stat = extern struct { | ... | @@ -172,15 +172,15 @@ pub const Stat = extern struct { |
| 172 | lspare: i32, | 172 | lspare: i32, |
| 173 | qspare1: i64, | 173 | qspare1: i64, |
| 174 | qspare2: i64, | 174 | qspare2: i64, |
| 175 | pub fn atime(self: Stat) timespec { | 175 | pub fn atime(self: @This()) timespec { |
| 176 | return self.atim; | 176 | return self.atim; |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | pub fn mtime(self: Stat) timespec { | 179 | pub fn mtime(self: @This()) timespec { |
| 180 | return self.mtim; | 180 | return self.mtim; |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | pub fn ctime(self: Stat) timespec { | 183 | pub fn ctime(self: @This()) timespec { |
| 184 | return self.ctim; | 184 | return self.ctim; |
| 185 | } | 185 | } |
| 186 | }; | 186 | }; |
lib/std/os/bits/freebsd.zig+4-10| ... | @@ -119,13 +119,7 @@ pub const msghdr_const = extern struct { | ... | @@ -119,13 +119,7 @@ pub const msghdr_const = extern struct { |
| 119 | pub const off_t = i64; | 119 | pub const off_t = i64; |
| 120 | pub const ino_t = u64; | 120 | pub const ino_t = u64; |
| 121 | 121 | ||
| 122 | /// Renamed to Stat to not conflict with the stat function. | 122 | pub const libc_stat = extern struct { |
| 123 | /// atime, mtime, and ctime have functions to return `timespec`, | ||
| 124 | /// because although this is a POSIX API, the layout and names of | ||
| 125 | /// the structs are inconsistent across operating systems, and | ||
| 126 | /// in C, macros are used to hide the differences. Here we use | ||
| 127 | /// methods to accomplish this. | ||
| 128 | pub const Stat = extern struct { | ||
| 129 | dev: u64, | 123 | dev: u64, |
| 130 | ino: ino_t, | 124 | ino: ino_t, |
| 131 | nlink: usize, | 125 | nlink: usize, |
| ... | @@ -149,15 +143,15 @@ pub const Stat = extern struct { | ... | @@ -149,15 +143,15 @@ pub const Stat = extern struct { |
| 149 | gen: u64, | 143 | gen: u64, |
| 150 | __spare: [10]u64, | 144 | __spare: [10]u64, |
| 151 | 145 | ||
| 152 | pub fn atime(self: Stat) timespec { | 146 | pub fn atime(self: @This()) timespec { |
| 153 | return self.atim; | 147 | return self.atim; |
| 154 | } | 148 | } |
| 155 | 149 | ||
| 156 | pub fn mtime(self: Stat) timespec { | 150 | pub fn mtime(self: @This()) timespec { |
| 157 | return self.mtim; | 151 | return self.mtim; |
| 158 | } | 152 | } |
| 159 | 153 | ||
| 160 | pub fn ctime(self: Stat) timespec { | 154 | pub fn ctime(self: @This()) timespec { |
| 161 | return self.ctim; | 155 | return self.ctim; |
| 162 | } | 156 | } |
| 163 | }; | 157 | }; |
lib/std/os/bits/linux.zig+15-7| ... | @@ -1152,11 +1152,19 @@ pub const SS_ONSTACK = 1; | ... | @@ -1152,11 +1152,19 @@ pub const SS_ONSTACK = 1; |
| 1152 | pub const SS_DISABLE = 2; | 1152 | pub const SS_DISABLE = 2; |
| 1153 | pub const SS_AUTODISARM = 1 << 31; | 1153 | pub const SS_AUTODISARM = 1 << 31; |
| 1154 | 1154 | ||
| 1155 | pub const stack_t = extern struct { | 1155 | pub const stack_t = if (is_mips) |
| 1156 | ss_sp: [*]u8, | 1156 | // IRIX compatible stack_t |
| 1157 | ss_flags: i32, | 1157 | extern struct { |
| 1158 | ss_size: isize, | 1158 | ss_sp: [*]u8, |
| 1159 | }; | 1159 | ss_size: usize, |
| 1160 | ss_flags: i32, | ||
| 1161 | } | ||
| 1162 | else | ||
| 1163 | extern struct { | ||
| 1164 | ss_sp: [*]u8, | ||
| 1165 | ss_flags: i32, | ||
| 1166 | ss_size: usize, | ||
| 1167 | }; | ||
| 1160 | 1168 | ||
| 1161 | pub const sigval = extern union { | 1169 | pub const sigval = extern union { |
| 1162 | int: i32, | 1170 | int: i32, |
| ... | @@ -1322,7 +1330,7 @@ pub const io_uring_sqe = extern struct { | ... | @@ -1322,7 +1330,7 @@ pub const io_uring_sqe = extern struct { |
| 1322 | buf_index: u16, | 1330 | buf_index: u16, |
| 1323 | personality: u16, | 1331 | personality: u16, |
| 1324 | splice_fd_in: i32, | 1332 | splice_fd_in: i32, |
| 1325 | __pad2: [2]u64 | 1333 | __pad2: [2]u64, |
| 1326 | }; | 1334 | }; |
| 1327 | 1335 | ||
| 1328 | pub const IOSQE_BIT = extern enum(u8) { | 1336 | pub const IOSQE_BIT = extern enum(u8) { |
| ... | @@ -1332,7 +1340,7 @@ pub const IOSQE_BIT = extern enum(u8) { | ... | @@ -1332,7 +1340,7 @@ pub const IOSQE_BIT = extern enum(u8) { |
| 1332 | IO_HARDLINK, | 1340 | IO_HARDLINK, |
| 1333 | ASYNC, | 1341 | ASYNC, |
| 1334 | BUFFER_SELECT, | 1342 | BUFFER_SELECT, |
| 1335 | 1343 | ||
| 1336 | _, | 1344 | _, |
| 1337 | }; | 1345 | }; |
| 1338 | 1346 |
lib/std/os/bits/linux/arm-eabi.zig+8-10| ... | @@ -553,13 +553,8 @@ pub const ino_t = u64; | ... | @@ -553,13 +553,8 @@ pub const ino_t = u64; |
| 553 | pub const dev_t = u64; | 553 | pub const dev_t = u64; |
| 554 | pub const blkcnt_t = i64; | 554 | pub const blkcnt_t = i64; |
| 555 | 555 | ||
| 556 | /// Renamed to Stat to not conflict with the stat function. | 556 | // The `stat` definition used by the Linux kernel. |
| 557 | /// atime, mtime, and ctime have functions to return `timespec`, | 557 | pub const kernel_stat = extern struct { |
| 558 | /// because although this is a POSIX API, the layout and names of | ||
| 559 | /// the structs are inconsistent across operating systems, and | ||
| 560 | /// in C, macros are used to hide the differences. Here we use | ||
| 561 | /// methods to accomplish this. | ||
| 562 | pub const Stat = extern struct { | ||
| 563 | dev: dev_t, | 558 | dev: dev_t, |
| 564 | __dev_padding: u32, | 559 | __dev_padding: u32, |
| 565 | __ino_truncated: u32, | 560 | __ino_truncated: u32, |
| ... | @@ -577,19 +572,22 @@ pub const Stat = extern struct { | ... | @@ -577,19 +572,22 @@ pub const Stat = extern struct { |
| 577 | ctim: timespec, | 572 | ctim: timespec, |
| 578 | ino: ino_t, | 573 | ino: ino_t, |
| 579 | 574 | ||
| 580 | pub fn atime(self: Stat) timespec { | 575 | pub fn atime(self: @This()) timespec { |
| 581 | return self.atim; | 576 | return self.atim; |
| 582 | } | 577 | } |
| 583 | 578 | ||
| 584 | pub fn mtime(self: Stat) timespec { | 579 | pub fn mtime(self: @This()) timespec { |
| 585 | return self.mtim; | 580 | return self.mtim; |
| 586 | } | 581 | } |
| 587 | 582 | ||
| 588 | pub fn ctime(self: Stat) timespec { | 583 | pub fn ctime(self: @This()) timespec { |
| 589 | return self.ctim; | 584 | return self.ctim; |
| 590 | } | 585 | } |
| 591 | }; | 586 | }; |
| 592 | 587 | ||
| 588 | // The `stat64` definition used by the libc. | ||
| 589 | pub const libc_stat = kernel_stat; | ||
| 590 | |||
| 593 | pub const timespec = extern struct { | 591 | pub const timespec = extern struct { |
| 594 | tv_sec: i32, | 592 | tv_sec: i32, |
| 595 | tv_nsec: i32, | 593 | tv_nsec: i32, |
lib/std/os/bits/linux/arm64.zig+8-10| ... | @@ -424,13 +424,8 @@ pub const ino_t = usize; | ... | @@ -424,13 +424,8 @@ pub const ino_t = usize; |
| 424 | pub const dev_t = usize; | 424 | pub const dev_t = usize; |
| 425 | pub const blkcnt_t = isize; | 425 | pub const blkcnt_t = isize; |
| 426 | 426 | ||
| 427 | /// Renamed to Stat to not conflict with the stat function. | 427 | // The `stat` definition used by the Linux kernel. |
| 428 | /// atime, mtime, and ctime have functions to return `timespec`, | 428 | pub const kernel_stat = extern struct { |
| 429 | /// because although this is a POSIX API, the layout and names of | ||
| 430 | /// the structs are inconsistent across operating systems, and | ||
| 431 | /// in C, macros are used to hide the differences. Here we use | ||
| 432 | /// methods to accomplish this. | ||
| 433 | pub const Stat = extern struct { | ||
| 434 | dev: dev_t, | 429 | dev: dev_t, |
| 435 | ino: ino_t, | 430 | ino: ino_t, |
| 436 | mode: mode_t, | 431 | mode: mode_t, |
| ... | @@ -448,19 +443,22 @@ pub const Stat = extern struct { | ... | @@ -448,19 +443,22 @@ pub const Stat = extern struct { |
| 448 | ctim: timespec, | 443 | ctim: timespec, |
| 449 | __unused: [2]u32, | 444 | __unused: [2]u32, |
| 450 | 445 | ||
| 451 | pub fn atime(self: Stat) timespec { | 446 | pub fn atime(self: @This()) timespec { |
| 452 | return self.atim; | 447 | return self.atim; |
| 453 | } | 448 | } |
| 454 | 449 | ||
| 455 | pub fn mtime(self: Stat) timespec { | 450 | pub fn mtime(self: @This()) timespec { |
| 456 | return self.mtim; | 451 | return self.mtim; |
| 457 | } | 452 | } |
| 458 | 453 | ||
| 459 | pub fn ctime(self: Stat) timespec { | 454 | pub fn ctime(self: @This()) timespec { |
| 460 | return self.ctim; | 455 | return self.ctim; |
| 461 | } | 456 | } |
| 462 | }; | 457 | }; |
| 463 | 458 | ||
| 459 | // The `stat64` definition used by the libc. | ||
| 460 | pub const libc_stat = kernel_stat; | ||
| 461 | |||
| 464 | pub const timespec = extern struct { | 462 | pub const timespec = extern struct { |
| 465 | tv_sec: time_t, | 463 | tv_sec: time_t, |
| 466 | tv_nsec: isize, | 464 | tv_nsec: isize, |
lib/std/os/bits/linux/i386.zig+8-10| ... | @@ -546,13 +546,8 @@ pub const ino_t = u64; | ... | @@ -546,13 +546,8 @@ pub const ino_t = u64; |
| 546 | pub const dev_t = u64; | 546 | pub const dev_t = u64; |
| 547 | pub const blkcnt_t = i64; | 547 | pub const blkcnt_t = i64; |
| 548 | 548 | ||
| 549 | /// Renamed to Stat to not conflict with the stat function. | 549 | // The `stat` definition used by the Linux kernel. |
| 550 | /// atime, mtime, and ctime have functions to return `timespec`, | 550 | pub const kernel_stat = extern struct { |
| 551 | /// because although this is a POSIX API, the layout and names of | ||
| 552 | /// the structs are inconsistent across operating systems, and | ||
| 553 | /// in C, macros are used to hide the differences. Here we use | ||
| 554 | /// methods to accomplish this. | ||
| 555 | pub const Stat = extern struct { | ||
| 556 | dev: dev_t, | 551 | dev: dev_t, |
| 557 | __dev_padding: u32, | 552 | __dev_padding: u32, |
| 558 | __ino_truncated: u32, | 553 | __ino_truncated: u32, |
| ... | @@ -570,19 +565,22 @@ pub const Stat = extern struct { | ... | @@ -570,19 +565,22 @@ pub const Stat = extern struct { |
| 570 | ctim: timespec, | 565 | ctim: timespec, |
| 571 | ino: ino_t, | 566 | ino: ino_t, |
| 572 | 567 | ||
| 573 | pub fn atime(self: Stat) timespec { | 568 | pub fn atime(self: @This()) timespec { |
| 574 | return self.atim; | 569 | return self.atim; |
| 575 | } | 570 | } |
| 576 | 571 | ||
| 577 | pub fn mtime(self: Stat) timespec { | 572 | pub fn mtime(self: @This()) timespec { |
| 578 | return self.mtim; | 573 | return self.mtim; |
| 579 | } | 574 | } |
| 580 | 575 | ||
| 581 | pub fn ctime(self: Stat) timespec { | 576 | pub fn ctime(self: @This()) timespec { |
| 582 | return self.ctim; | 577 | return self.ctim; |
| 583 | } | 578 | } |
| 584 | }; | 579 | }; |
| 585 | 580 | ||
| 581 | // The `stat64` definition used by the libc. | ||
| 582 | pub const libc_stat = kernel_stat; | ||
| 583 | |||
| 586 | pub const timespec = extern struct { | 584 | pub const timespec = extern struct { |
| 587 | tv_sec: i32, | 585 | tv_sec: i32, |
| 588 | tv_nsec: i32, | 586 | tv_nsec: i32, |
lib/std/os/bits/linux/mips.zig+42-9| ... | @@ -536,41 +536,74 @@ pub const Flock = extern struct { | ... | @@ -536,41 +536,74 @@ pub const Flock = extern struct { |
| 536 | 536 | ||
| 537 | pub const blksize_t = i32; | 537 | pub const blksize_t = i32; |
| 538 | pub const nlink_t = u32; | 538 | pub const nlink_t = u32; |
| 539 | pub const time_t = isize; | 539 | pub const time_t = i32; |
| 540 | pub const mode_t = u32; | 540 | pub const mode_t = u32; |
| 541 | pub const off_t = i64; | 541 | pub const off_t = i64; |
| 542 | pub const ino_t = u64; | 542 | pub const ino_t = u64; |
| 543 | pub const dev_t = usize; | 543 | pub const dev_t = u64; |
| 544 | pub const blkcnt_t = i64; | 544 | pub const blkcnt_t = i64; |
| 545 | 545 | ||
| 546 | pub const Stat = extern struct { | 546 | // The `stat` definition used by the Linux kernel. |
| 547 | pub const kernel_stat = extern struct { | ||
| 547 | dev: u32, | 548 | dev: u32, |
| 548 | __pad0: [3]u32, | 549 | __pad0: [3]u32, // Reserved for st_dev expansion |
| 549 | ino: ino_t, | 550 | ino: ino_t, |
| 550 | mode: mode_t, | 551 | mode: mode_t, |
| 551 | nlink: nlink_t, | 552 | nlink: nlink_t, |
| 552 | uid: uid_t, | 553 | uid: uid_t, |
| 553 | gid: gid_t, | 554 | gid: gid_t, |
| 554 | rdev: dev_t, | 555 | rdev: u32, |
| 555 | __pad1: [3]u32, | 556 | __pad1: [3]u32, |
| 556 | size: off_t, | 557 | size: off_t, |
| 557 | atim: timespec, | 558 | atim: timespec, |
| 558 | mtim: timespec, | 559 | mtim: timespec, |
| 559 | ctim: timespec, | 560 | ctim: timespec, |
| 560 | blksize: blksize_t, | 561 | blksize: blksize_t, |
| 561 | __pad3: [1]u32, | 562 | __pad3: u32, |
| 562 | blocks: blkcnt_t, | 563 | blocks: blkcnt_t, |
| 563 | __pad4: [14]usize, | 564 | __pad4: [14]usize, |
| 564 | 565 | ||
| 565 | pub fn atime(self: Stat) timespec { | 566 | pub fn atime(self: @This()) timespec { |
| 567 | return self.atim; | ||
| 568 | } | ||
| 569 | |||
| 570 | pub fn mtime(self: @This()) timespec { | ||
| 571 | return self.mtim; | ||
| 572 | } | ||
| 573 | |||
| 574 | pub fn ctime(self: @This()) timespec { | ||
| 575 | return self.ctim; | ||
| 576 | } | ||
| 577 | }; | ||
| 578 | |||
| 579 | pub const libc_stat = extern struct { | ||
| 580 | dev: dev_t, | ||
| 581 | __pad0: [2]u32, | ||
| 582 | ino: ino_t, | ||
| 583 | mode: mode_t, | ||
| 584 | nlink: nlink_t, | ||
| 585 | uid: uid_t, | ||
| 586 | gid: gid_t, | ||
| 587 | rdev: dev_t, | ||
| 588 | __pad1: [2]u32, | ||
| 589 | size: off_t, | ||
| 590 | atim: timespec, | ||
| 591 | mtim: timespec, | ||
| 592 | ctim: timespec, | ||
| 593 | blksize: blksize_t, | ||
| 594 | __pad3: u32, | ||
| 595 | blocks: blkcnt_t, | ||
| 596 | __pad4: [14]u32, | ||
| 597 | |||
| 598 | pub fn atime(self: @This()) timespec { | ||
| 566 | return self.atim; | 599 | return self.atim; |
| 567 | } | 600 | } |
| 568 | 601 | ||
| 569 | pub fn mtime(self: Stat) timespec { | 602 | pub fn mtime(self: @This()) timespec { |
| 570 | return self.mtim; | 603 | return self.mtim; |
| 571 | } | 604 | } |
| 572 | 605 | ||
| 573 | pub fn ctime(self: Stat) timespec { | 606 | pub fn ctime(self: @This()) timespec { |
| 574 | return self.ctim; | 607 | return self.ctim; |
| 575 | } | 608 | } |
| 576 | }; | 609 | }; |
lib/std/os/bits/linux/powerpc64.zig+8-10| ... | @@ -516,13 +516,8 @@ pub const ino_t = u64; | ... | @@ -516,13 +516,8 @@ pub const ino_t = u64; |
| 516 | pub const dev_t = u64; | 516 | pub const dev_t = u64; |
| 517 | pub const blkcnt_t = i64; | 517 | pub const blkcnt_t = i64; |
| 518 | 518 | ||
| 519 | /// Renamed to Stat to not conflict with the stat function. | 519 | // The `stat` definition used by the Linux kernel. |
| 520 | /// atime, mtime, and ctime have functions to return `timespec`, | 520 | pub const kernel_stat = extern struct { |
| 521 | /// because although this is a POSIX API, the layout and names of | ||
| 522 | /// the structs are inconsistent across operating systems, and | ||
| 523 | /// in C, macros are used to hide the differences. Here we use | ||
| 524 | /// methods to accomplish this. | ||
| 525 | pub const Stat = extern struct { | ||
| 526 | dev: dev_t, | 521 | dev: dev_t, |
| 527 | ino: ino_t, | 522 | ino: ino_t, |
| 528 | nlink: nlink_t, | 523 | nlink: nlink_t, |
| ... | @@ -538,19 +533,22 @@ pub const Stat = extern struct { | ... | @@ -538,19 +533,22 @@ pub const Stat = extern struct { |
| 538 | ctim: timespec, | 533 | ctim: timespec, |
| 539 | __unused: [3]u64, | 534 | __unused: [3]u64, |
| 540 | 535 | ||
| 541 | pub fn atime(self: Stat) timespec { | 536 | pub fn atime(self: @This()) timespec { |
| 542 | return self.atim; | 537 | return self.atim; |
| 543 | } | 538 | } |
| 544 | 539 | ||
| 545 | pub fn mtime(self: Stat) timespec { | 540 | pub fn mtime(self: @This()) timespec { |
| 546 | return self.mtim; | 541 | return self.mtim; |
| 547 | } | 542 | } |
| 548 | 543 | ||
| 549 | pub fn ctime(self: Stat) timespec { | 544 | pub fn ctime(self: @This()) timespec { |
| 550 | return self.ctim; | 545 | return self.ctim; |
| 551 | } | 546 | } |
| 552 | }; | 547 | }; |
| 553 | 548 | ||
| 549 | // The `stat64` definition used by the libc. | ||
| 550 | pub const libc_stat = kernel_stat; | ||
| 551 | |||
| 554 | pub const timespec = extern struct { | 552 | pub const timespec = extern struct { |
| 555 | tv_sec: time_t, | 553 | tv_sec: time_t, |
| 556 | tv_nsec: isize, | 554 | tv_nsec: isize, |
lib/std/os/bits/linux/riscv64.zig+8-10| ... | @@ -381,13 +381,8 @@ pub const Flock = extern struct { | ... | @@ -381,13 +381,8 @@ pub const Flock = extern struct { |
| 381 | __unused: [4]u8, | 381 | __unused: [4]u8, |
| 382 | }; | 382 | }; |
| 383 | 383 | ||
| 384 | /// Renamed to Stat to not conflict with the stat function. | 384 | // The `stat` definition used by the Linux kernel. |
| 385 | /// atime, mtime, and ctime have functions to return `timespec`, | 385 | pub const kernel_stat = extern struct { |
| 386 | /// because although this is a POSIX API, the layout and names of | ||
| 387 | /// the structs are inconsistent across operating systems, and | ||
| 388 | /// in C, macros are used to hide the differences. Here we use | ||
| 389 | /// methods to accomplish this. | ||
| 390 | pub const Stat = extern struct { | ||
| 391 | dev: dev_t, | 386 | dev: dev_t, |
| 392 | ino: ino_t, | 387 | ino: ino_t, |
| 393 | mode: mode_t, | 388 | mode: mode_t, |
| ... | @@ -405,17 +400,20 @@ pub const Stat = extern struct { | ... | @@ -405,17 +400,20 @@ pub const Stat = extern struct { |
| 405 | ctim: timespec, | 400 | ctim: timespec, |
| 406 | __unused: [2]u32, | 401 | __unused: [2]u32, |
| 407 | 402 | ||
| 408 | pub fn atime(self: Stat) timespec { | 403 | pub fn atime(self: @This()) timespec { |
| 409 | return self.atim; | 404 | return self.atim; |
| 410 | } | 405 | } |
| 411 | 406 | ||
| 412 | pub fn mtime(self: Stat) timespec { | 407 | pub fn mtime(self: @This()) timespec { |
| 413 | return self.mtim; | 408 | return self.mtim; |
| 414 | } | 409 | } |
| 415 | 410 | ||
| 416 | pub fn ctime(self: Stat) timespec { | 411 | pub fn ctime(self: @This()) timespec { |
| 417 | return self.ctim; | 412 | return self.ctim; |
| 418 | } | 413 | } |
| 419 | }; | 414 | }; |
| 420 | 415 | ||
| 416 | // The `stat64` definition used by the libc. | ||
| 417 | pub const libc_stat = kernel_stat; | ||
| 418 | |||
| 421 | pub const Elf_Symndx = u32; | 419 | pub const Elf_Symndx = u32; |
lib/std/os/bits/linux/sparc64.zig+21-30| ... | @@ -484,11 +484,7 @@ pub const off_t = i64; | ... | @@ -484,11 +484,7 @@ pub const off_t = i64; |
| 484 | pub const ino_t = u64; | 484 | pub const ino_t = u64; |
| 485 | pub const mode_t = u32; | 485 | pub const mode_t = u32; |
| 486 | 486 | ||
| 487 | /// atime, mtime, and ctime have functions to return `timespec`, | 487 | // The `stat64` definition used by the libc. |
| 488 | /// because although this is a POSIX API, the layout and names of | ||
| 489 | /// the structs are inconsistent across operating systems, and | ||
| 490 | /// in C, macros are used to hide the differences. Here we use | ||
| 491 | /// methods to accomplish this. | ||
| 492 | pub const libc_stat = extern struct { | 488 | pub const libc_stat = extern struct { |
| 493 | dev: u64, | 489 | dev: u64, |
| 494 | ino: ino_t, | 490 | ino: ino_t, |
| ... | @@ -522,45 +518,40 @@ pub const libc_stat = extern struct { | ... | @@ -522,45 +518,40 @@ pub const libc_stat = extern struct { |
| 522 | } | 518 | } |
| 523 | }; | 519 | }; |
| 524 | 520 | ||
| 521 | // The `stat64` definition used by the kernel. | ||
| 525 | pub const kernel_stat = extern struct { | 522 | pub const kernel_stat = extern struct { |
| 526 | dev: u32, | 523 | dev: u64, |
| 527 | ino: ino_t, | 524 | ino: u64, |
| 528 | mode: mode_t, | 525 | nlink: u64, |
| 529 | nlink: i16, | ||
| 530 | 526 | ||
| 527 | mode: u32, | ||
| 531 | uid: u32, | 528 | uid: u32, |
| 532 | gid: u32, | 529 | gid: u32, |
| 533 | rdev: u32, | 530 | __pad0: u32, |
| 534 | |||
| 535 | size: off_t, | ||
| 536 | atim: isize, | ||
| 537 | mtim: isize, | ||
| 538 | ctim: isize, | ||
| 539 | 531 | ||
| 540 | blksize: off_t, | 532 | rdev: u64, |
| 541 | blocks: off_t, | 533 | size: i64, |
| 534 | blksize: i64, | ||
| 535 | blocks: i64, | ||
| 542 | 536 | ||
| 543 | __unused4: [2]isize, | 537 | atim: timespec, |
| 538 | mtim: timespec, | ||
| 539 | ctim: timespec, | ||
| 540 | __unused: [3]u64, | ||
| 544 | 541 | ||
| 545 | // Hack to make the stdlib not complain about atime | 542 | pub fn atime(self: @This()) timespec { |
| 546 | // and friends not being a method. | 543 | return self.atim; |
| 547 | // TODO what should tv_nsec be filled with? | ||
| 548 | pub fn atime(self: kernel_stat) timespec { | ||
| 549 | return timespec{.tv_sec=self.atim, .tv_nsec=0}; | ||
| 550 | } | 544 | } |
| 551 | 545 | ||
| 552 | pub fn mtime(self: kernel_stat) timespec { | 546 | pub fn mtime(self: @This()) timespec { |
| 553 | return timespec{.tv_sec=self.mtim, .tv_nsec=0}; | 547 | return self.mtim; |
| 554 | } | 548 | } |
| 555 | 549 | ||
| 556 | pub fn ctime(self: kernel_stat) timespec { | 550 | pub fn ctime(self: @This()) timespec { |
| 557 | return timespec{.tv_sec=self.ctim, .tv_nsec=0}; | 551 | return self.ctim; |
| 558 | } | 552 | } |
| 559 | }; | 553 | }; |
| 560 | 554 | ||
| 561 | /// Renamed to Stat to not conflict with the stat function. | ||
| 562 | pub const Stat = if (std.builtin.link_libc) libc_stat else kernel_stat; | ||
| 563 | |||
| 564 | pub const timespec = extern struct { | 555 | pub const timespec = extern struct { |
| 565 | tv_sec: isize, | 556 | tv_sec: isize, |
| 566 | tv_nsec: isize, | 557 | tv_nsec: isize, |
lib/std/os/bits/linux/x86_64.zig+8-10| ... | @@ -512,13 +512,8 @@ pub const msghdr_const = extern struct { | ... | @@ -512,13 +512,8 @@ pub const msghdr_const = extern struct { |
| 512 | pub const off_t = i64; | 512 | pub const off_t = i64; |
| 513 | pub const ino_t = u64; | 513 | pub const ino_t = u64; |
| 514 | 514 | ||
| 515 | /// Renamed to Stat to not conflict with the stat function. | 515 | // The `stat` definition used by the Linux kernel. |
| 516 | /// atime, mtime, and ctime have functions to return `timespec`, | 516 | pub const kernel_stat = extern struct { |
| 517 | /// because although this is a POSIX API, the layout and names of | ||
| 518 | /// the structs are inconsistent across operating systems, and | ||
| 519 | /// in C, macros are used to hide the differences. Here we use | ||
| 520 | /// methods to accomplish this. | ||
| 521 | pub const Stat = extern struct { | ||
| 522 | dev: u64, | 517 | dev: u64, |
| 523 | ino: ino_t, | 518 | ino: ino_t, |
| 524 | nlink: usize, | 519 | nlink: usize, |
| ... | @@ -537,19 +532,22 @@ pub const Stat = extern struct { | ... | @@ -537,19 +532,22 @@ pub const Stat = extern struct { |
| 537 | ctim: timespec, | 532 | ctim: timespec, |
| 538 | __unused: [3]isize, | 533 | __unused: [3]isize, |
| 539 | 534 | ||
| 540 | pub fn atime(self: Stat) timespec { | 535 | pub fn atime(self: @This()) timespec { |
| 541 | return self.atim; | 536 | return self.atim; |
| 542 | } | 537 | } |
| 543 | 538 | ||
| 544 | pub fn mtime(self: Stat) timespec { | 539 | pub fn mtime(self: @This()) timespec { |
| 545 | return self.mtim; | 540 | return self.mtim; |
| 546 | } | 541 | } |
| 547 | 542 | ||
| 548 | pub fn ctime(self: Stat) timespec { | 543 | pub fn ctime(self: @This()) timespec { |
| 549 | return self.ctim; | 544 | return self.ctim; |
| 550 | } | 545 | } |
| 551 | }; | 546 | }; |
| 552 | 547 | ||
| 548 | // The `stat64` definition used by the libc. | ||
| 549 | pub const libc_stat = kernel_stat; | ||
| 550 | |||
| 553 | pub const timespec = extern struct { | 551 | pub const timespec = extern struct { |
| 554 | tv_sec: isize, | 552 | tv_sec: isize, |
| 555 | tv_nsec: isize, | 553 | tv_nsec: isize, |
lib/std/os/bits/netbsd.zig+4-10| ... | @@ -153,13 +153,7 @@ pub const msghdr_const = extern struct { | ... | @@ -153,13 +153,7 @@ pub const msghdr_const = extern struct { |
| 153 | msg_flags: i32, | 153 | msg_flags: i32, |
| 154 | }; | 154 | }; |
| 155 | 155 | ||
| 156 | /// Renamed to Stat to not conflict with the stat function. | 156 | pub const libc_stat = extern struct { |
| 157 | /// atime, mtime, and ctime have functions to return `timespec`, | ||
| 158 | /// because although this is a POSIX API, the layout and names of | ||
| 159 | /// the structs are inconsistent across operating systems, and | ||
| 160 | /// in C, macros are used to hide the differences. Here we use | ||
| 161 | /// methods to accomplish this. | ||
| 162 | pub const Stat = extern struct { | ||
| 163 | dev: dev_t, | 157 | dev: dev_t, |
| 164 | mode: mode_t, | 158 | mode: mode_t, |
| 165 | ino: ino_t, | 159 | ino: ino_t, |
| ... | @@ -178,15 +172,15 @@ pub const Stat = extern struct { | ... | @@ -178,15 +172,15 @@ pub const Stat = extern struct { |
| 178 | gen: u32, | 172 | gen: u32, |
| 179 | __spare: [2]u32, | 173 | __spare: [2]u32, |
| 180 | 174 | ||
| 181 | pub fn atime(self: Stat) timespec { | 175 | pub fn atime(self: @This()) timespec { |
| 182 | return self.atim; | 176 | return self.atim; |
| 183 | } | 177 | } |
| 184 | 178 | ||
| 185 | pub fn mtime(self: Stat) timespec { | 179 | pub fn mtime(self: @This()) timespec { |
| 186 | return self.mtim; | 180 | return self.mtim; |
| 187 | } | 181 | } |
| 188 | 182 | ||
| 189 | pub fn ctime(self: Stat) timespec { | 183 | pub fn ctime(self: @This()) timespec { |
| 190 | return self.ctim; | 184 | return self.ctim; |
| 191 | } | 185 | } |
| 192 | }; | 186 | }; |
lib/std/os/bits/openbsd.zig+4-10| ... | @@ -152,13 +152,7 @@ pub const msghdr_const = extern struct { | ... | @@ -152,13 +152,7 @@ pub const msghdr_const = extern struct { |
| 152 | msg_flags: i32, | 152 | msg_flags: i32, |
| 153 | }; | 153 | }; |
| 154 | 154 | ||
| 155 | /// Renamed to Stat to not conflict with the stat function. | 155 | pub const libc_stat = extern struct { |
| 156 | /// atime, mtime, and ctime have functions to return `timespec`, | ||
| 157 | /// because although this is a POSIX API, the layout and names of | ||
| 158 | /// the structs are inconsistent across operating systems, and | ||
| 159 | /// in C, macros are used to hide the differences. Here we use | ||
| 160 | /// methods to accomplish this. | ||
| 161 | pub const Stat = extern struct { | ||
| 162 | mode: mode_t, | 156 | mode: mode_t, |
| 163 | dev: dev_t, | 157 | dev: dev_t, |
| 164 | ino: ino_t, | 158 | ino: ino_t, |
| ... | @@ -176,15 +170,15 @@ pub const Stat = extern struct { | ... | @@ -176,15 +170,15 @@ pub const Stat = extern struct { |
| 176 | gen: u32, | 170 | gen: u32, |
| 177 | birthtim: timespec, | 171 | birthtim: timespec, |
| 178 | 172 | ||
| 179 | pub fn atime(self: Stat) timespec { | 173 | pub fn atime(self: @This()) timespec { |
| 180 | return self.atim; | 174 | return self.atim; |
| 181 | } | 175 | } |
| 182 | 176 | ||
| 183 | pub fn mtime(self: Stat) timespec { | 177 | pub fn mtime(self: @This()) timespec { |
| 184 | return self.mtim; | 178 | return self.mtim; |
| 185 | } | 179 | } |
| 186 | 180 | ||
| 187 | pub fn ctime(self: Stat) timespec { | 181 | pub fn ctime(self: @This()) timespec { |
| 188 | return self.ctim; | 182 | return self.ctim; |
| 189 | } | 183 | } |
| 190 | }; | 184 | }; |
lib/std/os/bits/wasi.zig+1-1| ... | @@ -31,7 +31,7 @@ pub const timespec = struct { | ... | @@ -31,7 +31,7 @@ pub const timespec = struct { |
| 31 | } | 31 | } |
| 32 | }; | 32 | }; |
| 33 | 33 | ||
| 34 | pub const Stat = struct { | 34 | pub const kernel_stat = struct { |
| 35 | dev: device_t, | 35 | dev: device_t, |
| 36 | ino: inode_t, | 36 | ino: inode_t, |
| 37 | mode: mode_t, | 37 | mode: mode_t, |
lib/std/os/linux.zig+4-4| ... | @@ -1071,7 +1071,7 @@ pub fn accept4(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flag | ... | @@ -1071,7 +1071,7 @@ pub fn accept4(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flag |
| 1071 | return syscall4(.accept4, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags); | 1071 | return syscall4(.accept4, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags); |
| 1072 | } | 1072 | } |
| 1073 | 1073 | ||
| 1074 | pub fn fstat(fd: i32, stat_buf: *Stat) usize { | 1074 | pub fn fstat(fd: i32, stat_buf: *kernel_stat) usize { |
| 1075 | if (@hasField(SYS, "fstat64")) { | 1075 | if (@hasField(SYS, "fstat64")) { |
| 1076 | return syscall2(.fstat64, @bitCast(usize, @as(isize, fd)), @ptrToInt(stat_buf)); | 1076 | return syscall2(.fstat64, @bitCast(usize, @as(isize, fd)), @ptrToInt(stat_buf)); |
| 1077 | } else { | 1077 | } else { |
| ... | @@ -1079,7 +1079,7 @@ pub fn fstat(fd: i32, stat_buf: *Stat) usize { | ... | @@ -1079,7 +1079,7 @@ pub fn fstat(fd: i32, stat_buf: *Stat) usize { |
| 1079 | } | 1079 | } |
| 1080 | } | 1080 | } |
| 1081 | 1081 | ||
| 1082 | pub fn stat(pathname: [*:0]const u8, statbuf: *Stat) usize { | 1082 | pub fn stat(pathname: [*:0]const u8, statbuf: *kernel_stat) usize { |
| 1083 | if (@hasField(SYS, "stat64")) { | 1083 | if (@hasField(SYS, "stat64")) { |
| 1084 | return syscall2(.stat64, @ptrToInt(pathname), @ptrToInt(statbuf)); | 1084 | return syscall2(.stat64, @ptrToInt(pathname), @ptrToInt(statbuf)); |
| 1085 | } else { | 1085 | } else { |
| ... | @@ -1087,7 +1087,7 @@ pub fn stat(pathname: [*:0]const u8, statbuf: *Stat) usize { | ... | @@ -1087,7 +1087,7 @@ pub fn stat(pathname: [*:0]const u8, statbuf: *Stat) usize { |
| 1087 | } | 1087 | } |
| 1088 | } | 1088 | } |
| 1089 | 1089 | ||
| 1090 | pub fn lstat(pathname: [*:0]const u8, statbuf: *Stat) usize { | 1090 | pub fn lstat(pathname: [*:0]const u8, statbuf: *kernel_stat) usize { |
| 1091 | if (@hasField(SYS, "lstat64")) { | 1091 | if (@hasField(SYS, "lstat64")) { |
| 1092 | return syscall2(.lstat64, @ptrToInt(pathname), @ptrToInt(statbuf)); | 1092 | return syscall2(.lstat64, @ptrToInt(pathname), @ptrToInt(statbuf)); |
| 1093 | } else { | 1093 | } else { |
| ... | @@ -1095,7 +1095,7 @@ pub fn lstat(pathname: [*:0]const u8, statbuf: *Stat) usize { | ... | @@ -1095,7 +1095,7 @@ pub fn lstat(pathname: [*:0]const u8, statbuf: *Stat) usize { |
| 1095 | } | 1095 | } |
| 1096 | } | 1096 | } |
| 1097 | 1097 | ||
| 1098 | pub fn fstatat(dirfd: i32, path: [*:0]const u8, stat_buf: *Stat, flags: u32) usize { | 1098 | pub fn fstatat(dirfd: i32, path: [*:0]const u8, stat_buf: *kernel_stat, flags: u32) usize { |
| 1099 | if (@hasField(SYS, "fstatat64")) { | 1099 | if (@hasField(SYS, "fstatat64")) { |
| 1100 | return syscall4(.fstatat64, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags); | 1100 | return syscall4(.fstatat64, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(stat_buf), flags); |
| 1101 | } else { | 1101 | } else { |
lib/std/os/linux/sparc64.zig+11-9| ... | @@ -2,20 +2,22 @@ usingnamespace @import("../bits.zig"); | ... | @@ -2,20 +2,22 @@ usingnamespace @import("../bits.zig"); |
| 2 | 2 | ||
| 3 | pub fn syscall_pipe(fd: *[2]i32) usize { | 3 | pub fn syscall_pipe(fd: *[2]i32) usize { |
| 4 | return asm volatile ( | 4 | return asm volatile ( |
| 5 | \\ mov %%o0, %%o2 | 5 | \\ mov %[arg], %%g3 |
| 6 | \\ t 0x6d | 6 | \\ t 0x6d |
| 7 | \\ bcc,pt %%xcc, 1f | 7 | \\ bcc,pt %%xcc, 1f |
| 8 | \\ nop | 8 | \\ nop |
| 9 | \\ # Return the error code | ||
| 9 | \\ ba 2f | 10 | \\ ba 2f |
| 10 | \\ neg %%o0 | 11 | \\ neg %%o0 |
| 11 | \\ 1: | 12 | \\1: |
| 12 | \\ st %%o0, [%%o2] | 13 | \\ st %%o0, [%%g3+0] |
| 13 | \\ st %%o1, [%%o2 + 4] | 14 | \\ st %%o1, [%%g3+4] |
| 14 | \\ clr %%o0 | 15 | \\ clr %%o0 |
| 15 | \\ 2: | 16 | \\2: |
| 16 | : [ret] "={o0}" (-> usize) | 17 | : [ret] "={o0}" (-> usize) |
| 17 | : [number] "{$2}" (@enumToInt(SYS.pipe)) | 18 | : [number] "{g1}" (@enumToInt(SYS.pipe)), |
| 18 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" | 19 | [arg] "r" (fd) |
| 20 | : "memory", "g3" | ||
| 19 | ); | 21 | ); |
| 20 | } | 22 | } |
| 21 | 23 | ||
| ... | @@ -107,7 +109,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, | ... | @@ -107,7 +109,7 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, |
| 107 | [arg2] "{o1}" (arg2), | 109 | [arg2] "{o1}" (arg2), |
| 108 | [arg3] "{o2}" (arg3), | 110 | [arg3] "{o2}" (arg3), |
| 109 | [arg4] "{o3}" (arg4), | 111 | [arg4] "{o3}" (arg4), |
| 110 | [arg5] "{o4}" (arg5), | 112 | [arg5] "{o4}" (arg5) |
| 111 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" | 113 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" |
| 112 | ); | 114 | ); |
| 113 | } | 115 | } |
| ... | @@ -134,7 +136,7 @@ pub fn syscall6( | ... | @@ -134,7 +136,7 @@ pub fn syscall6( |
| 134 | [arg3] "{o2}" (arg3), | 136 | [arg3] "{o2}" (arg3), |
| 135 | [arg4] "{o3}" (arg4), | 137 | [arg4] "{o3}" (arg4), |
| 136 | [arg5] "{o4}" (arg5), | 138 | [arg5] "{o4}" (arg5), |
| 137 | [arg6] "{o5}" (arg6), | 139 | [arg6] "{o5}" (arg6) |
| 138 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" | 140 | : "memory", "xcc", "o1", "o2", "o3", "o4", "o5", "o7" |
| 139 | ); | 141 | ); |
| 140 | } | 142 | } |
lib/std/os/linux/test.zig+1-1| ... | @@ -86,7 +86,7 @@ test "statx" { | ... | @@ -86,7 +86,7 @@ test "statx" { |
| 86 | else => unreachable, | 86 | else => unreachable, |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | var stat_buf: linux.Stat = undefined; | 89 | var stat_buf: linux.kernel_stat = undefined; |
| 90 | switch (linux.getErrno(linux.fstatat(file.handle, "", &stat_buf, linux.AT_EMPTY_PATH))) { | 90 | switch (linux.getErrno(linux.fstatat(file.handle, "", &stat_buf, linux.AT_EMPTY_PATH))) { |
| 91 | 0 => {}, | 91 | 0 => {}, |
| 92 | else => unreachable, | 92 | else => unreachable, |