tools/nolibc: s390: provide custom implementation for sys_fork
authorThomas Weißschuh <linux@weissschuh.net>
Sat, 15 Apr 2023 21:28:47 +0000 (23:28 +0200)
committerPaul E. McKenney <paulmck@kernel.org>
Fri, 9 Jun 2023 18:46:07 +0000 (11:46 -0700)
On s390 the first two arguments to the clone() syscall are swapped,
as documented in clone(2).

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Cc: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
tools/include/nolibc/arch-s390.h
tools/include/nolibc/sys.h

index c62ee2472407e142d29779f04097fa84f5b1b0e5..a738e7f3f8e804b8ac82d5b74d2dd34ff3608acf 100644 (file)
@@ -5,6 +5,7 @@
 
 #ifndef _NOLIBC_ARCH_S390_H
 #define _NOLIBC_ARCH_S390_H
+#include <asm/signal.h>
 #include <asm/unistd.h>
 
 /* The struct returned by the stat() syscall, equivalent to stat64(). The
@@ -223,4 +224,12 @@ void *sys_mmap(void *addr, size_t length, int prot, int flags, int fd,
        return (void *)my_syscall1(__NR_mmap, &args);
 }
 #define sys_mmap sys_mmap
+
+static __attribute__((unused))
+pid_t sys_fork(void)
+{
+       return my_syscall5(__NR_clone, 0, SIGCHLD, 0, 0, 0);
+}
+#define sys_fork sys_fork
+
 #endif /* _NOLIBC_ARCH_S390_H */
index 1b9b91cd8b57016e3502ba7343d81fcc3f5572b9..60dffb1cbf961ac6d1491210e6ab41af299d22c3 100644 (file)
@@ -336,6 +336,7 @@ void exit(int status)
  * pid_t fork(void);
  */
 
+#ifndef sys_fork
 static __attribute__((unused))
 pid_t sys_fork(void)
 {
@@ -351,6 +352,7 @@ pid_t sys_fork(void)
 #error Neither __NR_clone nor __NR_fork defined, cannot implement sys_fork()
 #endif
 }
+#endif
 
 static __attribute__((unused))
 pid_t fork(void)