summaryrefslogtreecommitdiff
path: root/src/internal/syscall.h
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2024-02-22 18:50:34 -0500
committerRich Felker <dalias@aerifal.cx>2024-02-22 18:50:34 -0500
commit19563e1850808af216b1b84263bb7e83cccce506 (patch)
tree76aa0be0c61791fcae503569477efb87401cb83e /src/internal/syscall.h
parent7020e85fd768be02e7f5971f1707229407cfa1e4 (diff)
downloadmusl-19563e1850808af216b1b84263bb7e83cccce506.tar.gz
add framework to support archs without a native wait4 syscall
this commit should make no codegen change for existing archs, but is a prerequisite for new archs including riscv32. the wait4 emulation backend provides both cancellable and non-cancellable variants because waitpid is required to be a cancellation point, but all of our other uses are not, and most of them cannot be. based on patch by Stefan O'Rear.
Diffstat (limited to 'src/internal/syscall.h')
-rw-r--r--src/internal/syscall.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/internal/syscall.h b/src/internal/syscall.h
index 4a446157..33d981f9 100644
--- a/src/internal/syscall.h
+++ b/src/internal/syscall.h
@@ -391,6 +391,18 @@ static inline long __alt_socketcall(int sys, int sock, int cp, syscall_arg_t a,
#define __sys_open_cp(...) __SYSCALL_DISP(__sys_open_cp,,__VA_ARGS__)
#define sys_open_cp(...) __syscall_ret(__sys_open_cp(__VA_ARGS__))
+#ifdef SYS_wait4
+#define __sys_wait4(a,b,c,d) __syscall(SYS_wait4,a,b,c,d)
+#define __sys_wait4_cp(a,b,c,d) __syscall_cp(SYS_wait4,a,b,c,d)
+#else
+hidden long __emulate_wait4(int, int *, int, void *, int);
+#define __sys_wait4(a,b,c,d) __emulate_wait4(a,b,c,d,0)
+#define __sys_wait4_cp(a,b,c,d) __emulate_wait4(a,b,c,d,1)
+#endif
+
+#define sys_wait4(a,b,c,d) __syscall_ret(__sys_wait4(a,b,c,d))
+#define sys_wait4_cp(a,b,c,d) __syscall_ret(__sys_wait4_cp(a,b,c,d))
+
hidden void __procfdname(char __buf[static 15+3*sizeof(int)], unsigned);
hidden void *__vdsosym(const char *, const char *);