authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-08-22 20:09:08-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-08-22 20:09:08-07:00
logee84deda988afb36f24ecd35ebea40221c1b80d8
treeb4044553d6cf49cbf69dd20f617260161f2527ac
parentc262061129f0c19a276779e4102da99eca58536a
parent3e8ac8e23fce5f8468f54209dc9cc97c878edb9e
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #21095 from alexrp/mips64-tests

Get `mips64(el)-linux` working and start testing it

9 files changed, 424 insertions(+), 275 deletions(-)

lib/std/c.zig+128-4
...@@ -2722,7 +2722,39 @@ pub const SYS = switch (native_os) {...@@ -2722,7 +2722,39 @@ pub const SYS = switch (native_os) {
2722};2722};
2723/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.2723/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.
2724pub const Sigaction = switch (native_os) {2724pub const Sigaction = switch (native_os) {
2725 .linux => linux.Sigaction,2725 .linux => switch (native_arch) {
2726 .mips,
2727 .mipsel,
2728 .mips64,
2729 .mips64el,
2730 => if (builtin.target.isMusl())
2731 linux.Sigaction
2732 else if (builtin.target.ptrBitWidth() == 64) extern struct {
2733 pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
2734 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
2735
2736 flags: c_uint,
2737 handler: extern union {
2738 handler: ?handler_fn,
2739 sigaction: ?sigaction_fn,
2740 },
2741 mask: sigset_t,
2742 restorer: ?*const fn () callconv(.C) void = null,
2743 } else extern struct {
2744 pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
2745 pub const sigaction_fn = *const fn (i32, *const siginfo_t, ?*anyopaque) callconv(.C) void;
2746
2747 flags: c_uint,
2748 handler: extern union {
2749 handler: ?handler_fn,
2750 sigaction: ?sigaction_fn,
2751 },
2752 mask: sigset_t,
2753 restorer: ?*const fn () callconv(.C) void = null,
2754 __resv: [1]c_int = .{0},
2755 },
2756 else => linux.Sigaction,
2757 },
2726 .emscripten => emscripten.Sigaction,2758 .emscripten => emscripten.Sigaction,
2727 .netbsd, .macos, .ios, .tvos, .watchos, .visionos => extern struct {2759 .netbsd, .macos, .ios, .tvos, .watchos, .visionos => extern struct {
2728 pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;2760 pub const handler_fn = *align(1) const fn (i32) callconv(.C) void;
...@@ -6326,16 +6358,46 @@ pub const Stat = switch (native_os) {...@@ -6326,16 +6358,46 @@ pub const Stat = switch (native_os) {
6326 return self.ctim;6358 return self.ctim;
6327 }6359 }
6328 },6360 },
6329 .mips, .mipsel => extern struct {6361 .mips, .mipsel => if (builtin.target.isMusl()) extern struct {
6330 dev: dev_t,6362 dev: dev_t,
6331 __pad0: [2]u32,6363 __pad0: [2]i32,
6332 ino: ino_t,6364 ino: ino_t,
6333 mode: mode_t,6365 mode: mode_t,
6334 nlink: nlink_t,6366 nlink: nlink_t,
6335 uid: uid_t,6367 uid: uid_t,
6336 gid: gid_t,6368 gid: gid_t,
6337 rdev: dev_t,6369 rdev: dev_t,
6338 __pad1: [2]u32,6370 __pad1: [2]i32,
6371 size: off_t,
6372 atim: timespec,
6373 mtim: timespec,
6374 ctim: timespec,
6375 blksize: blksize_t,
6376 __pad3: i32,
6377 blocks: blkcnt_t,
6378 __pad4: [14]i32,
6379
6380 pub fn atime(self: @This()) timespec {
6381 return self.atim;
6382 }
6383
6384 pub fn mtime(self: @This()) timespec {
6385 return self.mtim;
6386 }
6387
6388 pub fn ctime(self: @This()) timespec {
6389 return self.ctim;
6390 }
6391 } else extern struct {
6392 dev: dev_t,
6393 __pad0: [3]u32,
6394 ino: ino_t,
6395 mode: mode_t,
6396 nlink: nlink_t,
6397 uid: uid_t,
6398 gid: gid_t,
6399 rdev: dev_t,
6400 __pad1: [3]u32,
6339 size: off_t,6401 size: off_t,
6340 atim: timespec,6402 atim: timespec,
6341 mtim: timespec,6403 mtim: timespec,
...@@ -6357,6 +6419,68 @@ pub const Stat = switch (native_os) {...@@ -6357,6 +6419,68 @@ pub const Stat = switch (native_os) {
6357 return self.ctim;6419 return self.ctim;
6358 }6420 }
6359 },6421 },
6422 .mips64, .mips64el => if (builtin.target.isMusl()) extern struct {
6423 dev: dev_t,
6424 __pad0: [3]i32,
6425 ino: ino_t,
6426 mode: mode_t,
6427 nlink: nlink_t,
6428 uid: uid_t,
6429 gid: gid_t,
6430 rdev: dev_t,
6431 __pad1: [2]u32,
6432 size: off_t,
6433 __pad2: i32,
6434 atim: timespec,
6435 mtim: timespec,
6436 ctim: timespec,
6437 blksize: blksize_t,
6438 __pad3: u32,
6439 blocks: blkcnt_t,
6440 __pad4: [14]i32,
6441
6442 pub fn atime(self: @This()) timespec {
6443 return self.atim;
6444 }
6445
6446 pub fn mtime(self: @This()) timespec {
6447 return self.mtim;
6448 }
6449
6450 pub fn ctime(self: @This()) timespec {
6451 return self.ctim;
6452 }
6453 } else extern struct {
6454 dev: dev_t,
6455 __pad0: [3]u32,
6456 ino: ino_t,
6457 mode: mode_t,
6458 nlink: nlink_t,
6459 uid: uid_t,
6460 gid: gid_t,
6461 rdev: dev_t,
6462 __pad1: [3]u32,
6463 size: off_t,
6464 atim: timespec,
6465 mtim: timespec,
6466 ctim: timespec,
6467 blksize: blksize_t,
6468 __pad3: u32,
6469 blocks: blkcnt_t,
6470 __pad4: [14]i32,
6471
6472 pub fn atime(self: @This()) timespec {
6473 return self.atim;
6474 }
6475
6476 pub fn mtime(self: @This()) timespec {
6477 return self.mtim;
6478 }
6479
6480 pub fn ctime(self: @This()) timespec {
6481 return self.ctim;
6482 }
6483 },
63606484
6361 else => std.os.linux.Stat, // libc stat is the same as kernel stat.6485 else => std.os.linux.Stat, // libc stat is the same as kernel stat.
6362 },6486 },
lib/std/debug.zig+2
...@@ -56,6 +56,8 @@ pub const sys_can_stack_trace = switch (builtin.cpu.arch) {...@@ -56,6 +56,8 @@ pub const sys_can_stack_trace = switch (builtin.cpu.arch) {
56 // TODO: Make this work.56 // TODO: Make this work.
57 .mips,57 .mips,
58 .mipsel,58 .mipsel,
59 .mips64,
60 .mips64el,
59 => false,61 => false,
6062
61 // `@returnAddress()` in LLVM 10 gives63 // `@returnAddress()` in LLVM 10 gives
lib/std/os/linux.zig+161-48
...@@ -2272,7 +2272,7 @@ pub fn fadvise(fd: fd_t, offset: i64, len: i64, advice: usize) usize {...@@ -2272,7 +2272,7 @@ pub fn fadvise(fd: fd_t, offset: i64, len: i64, advice: usize) usize {
2272 length_halves[0],2272 length_halves[0],
2273 length_halves[1],2273 length_halves[1],
2274 );2274 );
2275 } else if (comptime native_arch == .mips or native_arch == .mipsel) {2275 } else if (native_arch.isMIPS32()) {
2276 // MIPS O32 does not deal with the register alignment issue, so pass a dummy value.2276 // MIPS O32 does not deal with the register alignment issue, so pass a dummy value.
22772277
2278 const offset_halves = splitValue64(offset);2278 const offset_halves = splitValue64(offset);
...@@ -2382,7 +2382,7 @@ pub fn map_shadow_stack(addr: u64, size: u64, flags: u32) usize {...@@ -2382,7 +2382,7 @@ pub fn map_shadow_stack(addr: u64, size: u64, flags: u32) usize {
2382}2382}
23832383
2384pub const E = switch (native_arch) {2384pub const E = switch (native_arch) {
2385 .mips, .mipsel => enum(u16) {2385 .mips, .mipsel, .mips64, .mips64el => enum(u16) {
2386 /// No error occurred.2386 /// No error occurred.
2387 SUCCESS = 0,2387 SUCCESS = 0,
23882388
...@@ -7068,53 +7068,166 @@ pub const ifreq = extern struct {...@@ -7068,53 +7068,166 @@ pub const ifreq = extern struct {
7068};7068};
70697069
7070// doc comments copied from musl7070// doc comments copied from musl
7071pub const rlimit_resource = if (native_arch.isMIPS() or native_arch.isSPARC())7071pub const rlimit_resource = if (native_arch.isMIPS()) enum(c_int) {
7072 arch_bits.rlimit_resource7072 /// Per-process CPU limit, in seconds.
7073else7073 CPU = 0,
7074 enum(c_int) {
7075 /// Per-process CPU limit, in seconds.
7076 CPU,
7077 /// Largest file that can be created, in bytes.
7078 FSIZE,
7079 /// Maximum size of data segment, in bytes.
7080 DATA,
7081 /// Maximum size of stack segment, in bytes.
7082 STACK,
7083 /// Largest core file that can be created, in bytes.
7084 CORE,
7085 /// Largest resident set size, in bytes.
7086 /// This affects swapping; processes that are exceeding their
7087 /// resident set size will be more likely to have physical memory
7088 /// taken from them.
7089 RSS,
7090 /// Number of processes.
7091 NPROC,
7092 /// Number of open files.
7093 NOFILE,
7094 /// Locked-in-memory address space.
7095 MEMLOCK,
7096 /// Address space limit.
7097 AS,
7098 /// Maximum number of file locks.
7099 LOCKS,
7100 /// Maximum number of pending signals.
7101 SIGPENDING,
7102 /// Maximum bytes in POSIX message queues.
7103 MSGQUEUE,
7104 /// Maximum nice priority allowed to raise to.
7105 /// Nice levels 19 .. -20 correspond to 0 .. 39
7106 /// values of this resource limit.
7107 NICE,
7108 /// Maximum realtime priority allowed for non-privileged
7109 /// processes.
7110 RTPRIO,
7111 /// Maximum CPU time in µs that a process scheduled under a real-time
7112 /// scheduling policy may consume without making a blocking system
7113 /// call before being forcibly descheduled.
7114 RTTIME,
71157074
7116 _,7075 /// Largest file that can be created, in bytes.
7117 };7076 FSIZE = 1,
7077
7078 /// Maximum size of data segment, in bytes.
7079 DATA = 2,
7080
7081 /// Maximum size of stack segment, in bytes.
7082 STACK = 3,
7083
7084 /// Largest core file that can be created, in bytes.
7085 CORE = 4,
7086
7087 /// Number of open files.
7088 NOFILE = 5,
7089
7090 /// Address space limit.
7091 AS = 6,
7092
7093 /// Largest resident set size, in bytes.
7094 /// This affects swapping; processes that are exceeding their
7095 /// resident set size will be more likely to have physical memory
7096 /// taken from them.
7097 RSS = 7,
7098
7099 /// Number of processes.
7100 NPROC = 8,
7101
7102 /// Locked-in-memory address space.
7103 MEMLOCK = 9,
7104
7105 /// Maximum number of file locks.
7106 LOCKS = 10,
7107
7108 /// Maximum number of pending signals.
7109 SIGPENDING = 11,
7110
7111 /// Maximum bytes in POSIX message queues.
7112 MSGQUEUE = 12,
7113
7114 /// Maximum nice priority allowed to raise to.
7115 /// Nice levels 19 .. -20 correspond to 0 .. 39
7116 /// values of this resource limit.
7117 NICE = 13,
7118
7119 /// Maximum realtime priority allowed for non-privileged
7120 /// processes.
7121 RTPRIO = 14,
7122
7123 /// Maximum CPU time in µs that a process scheduled under a real-time
7124 /// scheduling policy may consume without making a blocking system
7125 /// call before being forcibly descheduled.
7126 RTTIME = 15,
7127
7128 _,
7129} else if (native_arch.isSPARC()) enum(c_int) {
7130 /// Per-process CPU limit, in seconds.
7131 CPU = 0,
7132
7133 /// Largest file that can be created, in bytes.
7134 FSIZE = 1,
7135
7136 /// Maximum size of data segment, in bytes.
7137 DATA = 2,
7138
7139 /// Maximum size of stack segment, in bytes.
7140 STACK = 3,
7141
7142 /// Largest core file that can be created, in bytes.
7143 CORE = 4,
7144
7145 /// Largest resident set size, in bytes.
7146 /// This affects swapping; processes that are exceeding their
7147 /// resident set size will be more likely to have physical memory
7148 /// taken from them.
7149 RSS = 5,
7150
7151 /// Number of open files.
7152 NOFILE = 6,
7153
7154 /// Number of processes.
7155 NPROC = 7,
7156
7157 /// Locked-in-memory address space.
7158 MEMLOCK = 8,
7159
7160 /// Address space limit.
7161 AS = 9,
7162
7163 /// Maximum number of file locks.
7164 LOCKS = 10,
7165
7166 /// Maximum number of pending signals.
7167 SIGPENDING = 11,
7168
7169 /// Maximum bytes in POSIX message queues.
7170 MSGQUEUE = 12,
7171
7172 /// Maximum nice priority allowed to raise to.
7173 /// Nice levels 19 .. -20 correspond to 0 .. 39
7174 /// values of this resource limit.
7175 NICE = 13,
7176
7177 /// Maximum realtime priority allowed for non-privileged
7178 /// processes.
7179 RTPRIO = 14,
7180
7181 /// Maximum CPU time in µs that a process scheduled under a real-time
7182 /// scheduling policy may consume without making a blocking system
7183 /// call before being forcibly descheduled.
7184 RTTIME = 15,
7185
7186 _,
7187} else enum(c_int) {
7188 /// Per-process CPU limit, in seconds.
7189 CPU = 0,
7190 /// Largest file that can be created, in bytes.
7191 FSIZE = 1,
7192 /// Maximum size of data segment, in bytes.
7193 DATA = 2,
7194 /// Maximum size of stack segment, in bytes.
7195 STACK = 3,
7196 /// Largest core file that can be created, in bytes.
7197 CORE = 4,
7198 /// Largest resident set size, in bytes.
7199 /// This affects swapping; processes that are exceeding their
7200 /// resident set size will be more likely to have physical memory
7201 /// taken from them.
7202 RSS = 5,
7203 /// Number of processes.
7204 NPROC = 6,
7205 /// Number of open files.
7206 NOFILE = 7,
7207 /// Locked-in-memory address space.
7208 MEMLOCK = 8,
7209 /// Address space limit.
7210 AS = 9,
7211 /// Maximum number of file locks.
7212 LOCKS = 10,
7213 /// Maximum number of pending signals.
7214 SIGPENDING = 11,
7215 /// Maximum bytes in POSIX message queues.
7216 MSGQUEUE = 12,
7217 /// Maximum nice priority allowed to raise to.
7218 /// Nice levels 19 .. -20 correspond to 0 .. 39
7219 /// values of this resource limit.
7220 NICE = 13,
7221 /// Maximum realtime priority allowed for non-privileged
7222 /// processes.
7223 RTPRIO = 14,
7224 /// Maximum CPU time in µs that a process scheduled under a real-time
7225 /// scheduling policy may consume without making a blocking system
7226 /// call before being forcibly descheduled.
7227 RTTIME = 15,
7228
7229 _,
7230};
71187231
7119pub const rlim_t = u64;7232pub const rlim_t = u64;
71207233
lib/std/os/linux/mips.zig+41-82
...@@ -14,7 +14,8 @@ const timespec = linux.timespec;...@@ -14,7 +14,8 @@ const timespec = linux.timespec;
14pub fn syscall0(number: SYS) usize {14pub fn syscall0(number: SYS) usize {
15 return asm volatile (15 return asm volatile (
16 \\ syscall16 \\ syscall
17 \\ blez $7, 1f17 \\ beq $7, $zero, 1f
18 \\ blez $2, 1f
18 \\ subu $2, $0, $219 \\ subu $2, $0, $2
19 \\ 1:20 \\ 1:
20 : [ret] "={$2}" (-> usize),21 : [ret] "={$2}" (-> usize),
...@@ -28,7 +29,7 @@ pub fn syscall_pipe(fd: *[2]i32) usize {...@@ -28,7 +29,7 @@ pub fn syscall_pipe(fd: *[2]i32) usize {
28 \\ .set noat29 \\ .set noat
29 \\ .set noreorder30 \\ .set noreorder
30 \\ syscall31 \\ syscall
31 \\ blez $7, 1f32 \\ beq $7, $zero, 1f
32 \\ nop33 \\ nop
33 \\ b 2f34 \\ b 2f
34 \\ subu $2, $0, $235 \\ subu $2, $0, $2
...@@ -46,7 +47,8 @@ pub fn syscall_pipe(fd: *[2]i32) usize {...@@ -46,7 +47,8 @@ pub fn syscall_pipe(fd: *[2]i32) usize {
46pub fn syscall1(number: SYS, arg1: usize) usize {47pub fn syscall1(number: SYS, arg1: usize) usize {
47 return asm volatile (48 return asm volatile (
48 \\ syscall49 \\ syscall
49 \\ blez $7, 1f50 \\ beq $7, $zero, 1f
51 \\ blez $2, 1f
50 \\ subu $2, $0, $252 \\ subu $2, $0, $2
51 \\ 1:53 \\ 1:
52 : [ret] "={$2}" (-> usize),54 : [ret] "={$2}" (-> usize),
...@@ -59,7 +61,8 @@ pub fn syscall1(number: SYS, arg1: usize) usize {...@@ -59,7 +61,8 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
59pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {61pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
60 return asm volatile (62 return asm volatile (
61 \\ syscall63 \\ syscall
62 \\ blez $7, 1f64 \\ beq $7, $zero, 1f
65 \\ blez $2, 1f
63 \\ subu $2, $0, $266 \\ subu $2, $0, $2
64 \\ 1:67 \\ 1:
65 : [ret] "={$2}" (-> usize),68 : [ret] "={$2}" (-> usize),
...@@ -73,7 +76,8 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {...@@ -73,7 +76,8 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
73pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {76pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
74 return asm volatile (77 return asm volatile (
75 \\ syscall78 \\ syscall
76 \\ blez $7, 1f79 \\ beq $7, $zero, 1f
80 \\ blez $2, 1f
77 \\ subu $2, $0, $281 \\ subu $2, $0, $2
78 \\ 1:82 \\ 1:
79 : [ret] "={$2}" (-> usize),83 : [ret] "={$2}" (-> usize),
...@@ -88,7 +92,8 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {...@@ -88,7 +92,8 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
88pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {92pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
89 return asm volatile (93 return asm volatile (
90 \\ syscall94 \\ syscall
91 \\ blez $7, 1f95 \\ beq $7, $zero, 1f
96 \\ blez $2, 1f
92 \\ subu $2, $0, $297 \\ subu $2, $0, $2
93 \\ 1:98 \\ 1:
94 : [ret] "={$2}" (-> usize),99 : [ret] "={$2}" (-> usize),
...@@ -108,7 +113,8 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,...@@ -108,7 +113,8 @@ pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize,
108 \\ sw %[arg5], 16($sp)113 \\ sw %[arg5], 16($sp)
109 \\ syscall114 \\ syscall
110 \\ addu $sp, $sp, 24115 \\ addu $sp, $sp, 24
111 \\ blez $7, 1f116 \\ beq $7, $zero, 1f
117 \\ blez $2, 1f
112 \\ subu $2, $0, $2118 \\ subu $2, $0, $2
113 \\ 1:119 \\ 1:
114 : [ret] "={$2}" (-> usize),120 : [ret] "={$2}" (-> usize),
...@@ -141,7 +147,8 @@ pub fn syscall6(...@@ -141,7 +147,8 @@ pub fn syscall6(
141 \\ sw %[arg6], 20($sp)147 \\ sw %[arg6], 20($sp)
142 \\ syscall148 \\ syscall
143 \\ addu $sp, $sp, 24149 \\ addu $sp, $sp, 24
144 \\ blez $7, 1f150 \\ beq $7, $zero, 1f
151 \\ blez $2, 1f
145 \\ subu $2, $0, $2152 \\ subu $2, $0, $2
146 \\ 1:153 \\ 1:
147 : [ret] "={$2}" (-> usize),154 : [ret] "={$2}" (-> usize),
...@@ -174,7 +181,8 @@ pub fn syscall7(...@@ -174,7 +181,8 @@ pub fn syscall7(
174 \\ sw %[arg7], 24($sp)181 \\ sw %[arg7], 24($sp)
175 \\ syscall182 \\ syscall
176 \\ addu $sp, $sp, 32183 \\ addu $sp, $sp, 32
177 \\ blez $7, 1f184 \\ beq $7, $zero, 1f
185 \\ blez $2, 1f
178 \\ subu $2, $0, $2186 \\ subu $2, $0, $2
179 \\ 1:187 \\ 1:
180 : [ret] "={$2}" (-> usize),188 : [ret] "={$2}" (-> usize),
...@@ -314,7 +322,7 @@ pub const msghdr_const = extern struct {...@@ -314,7 +322,7 @@ pub const msghdr_const = extern struct {
314 flags: i32,322 flags: i32,
315};323};
316324
317pub const blksize_t = i32;325pub const blksize_t = u32;
318pub const nlink_t = u32;326pub const nlink_t = u32;
319pub const time_t = i32;327pub const time_t = i32;
320pub const mode_t = u32;328pub const mode_t = u32;
...@@ -323,36 +331,47 @@ pub const ino_t = u64;...@@ -323,36 +331,47 @@ pub const ino_t = u64;
323pub const dev_t = u64;331pub const dev_t = u64;
324pub const blkcnt_t = i64;332pub const blkcnt_t = i64;
325333
326// The `stat` definition used by the Linux kernel.334// The `stat64` definition used by the Linux kernel.
327pub const Stat = extern struct {335pub const Stat = extern struct {
328 dev: u32,336 dev: dev_t,
329 __pad0: [3]u32, // Reserved for st_dev expansion337 __pad0: [2]u32, // -1 because our dev_t is u64 (kernel dev_t is really u32).
330 ino: ino_t,338 ino: ino_t,
331 mode: mode_t,339 mode: mode_t,
332 nlink: nlink_t,340 nlink: nlink_t,
333 uid: uid_t,341 uid: uid_t,
334 gid: gid_t,342 gid: gid_t,
335 rdev: u32,343 rdev: dev_t,
336 __pad1: [3]u32,344 __pad1: [2]u32, // -1 because our dev_t is u64 (kernel dev_t is really u32).
337 size: off_t,345 size: off_t,
338 atim: timespec,346 atim: i32,
339 mtim: timespec,347 atim_nsec: u32,
340 ctim: timespec,348 mtim: i32,
349 mtim_nsec: u32,
350 ctim: i32,
351 ctim_nsec: u32,
341 blksize: blksize_t,352 blksize: blksize_t,
342 __pad3: u32,353 __pad3: u32,
343 blocks: blkcnt_t,354 blocks: blkcnt_t,
344 __pad4: [14]usize,
345355
346 pub fn atime(self: @This()) timespec {356 pub fn atime(self: @This()) timespec {
347 return self.atim;357 return .{
358 .sec = self.atim,
359 .nsec = self.atim_nsec,
360 };
348 }361 }
349362
350 pub fn mtime(self: @This()) timespec {363 pub fn mtime(self: @This()) timespec {
351 return self.mtim;364 return .{
365 .sec = self.mtim,
366 .nsec = self.mtim_nsec,
367 };
352 }368 }
353369
354 pub fn ctime(self: @This()) timespec {370 pub fn ctime(self: @This()) timespec {
355 return self.ctim;371 return .{
372 .sec = self.ctim,
373 .nsec = self.ctim_nsec,
374 };
356 }375 }
357};376};
358377
...@@ -368,66 +387,6 @@ pub const timezone = extern struct {...@@ -368,66 +387,6 @@ pub const timezone = extern struct {
368387
369pub const Elf_Symndx = u32;388pub const Elf_Symndx = u32;
370389
371pub const rlimit_resource = enum(c_int) {
372 /// Per-process CPU limit, in seconds.
373 CPU,
374
375 /// Largest file that can be created, in bytes.
376 FSIZE,
377
378 /// Maximum size of data segment, in bytes.
379 DATA,
380
381 /// Maximum size of stack segment, in bytes.
382 STACK,
383
384 /// Largest core file that can be created, in bytes.
385 CORE,
386
387 /// Number of open files.
388 NOFILE,
389
390 /// Address space limit.
391 AS,
392
393 /// Largest resident set size, in bytes.
394 /// This affects swapping; processes that are exceeding their
395 /// resident set size will be more likely to have physical memory
396 /// taken from them.
397 RSS,
398
399 /// Number of processes.
400 NPROC,
401
402 /// Locked-in-memory address space.
403 MEMLOCK,
404
405 /// Maximum number of file locks.
406 LOCKS,
407
408 /// Maximum number of pending signals.
409 SIGPENDING,
410
411 /// Maximum bytes in POSIX message queues.
412 MSGQUEUE,
413
414 /// Maximum nice priority allowed to raise to.
415 /// Nice levels 19 .. -20 correspond to 0 .. 39
416 /// values of this resource limit.
417 NICE,
418
419 /// Maximum realtime priority allowed for non-privileged
420 /// processes.
421 RTPRIO,
422
423 /// Maximum CPU time in µs that a process scheduled under a real-time
424 /// scheduling policy may consume without making a blocking system
425 /// call before being forcibly descheduled.
426 RTTIME,
427
428 _,
429};
430
431/// TODO390/// TODO
432pub const ucontext_t = void;391pub const ucontext_t = void;
433392
lib/std/os/linux/mips64.zig+41-81
...@@ -14,7 +14,8 @@ const timespec = linux.timespec;...@@ -14,7 +14,8 @@ const timespec = linux.timespec;
14pub fn syscall0(number: SYS) usize {14pub fn syscall0(number: SYS) usize {
15 return asm volatile (15 return asm volatile (
16 \\ syscall16 \\ syscall
17 \\ blez $7, 1f17 \\ beq $7, $zero, 1f
18 \\ blez $2, 1f
18 \\ dsubu $2, $0, $219 \\ dsubu $2, $0, $2
19 \\ 1:20 \\ 1:
20 : [ret] "={$2}" (-> usize),21 : [ret] "={$2}" (-> usize),
...@@ -28,7 +29,7 @@ pub fn syscall_pipe(fd: *[2]i32) usize {...@@ -28,7 +29,7 @@ pub fn syscall_pipe(fd: *[2]i32) usize {
28 \\ .set noat29 \\ .set noat
29 \\ .set noreorder30 \\ .set noreorder
30 \\ syscall31 \\ syscall
31 \\ blez $7, 1f32 \\ beq $7, $zero, 1f
32 \\ nop33 \\ nop
33 \\ b 2f34 \\ b 2f
34 \\ subu $2, $0, $235 \\ subu $2, $0, $2
...@@ -46,7 +47,9 @@ pub fn syscall_pipe(fd: *[2]i32) usize {...@@ -46,7 +47,9 @@ pub fn syscall_pipe(fd: *[2]i32) usize {
46pub fn syscall1(number: SYS, arg1: usize) usize {47pub fn syscall1(number: SYS, arg1: usize) usize {
47 return asm volatile (48 return asm volatile (
48 \\ syscall49 \\ syscall
49 \\ blez $7, 1f50 \\ beq $7, $zero, 1f
51 \\ blez $2, 1f
52 \\ nop
50 \\ dsubu $2, $0, $253 \\ dsubu $2, $0, $2
51 \\ 1:54 \\ 1:
52 : [ret] "={$2}" (-> usize),55 : [ret] "={$2}" (-> usize),
...@@ -59,7 +62,8 @@ pub fn syscall1(number: SYS, arg1: usize) usize {...@@ -59,7 +62,8 @@ pub fn syscall1(number: SYS, arg1: usize) usize {
59pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {62pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
60 return asm volatile (63 return asm volatile (
61 \\ syscall64 \\ syscall
62 \\ blez $7, 1f65 \\ beq $7, $zero, 1f
66 \\ blez $2, 1f
63 \\ dsubu $2, $0, $267 \\ dsubu $2, $0, $2
64 \\ 1:68 \\ 1:
65 : [ret] "={$2}" (-> usize),69 : [ret] "={$2}" (-> usize),
...@@ -73,7 +77,8 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {...@@ -73,7 +77,8 @@ pub fn syscall2(number: SYS, arg1: usize, arg2: usize) usize {
73pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {77pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
74 return asm volatile (78 return asm volatile (
75 \\ syscall79 \\ syscall
76 \\ blez $7, 1f80 \\ beq $7, $zero, 1f
81 \\ blez $2, 1f
77 \\ dsubu $2, $0, $282 \\ dsubu $2, $0, $2
78 \\ 1:83 \\ 1:
79 : [ret] "={$2}" (-> usize),84 : [ret] "={$2}" (-> usize),
...@@ -88,7 +93,8 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {...@@ -88,7 +93,8 @@ pub fn syscall3(number: SYS, arg1: usize, arg2: usize, arg3: usize) usize {
88pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {93pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
89 return asm volatile (94 return asm volatile (
90 \\ syscall95 \\ syscall
91 \\ blez $7, 1f96 \\ beq $7, $zero, 1f
97 \\ blez $2, 1f
92 \\ dsubu $2, $0, $298 \\ dsubu $2, $0, $2
93 \\ 1:99 \\ 1:
94 : [ret] "={$2}" (-> usize),100 : [ret] "={$2}" (-> usize),
...@@ -104,7 +110,8 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)...@@ -104,7 +110,8 @@ pub fn syscall4(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize)
104pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {110pub fn syscall5(number: SYS, arg1: usize, arg2: usize, arg3: usize, arg4: usize, arg5: usize) usize {
105 return asm volatile (111 return asm volatile (
106 \\ syscall112 \\ syscall
107 \\ blez $7, 1f113 \\ beq $7, $zero, 1f
114 \\ blez $2, 1f
108 \\ dsubu $2, $0, $2115 \\ dsubu $2, $0, $2
109 \\ 1:116 \\ 1:
110 : [ret] "={$2}" (-> usize),117 : [ret] "={$2}" (-> usize),
...@@ -129,7 +136,8 @@ pub fn syscall6(...@@ -129,7 +136,8 @@ pub fn syscall6(
129) usize {136) usize {
130 return asm volatile (137 return asm volatile (
131 \\ syscall138 \\ syscall
132 \\ blez $7, 1f139 \\ beq $7, $zero, 1f
140 \\ blez $2, 1f
133 \\ dsubu $2, $0, $2141 \\ dsubu $2, $0, $2
134 \\ 1:142 \\ 1:
135 : [ret] "={$2}" (-> usize),143 : [ret] "={$2}" (-> usize),
...@@ -156,7 +164,8 @@ pub fn syscall7(...@@ -156,7 +164,8 @@ pub fn syscall7(
156) usize {164) usize {
157 return asm volatile (165 return asm volatile (
158 \\ syscall166 \\ syscall
159 \\ blez $7, 1f167 \\ beq $7, $zero, 1f
168 \\ blez $2, 1f
160 \\ dsubu $2, $0, $2169 \\ dsubu $2, $0, $2
161 \\ 1:170 \\ 1:
162 : [ret] "={$2}" (-> usize),171 : [ret] "={$2}" (-> usize),
...@@ -292,7 +301,7 @@ pub const msghdr_const = extern struct {...@@ -292,7 +301,7 @@ pub const msghdr_const = extern struct {
292 flags: i32,301 flags: i32,
293};302};
294303
295pub const blksize_t = i32;304pub const blksize_t = u32;
296pub const nlink_t = u32;305pub const nlink_t = u32;
297pub const time_t = i32;306pub const time_t = i32;
298pub const mode_t = u32;307pub const mode_t = u32;
...@@ -303,34 +312,45 @@ pub const blkcnt_t = i64;...@@ -303,34 +312,45 @@ pub const blkcnt_t = i64;
303312
304// The `stat` definition used by the Linux kernel.313// The `stat` definition used by the Linux kernel.
305pub const Stat = extern struct {314pub const Stat = extern struct {
306 dev: u32,315 dev: dev_t,
307 __pad0: [3]u32, // Reserved for st_dev expansion316 __pad0: [2]u32, // -1 because our dev_t is u64 (kernel dev_t is really u32).
308 ino: ino_t,317 ino: ino_t,
309 mode: mode_t,318 mode: mode_t,
310 nlink: nlink_t,319 nlink: nlink_t,
311 uid: uid_t,320 uid: uid_t,
312 gid: gid_t,321 gid: gid_t,
313 rdev: u32,322 rdev: dev_t,
314 __pad1: [3]u32,323 __pad1: [2]u32, // -1 because our dev_t is u64 (kernel dev_t is really u32).
315 size: off_t,324 size: off_t,
316 atim: timespec,325 atim: u32,
317 mtim: timespec,326 atim_nsec: u32,
318 ctim: timespec,327 mtim: u32,
328 mtim_nsec: u32,
329 ctim: u32,
330 ctim_nsec: u32,
319 blksize: blksize_t,331 blksize: blksize_t,
320 __pad3: u32,332 __pad3: u32,
321 blocks: blkcnt_t,333 blocks: blkcnt_t,
322 __pad4: [14]usize,
323334
324 pub fn atime(self: @This()) timespec {335 pub fn atime(self: @This()) timespec {
325 return self.atim;336 return .{
337 .sec = self.atim,
338 .nsec = self.atim_nsec,
339 };
326 }340 }
327341
328 pub fn mtime(self: @This()) timespec {342 pub fn mtime(self: @This()) timespec {
329 return self.mtim;343 return .{
344 .sec = self.mtim,
345 .nsec = self.mtim_nsec,
346 };
330 }347 }
331348
332 pub fn ctime(self: @This()) timespec {349 pub fn ctime(self: @This()) timespec {
333 return self.ctim;350 return .{
351 .sec = self.ctim,
352 .nsec = self.ctim_nsec,
353 };
334 }354 }
335};355};
336356
...@@ -346,66 +366,6 @@ pub const timezone = extern struct {...@@ -346,66 +366,6 @@ pub const timezone = extern struct {
346366
347pub const Elf_Symndx = u32;367pub const Elf_Symndx = u32;
348368
349pub const rlimit_resource = enum(c_int) {
350 /// Per-process CPU limit, in seconds.
351 CPU,
352
353 /// Largest file that can be created, in bytes.
354 FSIZE,
355
356 /// Maximum size of data segment, in bytes.
357 DATA,
358
359 /// Maximum size of stack segment, in bytes.
360 STACK,
361
362 /// Largest core file that can be created, in bytes.
363 CORE,
364
365 /// Number of open files.
366 NOFILE,
367
368 /// Address space limit.
369 AS,
370
371 /// Largest resident set size, in bytes.
372 /// This affects swapping; processes that are exceeding their
373 /// resident set size will be more likely to have physical memory
374 /// taken from them.
375 RSS,
376
377 /// Number of processes.
378 NPROC,
379
380 /// Locked-in-memory address space.
381 MEMLOCK,
382
383 /// Maximum number of file locks.
384 LOCKS,
385
386 /// Maximum number of pending signals.
387 SIGPENDING,
388
389 /// Maximum bytes in POSIX message queues.
390 MSGQUEUE,
391
392 /// Maximum nice priority allowed to raise to.
393 /// Nice levels 19 .. -20 correspond to 0 .. 39
394 /// values of this resource limit.
395 NICE,
396
397 /// Maximum realtime priority allowed for non-privileged
398 /// processes.
399 RTPRIO,
400
401 /// Maximum CPU time in µs that a process scheduled under a real-time
402 /// scheduling policy may consume without making a blocking system
403 /// call before being forcibly descheduled.
404 RTTIME,
405
406 _,
407};
408
409/// TODO369/// TODO
410pub const ucontext_t = void;370pub const ucontext_t = void;
411371
lib/std/os/linux/sparc64.zig-60
...@@ -448,63 +448,3 @@ pub const ucontext_t = extern struct {...@@ -448,63 +448,3 @@ pub const ucontext_t = extern struct {
448448
449/// TODO449/// TODO
450pub const getcontext = {};450pub const getcontext = {};
451
452pub const rlimit_resource = enum(c_int) {
453 /// Per-process CPU limit, in seconds.
454 CPU,
455
456 /// Largest file that can be created, in bytes.
457 FSIZE,
458
459 /// Maximum size of data segment, in bytes.
460 DATA,
461
462 /// Maximum size of stack segment, in bytes.
463 STACK,
464
465 /// Largest core file that can be created, in bytes.
466 CORE,
467
468 /// Largest resident set size, in bytes.
469 /// This affects swapping; processes that are exceeding their
470 /// resident set size will be more likely to have physical memory
471 /// taken from them.
472 RSS,
473
474 /// Number of open files.
475 NOFILE,
476
477 /// Number of processes.
478 NPROC,
479
480 /// Locked-in-memory address space.
481 MEMLOCK,
482
483 /// Address space limit.
484 AS,
485
486 /// Maximum number of file locks.
487 LOCKS,
488
489 /// Maximum number of pending signals.
490 SIGPENDING,
491
492 /// Maximum bytes in POSIX message queues.
493 MSGQUEUE,
494
495 /// Maximum nice priority allowed to raise to.
496 /// Nice levels 19 .. -20 correspond to 0 .. 39
497 /// values of this resource limit.
498 NICE,
499
500 /// Maximum realtime priority allowed for non-privileged
501 /// processes.
502 RTPRIO,
503
504 /// Maximum CPU time in µs that a process scheduled under a real-time
505 /// scheduling policy may consume without making a blocking system
506 /// call before being forcibly descheduled.
507 RTTIME,
508
509 _,
510};
test/behavior/maximum_minimum.zig+2
...@@ -146,6 +146,8 @@ test "@min/max for floats" {...@@ -146,6 +146,8 @@ test "@min/max for floats" {
146 };146 };
147147
148 inline for (.{ f16, f32, f64, f80, f128, c_longdouble }) |T| {148 inline for (.{ f16, f32, f64, f80, f128, c_longdouble }) |T| {
149 if (T == c_longdouble and builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21090
150
149 try S.doTheTest(T);151 try S.doTheTest(T);
150 try comptime S.doTheTest(T);152 try comptime S.doTheTest(T);
151 }153 }
test/behavior/vector.zig+1
...@@ -773,6 +773,7 @@ test "vector reduce operation" {...@@ -773,6 +773,7 @@ test "vector reduce operation" {
773 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;773 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
774 if (builtin.zig_backend == .stage2_c and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest;774 if (builtin.zig_backend == .stage2_c and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest;
775 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;775 if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
776 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21091
776777
777 const S = struct {778 const S = struct {
778 fn testReduce(comptime op: std.builtin.ReduceOp, x: anytype, expected: anytype) !void {779 fn testReduce(comptime op: std.builtin.ReduceOp, x: anytype, expected: anytype) !void {
test/tests.zig+48
...@@ -365,6 +365,54 @@ const test_targets = blk: {...@@ -365,6 +365,54 @@ const test_targets = blk: {
365 .slow_backend = true,365 .slow_backend = true,
366 },366 },
367367
368 .{
369 .target = .{
370 .cpu_arch = .mips64,
371 .os_tag = .linux,
372 .abi = .none,
373 },
374 },
375 .{
376 .target = .{
377 .cpu_arch = .mips64,
378 .os_tag = .linux,
379 .abi = .musl,
380 },
381 .link_libc = true,
382 },
383 .{
384 .target = .{
385 .cpu_arch = .mips64,
386 .os_tag = .linux,
387 .abi = .gnuabi64,
388 },
389 .link_libc = true,
390 },
391
392 .{
393 .target = .{
394 .cpu_arch = .mips64el,
395 .os_tag = .linux,
396 .abi = .none,
397 },
398 },
399 .{
400 .target = .{
401 .cpu_arch = .mips64el,
402 .os_tag = .linux,
403 .abi = .musl,
404 },
405 .link_libc = true,
406 },
407 .{
408 .target = .{
409 .cpu_arch = .mips64el,
410 .os_tag = .linux,
411 .abi = .gnuabi64,
412 },
413 .link_libc = true,
414 },
415
368 .{416 .{
369 .target = .{417 .target = .{
370 .cpu_arch = .powerpc,418 .cpu_arch = .powerpc,