authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-09-16 07:25:46+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-09-16 07:25:46+02:00
log5c4b14b6828b6de047a00e342de354cb69367f72
treea9bd9b3825bd49ba51b13c069c1ed10b0b51b773
parent98d4ee649dfb06d224ea6a57e63dda2557ed0229
parent1235bc67e20730dbf8741f56a15ac21989d72833

Merge pull request 'some miscellaneous fixes' (#36851) from alexrp/zig:stuff into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/36851

12 files changed, 28 insertions(+), 48 deletions(-)

lib/std/os/linux/hexagon.zig-1
......@@ -136,7 +136,6 @@ pub fn clone() callconv(.naked) u32 {
136136 \\ callr r11
137137 \\
138138 \\ r6 = #93 // SYS_exit
139 \\ r0 = #0
140139 \\ trap0(#1)
141140 );
142141}
lib/std/os/linux/microblaze.zig+3-2
......@@ -130,11 +130,11 @@ pub fn clone() callconv(.naked) u32 {
130130 \\ brki r14, 0x8
131131 \\ beqi r3, 1f
132132 \\
133 \\ // parent
133 \\ # parent
134134 \\ rtsd r15, 8
135135 \\ nop
136136 \\
137 \\ // child
137 \\ # child
138138 \\1:
139139 \\ ori r15, r0, 0
140140 \\ ori r19, r0, 0
......@@ -144,6 +144,7 @@ pub fn clone() callconv(.naked) u32 {
144144 \\ brald r15, r3
145145 \\ nop
146146 \\
147 \\ ori r5, r3, 0
147148 \\ ori r12, r0, 1 # SYS_exit
148149 \\ brki r14, 0x8
149150 );
lib/std/os/linux/mips.zig+1
......@@ -190,6 +190,7 @@ pub fn syscall_pipe(
190190 \\1:
191191 \\ sw $v0, 0($a0)
192192 \\ sw $v1, 4($a0)
193 \\ move $v0, $zero
193194 \\2:
194195 : [ret] "={$2}" (-> u32),
195196 : [number] "{$2}" (@backingInt(SYS.pipe)),
lib/std/os/linux/mips64.zig+1
......@@ -148,6 +148,7 @@ pub fn syscall_pipe(
148148 \\1:
149149 \\ sw $v0, 0($a0)
150150 \\ sw $v1, 4($a0)
151 \\ move $v0, $zero
151152 \\2:
152153 : [ret] "={$2}" (-> u64),
153154 : [number] "{$2}" (@backingInt(SYS.pipe)),
lib/std/os/linux/mipsn32.zig+1
......@@ -148,6 +148,7 @@ pub fn syscall_pipe(
148148 \\1:
149149 \\ sw $v0, 0($a0)
150150 \\ sw $v1, 4($a0)
151 \\ move $v0, $zero
151152 \\2:
152153 : [ret] "={$2}" (-> u32),
153154 : [number] "{$2}" (@backingInt(SYS.pipe)),
lib/std/os/linux/or1k.zig+5-5
......@@ -120,8 +120,8 @@ pub fn clone() callconv(.naked) u32 {
120120 // __clone(func, stack, flags, arg, ptid, tls, ctid)
121121 // r3, r4, r5, r6, r7, r8, +0
122122 //
123 // syscall(SYS_clone, flags, stack, ptid, tls, ctid)
124 // r11 r3, r4, r5, r6, r7
123 // syscall(SYS_clone, flags, stack, ptid, ctid, tls)
124 // r11 r3, r4, r5, r6, r7
125125 asm volatile (
126126 \\ # Save function pointer and argument pointer on new thread stack
127127 \\ l.addi r13, r0, -4
......@@ -134,8 +134,8 @@ pub fn clone() callconv(.naked) u32 {
134134 \\ l.ori r11, r0, 220 # SYS_clone
135135 \\ l.ori r3, r5, 0
136136 \\ l.ori r5, r7, 0
137 \\ l.ori r6, r8, 0
138 \\ l.lwz r7, 0(r1)
137 \\ l.lwz r6, 0(r1)
138 \\ l.ori r7, r8, 0
139139 \\ l.sys 1
140140 \\ l.sfeqi r11, 0
141141 \\ l.bf 1f
......@@ -145,7 +145,7 @@ pub fn clone() callconv(.naked) u32 {
145145 \\1:
146146 );
147147 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
148 \\ .cfi_undefined r9
148 \\ .cfi_undefined 9
149149 );
150150 asm volatile (
151151 \\ l.ori r2, r0, 0
lib/std/os/linux/sh.zig+3-2
......@@ -179,11 +179,11 @@ pub fn clone() callconv(.naked) u32 {
179179 \\ cmp/eq #0, r0
180180 \\ bt 1f
181181 \\
182 \\ // parent
182 \\ ! parent
183183 \\ rts
184184 \\ nop
185185 \\
186 \\ // child
186 \\ ! child
187187 \\1:
188188 );
189189 if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile (
......@@ -199,6 +199,7 @@ pub fn clone() callconv(.naked) u32 {
199199 \\ nop
200200 \\
201201 \\ mov #1, r3 ! SYS_exit
202 \\ mov r0, r4
202203 \\ trapa #31
203204 \\ or r0, r0
204205 \\ or r0, r0
lib/std/os/linux/xtensa.zig+2
......@@ -151,6 +151,8 @@ pub fn clone() callconv(.naked) u32 {
151151 \\
152152 \\ mov a2, a10
153153 \\ callx0 a9
154 \\
155 \\ mov a6, a2
154156 ) else asm volatile (
155157 \\ beqz a2, 1f
156158 \\ // parent
lib/std/os/windows.zig+6-8
......@@ -3645,14 +3645,12 @@ pub fn teb() *TEB {
36453645}
36463646
36473647pub fn peb() *PEB {
3648 if (builtin.zig_backend == .stage2_c) switch (native_arch) {
3649 .x86, .x86_64 => return @ptrCast(@alignCast(struct {
3650 /// This is a workaround for the C backend until zig has the ability to put
3651 /// C code in inline assembly.
3652 extern fn zig_windows_peb() callconv(.c) *anyopaque;
3653 }.zig_windows_peb())),
3654 else => {},
3655 } else switch (native_arch) {
3648 if (builtin.zig_backend == .stage2_c) return @ptrCast(@alignCast(struct {
3649 /// This is a workaround for the C backend until zig has the ability to put
3650 /// C code in inline assembly.
3651 extern fn zig_windows_peb() callconv(.c) *anyopaque;
3652 }.zig_windows_peb()));
3653 switch (native_arch) {
36563654 .aarch64 => {
36573655 comptime assert(@offsetOf(TEB, "ProcessEnvironmentBlock") == 0x60);
36583656 return asm (
lib/std/start.zig+1-1
......@@ -189,7 +189,7 @@ fn _start() callconv(.naked) noreturn {
189189 .m88k => ".cfi_undefined %%r1",
190190 .microblaze, .microblazeel => "", // No CFI support.
191191 .mips, .mipsel, .mips64, .mips64el => ".cfi_undefined $ra",
192 .or1k => ".cfi_undefined r9",
192 .or1k => ".cfi_undefined 9",
193193 .powerpc, .powerpcle, .powerpc64, .powerpc64le => ".cfi_undefined lr",
194194 .riscv32, .riscv32be, .riscv64, .riscv64be => if (builtin.zig_backend == .stage2_riscv64)
195195 ""
lib/std/zig/system/loongarch.zig+4-16
......@@ -94,21 +94,9 @@ pub fn detectNativeCpuAndFeatures(
9494 return cpu;
9595}
9696
97/// This is a workaround for the C backend until zig has the ability to put
98/// C code in inline assembly.
99extern fn zig_loongarch_cpucfg(word: u32, result: *u32) callconv(.c) void;
100
10197fn cpucfg(word: u32) u32 {
102 var result: u32 = undefined;
103
104 if (builtin.zig_backend == .stage2_c) {
105 zig_loongarch_cpucfg(word, &result);
106 } else {
107 asm ("cpucfg %[result], %[word]"
108 : [result] "=r" (result),
109 : [word] "r" (word),
110 );
111 }
112
113 return result;
98 return asm ("cpucfg %[result], %[word]"
99 : [result] "=r" (-> u32),
100 : [word] "r" (word),
101 );
114102}
lib/zig.h+1-13
......@@ -6750,19 +6750,7 @@ static inline void* zig_e_zig_windows_peb(void) {
67506750
67516751#endif
67526752
6753#if defined(zig_loongarch)
6754
6755static inline void zig_e_zig_loongarch_cpucfg(uint32_t word, uint32_t* result) zig_mangled(zig_e_zig_loongarch_cpucfg, "zig_loongarch_cpucfg");
6756
6757static inline void zig_e_zig_loongarch_cpucfg(uint32_t word, uint32_t* result) {
6758#if defined(zig_gnuc_asm)
6759 __asm__("cpucfg %[result], %[word]" : [result] "=r" (*result) : [word] "r" (word));
6760#else
6761 *result = 0;
6762#endif
6763}
6764
6765#elif defined(zig_x86) && !defined(zig_x86_16)
6753#if defined(zig_x86) && !defined(zig_x86_16)
67666754
67676755static inline void zig_e_zig_x86_cpuid(uint32_t leaf_id, uint32_t subid, uint32_t* eax, uint32_t* ebx, uint32_t* ecx, uint32_t* edx) zig_mangled(zig_e_zig_x86_cpuid, "zig_x86_cpuid");
67686756static inline uint32_t zig_e_zig_x86_get_xcr0(void) zig_mangled(zig_e_zig_x86_get_xcr0, "zig_x86_get_xcr0");