diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-08-22 20:09:08 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-22 20:09:08 -0700 |
| commit | ee84deda988afb36f24ecd35ebea40221c1b80d8 (patch) | |
| tree | b4044553d6cf49cbf69dd20f617260161f2527ac /lib/std/c.zig | |
| parent | c262061129f0c19a276779e4102da99eca58536a (diff) | |
| parent | 3e8ac8e23fce5f8468f54209dc9cc97c878edb9e (diff) | |
| download | zig-ee84deda988afb36f24ecd35ebea40221c1b80d8.tar.gz zig-ee84deda988afb36f24ecd35ebea40221c1b80d8.zip | |
Merge pull request #21095 from alexrp/mips64-tests
Get `mips64(el)-linux` working and start testing it
Diffstat (limited to 'lib/std/c.zig')
| -rw-r--r-- | lib/std/c.zig | 132 |
1 files changed, 128 insertions, 4 deletions
diff --git a/lib/std/c.zig b/lib/std/c.zig index 92d36dd135..d430cf6a83 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -2722,7 +2722,39 @@ pub const SYS = switch (native_os) { }; /// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name. pub const Sigaction = switch (native_os) { - .linux => linux.Sigaction, + .linux => switch (native_arch) { + .mips, + .mipsel, + .mips64, + .mips64el, + => if (builtin.target.isMusl()) + linux.Sigaction + else if (builtin.target.ptrBitWidth() == 64) extern struct { + pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; + pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; + + flags: c_uint, + handler: extern union { + handler: ?handler_fn, + sigaction: ?sigaction_fn, + }, + mask: sigset_t, + restorer: ?*const fn () callconv(.C) void = null, + } else extern struct { + pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; + pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void; + + flags: c_uint, + handler: extern union { + handler: ?handler_fn, + sigaction: ?sigaction_fn, + }, + mask: sigset_t, + restorer: ?*const fn () callconv(.C) void = null, + __resv: [1]c_int = .{0}, + }, + else => linux.Sigaction, + }, .emscripten => emscripten.Sigaction, .netbsd, .macos, .ios, .tvos, .watchos, .visionos => extern struct { pub const handler_fn = *align(1) const fn (i32) callconv(.C) void; @@ -6326,16 +6358,46 @@ pub const Stat = switch (native_os) { return self.ctim; } }, - .mips, .mipsel => extern struct { + .mips, .mipsel => if (builtin.target.isMusl()) extern struct { dev: dev_t, - __pad0: [2]u32, + __pad0: [2]i32, ino: ino_t, mode: mode_t, nlink: nlink_t, uid: uid_t, gid: gid_t, rdev: dev_t, - __pad1: [2]u32, + __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: 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, @@ -6357,6 +6419,68 @@ pub const Stat = switch (native_os) { return self.ctim; } }, + .mips64, .mips64el => if (builtin.target.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. }, |
