authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-04-02 22:25:53-04:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-04-03 17:45:16+02:00
logfde1ec5d0e57471b43bab226a78da2eb61e6bb66
tree463c6eff0089a919c6c004a9a83b2bac8b0c3770
parent1980f5479b2139112ff67de5d5f2e6af09fb215e

x86_64: remove returns from naked functions


2 files changed, 17 insertions(+), 6 deletions(-)

lib/std/os/linux/x86.zig+12-4
...@@ -125,36 +125,44 @@ pub extern fn clone(func: CloneFn, stack: usize, flags: u32, arg: usize, ptid: *...@@ -125,36 +125,44 @@ pub extern fn clone(func: CloneFn, stack: usize, flags: u32, arg: usize, ptid: *
125125
126pub fn restore() callconv(.Naked) void {126pub fn restore() callconv(.Naked) void {
127 switch (@import("builtin").zig_backend) {127 switch (@import("builtin").zig_backend) {
128 .stage2_c => return asm volatile (128 .stage2_c => asm volatile (
129 \\ movl %[number], %%eax129 \\ movl %[number], %%eax
130 \\ int $0x80130 \\ int $0x80
131 \\ ret
131 :132 :
132 : [number] "i" (@enumToInt(SYS.sigreturn)),133 : [number] "i" (@enumToInt(SYS.sigreturn)),
133 : "memory"134 : "memory"
134 ),135 ),
135 else => return asm volatile ("int $0x80"136 else => asm volatile (
137 \\ int $0x80
138 \\ ret
136 :139 :
137 : [number] "{eax}" (@enumToInt(SYS.sigreturn)),140 : [number] "{eax}" (@enumToInt(SYS.sigreturn)),
138 : "memory"141 : "memory"
139 ),142 ),
140 }143 }
144 unreachable;
141}145}
142146
143pub fn restore_rt() callconv(.Naked) void {147pub fn restore_rt() callconv(.Naked) void {
144 switch (@import("builtin").zig_backend) {148 switch (@import("builtin").zig_backend) {
145 .stage2_c => return asm volatile (149 .stage2_c => asm volatile (
146 \\ movl %[number], %%eax150 \\ movl %[number], %%eax
147 \\ int $0x80151 \\ int $0x80
152 \\ ret
148 :153 :
149 : [number] "i" (@enumToInt(SYS.rt_sigreturn)),154 : [number] "i" (@enumToInt(SYS.rt_sigreturn)),
150 : "memory"155 : "memory"
151 ),156 ),
152 else => return asm volatile ("int $0x80"157 else => asm volatile (
158 \\ int $0x80
159 \\ ret
153 :160 :
154 : [number] "{eax}" (@enumToInt(SYS.rt_sigreturn)),161 : [number] "{eax}" (@enumToInt(SYS.rt_sigreturn)),
155 : "memory"162 : "memory"
156 ),163 ),
157 }164 }
165 unreachable;
158}166}
159167
160pub const O = struct {168pub const O = struct {
lib/std/os/linux/x86_64.zig+5-2
...@@ -109,7 +109,7 @@ pub const restore = restore_rt;...@@ -109,7 +109,7 @@ pub const restore = restore_rt;
109109
110pub fn restore_rt() callconv(.Naked) void {110pub fn restore_rt() callconv(.Naked) void {
111 switch (@import("builtin").zig_backend) {111 switch (@import("builtin").zig_backend) {
112 .stage2_c => return asm volatile (112 .stage2_c => asm volatile (
113 \\ movl %[number], %%eax113 \\ movl %[number], %%eax
114 \\ syscall114 \\ syscall
115 \\ retq115 \\ retq
...@@ -117,12 +117,15 @@ pub fn restore_rt() callconv(.Naked) void {...@@ -117,12 +117,15 @@ pub fn restore_rt() callconv(.Naked) void {
117 : [number] "i" (@enumToInt(SYS.rt_sigreturn)),117 : [number] "i" (@enumToInt(SYS.rt_sigreturn)),
118 : "rcx", "r11", "memory"118 : "rcx", "r11", "memory"
119 ),119 ),
120 else => return asm volatile ("syscall"120 else => asm volatile (
121 \\ syscall
122 \\ retq
121 :123 :
122 : [number] "{rax}" (@enumToInt(SYS.rt_sigreturn)),124 : [number] "{rax}" (@enumToInt(SYS.rt_sigreturn)),
123 : "rcx", "r11", "memory"125 : "rcx", "r11", "memory"
124 ),126 ),
125 }127 }
128 unreachable;
126}129}
127130
128pub const mode_t = usize;131pub const mode_t = usize;