Commit fde1ec5d0e

Jacob Young <jacobly0@users.noreply.github.com>
2023-04-03 04:25:53
x86_64: remove returns from naked functions
1 parent 1980f54
Changed files (2)
lib
std
lib/std/os/linux/x86.zig
@@ -125,36 +125,44 @@ pub extern fn clone(func: CloneFn, stack: usize, flags: u32, arg: usize, ptid: *
 
 pub fn restore() callconv(.Naked) void {
     switch (@import("builtin").zig_backend) {
-        .stage2_c => return asm volatile (
+        .stage2_c => asm volatile (
             \\ movl %[number], %%eax
             \\ int $0x80
+            \\ ret
             :
             : [number] "i" (@enumToInt(SYS.sigreturn)),
             : "memory"
         ),
-        else => return asm volatile ("int $0x80"
+        else => asm volatile (
+            \\ int $0x80
+            \\ ret
             :
             : [number] "{eax}" (@enumToInt(SYS.sigreturn)),
             : "memory"
         ),
     }
+    unreachable;
 }
 
 pub fn restore_rt() callconv(.Naked) void {
     switch (@import("builtin").zig_backend) {
-        .stage2_c => return asm volatile (
+        .stage2_c => asm volatile (
             \\ movl %[number], %%eax
             \\ int $0x80
+            \\ ret
             :
             : [number] "i" (@enumToInt(SYS.rt_sigreturn)),
             : "memory"
         ),
-        else => return asm volatile ("int $0x80"
+        else => asm volatile (
+            \\ int $0x80
+            \\ ret
             :
             : [number] "{eax}" (@enumToInt(SYS.rt_sigreturn)),
             : "memory"
         ),
     }
+    unreachable;
 }
 
 pub const O = struct {
lib/std/os/linux/x86_64.zig
@@ -109,7 +109,7 @@ pub const restore = restore_rt;
 
 pub fn restore_rt() callconv(.Naked) void {
     switch (@import("builtin").zig_backend) {
-        .stage2_c => return asm volatile (
+        .stage2_c => asm volatile (
             \\ movl %[number], %%eax
             \\ syscall
             \\ retq
@@ -117,12 +117,15 @@ pub fn restore_rt() callconv(.Naked) void {
             : [number] "i" (@enumToInt(SYS.rt_sigreturn)),
             : "rcx", "r11", "memory"
         ),
-        else => return asm volatile ("syscall"
+        else => asm volatile (
+            \\ syscall
+            \\ retq
             :
             : [number] "{rax}" (@enumToInt(SYS.rt_sigreturn)),
             : "rcx", "r11", "memory"
         ),
     }
+    unreachable;
 }
 
 pub const mode_t = usize;