authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-08-16 11:23:02+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-08-18 07:27:23+02:00
logea38009f3d0476867d945c3f14f5053206ec87f9
tree48d7dd0b195ed78e20b020a40c3819c698fa011e
parented9a502dffa8db45ef2f73edcbd20c52e26c548f

std.os.linux: Fix Stat struct for mips/mips64.


2 files changed, 47 insertions(+), 25 deletions(-)

lib/std/os/linux/mips.zig+24-13
......@@ -322,7 +322,7 @@ pub const msghdr_const = extern struct {
322322 flags: i32,
323323};
324324
325pub const blksize_t = i32;
325pub const blksize_t = u32;
326326pub const nlink_t = u32;
327327pub const time_t = i32;
328328pub const mode_t = u32;
......@@ -331,36 +331,47 @@ pub const ino_t = u64;
331331pub const dev_t = u64;
332332pub const blkcnt_t = i64;
333333
334// The `stat` definition used by the Linux kernel.
334// The `stat64` definition used by the Linux kernel.
335335pub const Stat = extern struct {
336 dev: u32,
337 __pad0: [3]u32, // Reserved for st_dev expansion
336 dev: dev_t,
337 __pad0: [2]u32, // -1 because our dev_t is u64 (kernel dev_t is really u32).
338338 ino: ino_t,
339339 mode: mode_t,
340340 nlink: nlink_t,
341341 uid: uid_t,
342342 gid: gid_t,
343 rdev: u32,
344 __pad1: [3]u32,
343 rdev: dev_t,
344 __pad1: [2]u32, // -1 because our dev_t is u64 (kernel dev_t is really u32).
345345 size: off_t,
346 atim: timespec,
347 mtim: timespec,
348 ctim: timespec,
346 atim: i32,
347 atim_nsec: u32,
348 mtim: i32,
349 mtim_nsec: u32,
350 ctim: i32,
351 ctim_nsec: u32,
349352 blksize: blksize_t,
350353 __pad3: u32,
351354 blocks: blkcnt_t,
352 __pad4: [14]usize,
353355
354356 pub fn atime(self: @This()) timespec {
355 return self.atim;
357 return .{
358 .sec = self.atim,
359 .nsec = self.atim_nsec,
360 };
356361 }
357362
358363 pub fn mtime(self: @This()) timespec {
359 return self.mtim;
364 return .{
365 .sec = self.mtim,
366 .nsec = self.mtim_nsec,
367 };
360368 }
361369
362370 pub fn ctime(self: @This()) timespec {
363 return self.ctim;
371 return .{
372 .sec = self.ctim,
373 .nsec = self.ctim_nsec,
374 };
364375 }
365376};
366377
lib/std/os/linux/mips64.zig+23-12
......@@ -301,7 +301,7 @@ pub const msghdr_const = extern struct {
301301 flags: i32,
302302};
303303
304pub const blksize_t = i32;
304pub const blksize_t = u32;
305305pub const nlink_t = u32;
306306pub const time_t = i32;
307307pub const mode_t = u32;
......@@ -312,34 +312,45 @@ pub const blkcnt_t = i64;
312312
313313// The `stat` definition used by the Linux kernel.
314314pub const Stat = extern struct {
315 dev: u32,
316 __pad0: [3]u32, // Reserved for st_dev expansion
315 dev: dev_t,
316 __pad0: [2]u32, // -1 because our dev_t is u64 (kernel dev_t is really u32).
317317 ino: ino_t,
318318 mode: mode_t,
319319 nlink: nlink_t,
320320 uid: uid_t,
321321 gid: gid_t,
322 rdev: u32,
323 __pad1: [3]u32,
322 rdev: dev_t,
323 __pad1: [2]u32, // -1 because our dev_t is u64 (kernel dev_t is really u32).
324324 size: off_t,
325 atim: timespec,
326 mtim: timespec,
327 ctim: timespec,
325 atim: u32,
326 atim_nsec: u32,
327 mtim: u32,
328 mtim_nsec: u32,
329 ctim: u32,
330 ctim_nsec: u32,
328331 blksize: blksize_t,
329332 __pad3: u32,
330333 blocks: blkcnt_t,
331 __pad4: [14]usize,
332334
333335 pub fn atime(self: @This()) timespec {
334 return self.atim;
336 return .{
337 .sec = self.atim,
338 .nsec = self.atim_nsec,
339 };
335340 }
336341
337342 pub fn mtime(self: @This()) timespec {
338 return self.mtim;
343 return .{
344 .sec = self.mtim,
345 .nsec = self.mtim_nsec,
346 };
339347 }
340348
341349 pub fn ctime(self: @This()) timespec {
342 return self.ctim;
350 return .{
351 .sec = self.ctim,
352 .nsec = self.ctim_nsec,
353 };
343354 }
344355};
345356