authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-06-27 18:27:06-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-06-27 18:27:06-07:00
log0b8bd9b2b4f609fb4ae7d31da7e7a0fd4f5ad987
treec5c11adbecdba4ecd60fa45d612a57d3f9a9d8c6
parentdf1f401cf0e997ed289e14f69ab1114e839b56ee

std.os.linux.clone: upgrade to stage2 fn ptr semantics


7 files changed, 42 insertions(+), 7 deletions(-)

lib/std/os/linux/arm64.zig+6-1
...@@ -98,8 +98,13 @@ pub fn syscall6(...@@ -98,8 +98,13 @@ pub fn syscall6(
98 );98 );
99}99}
100100
101const CloneFn = switch (@import("builtin").zig_backend) {
102 .stage1 => fn (arg: usize) callconv(.C) u8,
103 else => *const fn (arg: usize) callconv(.C) u8,
104};
105
101/// This matches the libc clone function.106/// This matches the libc clone function.
102pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;107pub extern fn clone(func: CloneFn, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
103108
104pub const restore = restore_rt;109pub const restore = restore_rt;
105110
lib/std/os/linux/i386.zig+6-1
...@@ -118,8 +118,13 @@ pub fn socketcall(call: usize, args: [*]usize) usize {...@@ -118,8 +118,13 @@ pub fn socketcall(call: usize, args: [*]usize) usize {
118 );118 );
119}119}
120120
121const CloneFn = switch (@import("builtin").zig_backend) {
122 .stage1 => fn (arg: usize) callconv(.C) u8,
123 else => *const fn (arg: usize) callconv(.C) u8,
124};
125
121/// This matches the libc clone function.126/// This matches the libc clone function.
122pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;127pub extern fn clone(func: CloneFn, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
123128
124pub fn restore() callconv(.Naked) void {129pub fn restore() callconv(.Naked) void {
125 return asm volatile ("int $0x80"130 return asm volatile ("int $0x80"
lib/std/os/linux/mips.zig+6-1
...@@ -190,8 +190,13 @@ pub fn syscall7(...@@ -190,8 +190,13 @@ pub fn syscall7(
190 );190 );
191}191}
192192
193const CloneFn = switch (@import("builtin").zig_backend) {
194 .stage1 => fn (arg: usize) callconv(.C) u8,
195 else => *const fn (arg: usize) callconv(.C) u8,
196};
197
193/// This matches the libc clone function.198/// This matches the libc clone function.
194pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;199pub extern fn clone(func: CloneFn, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
195200
196pub fn restore() callconv(.Naked) void {201pub fn restore() callconv(.Naked) void {
197 return asm volatile ("syscall"202 return asm volatile ("syscall"
lib/std/os/linux/powerpc.zig+6-1
...@@ -126,8 +126,13 @@ pub fn syscall6(...@@ -126,8 +126,13 @@ pub fn syscall6(
126 );126 );
127}127}
128128
129const CloneFn = switch (@import("builtin").zig_backend) {
130 .stage1 => fn (arg: usize) callconv(.C) u8,
131 else => *const fn (arg: usize) callconv(.C) u8,
132};
133
129/// This matches the libc clone function.134/// This matches the libc clone function.
130pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: usize, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;135pub extern fn clone(func: CloneFn, stack: usize, flags: usize, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
131136
132pub const restore = restore_rt;137pub const restore = restore_rt;
133138
lib/std/os/linux/powerpc64.zig+6-1
...@@ -126,8 +126,13 @@ pub fn syscall6(...@@ -126,8 +126,13 @@ pub fn syscall6(
126 );126 );
127}127}
128128
129const CloneFn = switch (@import("builtin").zig_backend) {
130 .stage1 => fn (arg: usize) callconv(.C) u8,
131 else => *const fn (arg: usize) callconv(.C) u8,
132};
133
129/// This matches the libc clone function.134/// This matches the libc clone function.
130pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: usize, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;135pub extern fn clone(func: CloneFn, stack: usize, flags: usize, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
131136
132pub const restore = restore_rt;137pub const restore = restore_rt;
133138
lib/std/os/linux/riscv64.zig+6-1
...@@ -95,7 +95,12 @@ pub fn syscall6(...@@ -95,7 +95,12 @@ pub fn syscall6(
95 );95 );
96}96}
9797
98pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;98const CloneFn = switch (@import("builtin").zig_backend) {
99 .stage1 => fn (arg: usize) callconv(.C) u8,
100 else => *const fn (arg: usize) callconv(.C) u8,
101};
102
103pub extern fn clone(func: CloneFn, stack: usize, flags: u32, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
99104
100pub const restore = restore_rt;105pub const restore = restore_rt;
101106
lib/std/os/linux/sparc64.zig+6-1
...@@ -178,8 +178,13 @@ pub fn syscall6(...@@ -178,8 +178,13 @@ pub fn syscall6(
178 );178 );
179}179}
180180
181const CloneFn = switch (@import("builtin").zig_backend) {
182 .stage1 => fn (arg: usize) callconv(.C) u8,
183 else => *const fn (arg: usize) callconv(.C) u8,
184};
185
181/// This matches the libc clone function.186/// This matches the libc clone function.
182pub extern fn clone(func: fn (arg: usize) callconv(.C) u8, stack: usize, flags: usize, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;187pub extern fn clone(func: CloneFn, stack: usize, flags: usize, arg: usize, ptid: *i32, tls: usize, ctid: *i32) usize;
183188
184pub const restore = restore_rt;189pub const restore = restore_rt;
185190