sparc: Fix arch_fork definition
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 28 Mar 2018 00:23:52 +0000 (21:23 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 28 Mar 2018 00:28:58 +0000 (21:28 -0300)
This patch fixes 3dc214977 for sparc.  Different than other architectures
SPARC kernel Kconfig does not define CONFIG_CLONE_BACKWARDS, however it
has the same ABI as if it did, implemented by sparc-specific code
(sparc_do_fork).

It also has a unique return value convention for clone:

   Parent -->  %o0 == child's  pid, %o1 == 0
   Child  -->  %o0 == parent's pid, %o1 == 1

Which required a special macro to correct issue the syscall
(INLINE_CLONE_SYSCALL).

Checked on sparc64-linux-gnu and sparcv9-linux-gnu.

* sysdeps/unix/sysv/linux/arch-fork.h [__ASSUME_CLONE_BACKWARDS]
(arch_fork): Issue INLINE_CLONE_SYSCALL if defined.
* sysdeps/unix/sysv/linux/sparc/kernel-features.h
(__ASSUME_CLONE_BACKWARDS): Define.

ChangeLog
sysdeps/unix/sysv/linux/arch-fork.h
sysdeps/unix/sysv/linux/sparc/kernel-features.h

index 7f2044d..6412367 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2018-03-27  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
+
+       * sysdeps/unix/sysv/linux/arch-fork.h [__ASSUME_CLONE_BACKWARDS]
+       (arch_fork): Issue INLINE_CLONE_SYSCALL if defined.
+       * sysdeps/unix/sysv/linux/sparc/kernel-features.h
+       (__ASSUME_CLONE_BACKWARDS): Define.
+
 2018-03-27  Jesse Hathaway  <jesse@mbuki-mvuki.org>
 
        * sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid): Return
index 3daa965..046d9fc 100644 (file)
@@ -34,7 +34,11 @@ arch_fork (void *ctid)
   const int flags = CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD;
   long int ret;
 #ifdef __ASSUME_CLONE_BACKWARDS
+# ifdef INLINE_CLONE_SYSCALL
+  ret = INLINE_CLONE_SYSCALL (flags, 0, NULL, 0, ctid);
+# else
   ret = INLINE_SYSCALL_CALL (clone, flags, 0, NULL, 0, ctid);
+# endif
 #elif defined(__ASSUME_CLONE_BACKWARDS2)
   ret = INLINE_SYSCALL_CALL (clone, 0, flags, NULL, ctid, 0);
 #elif defined(__ASSUME_CLONE_BACKWARDS3)
index 2fd12cb..64d7140 100644 (file)
 
 /* sparc only supports ipc syscall.  */
 #undef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
+
+/* SPARC kernel Kconfig does not define CONFIG_CLONE_BACKWARDS, however it
+   has the same ABI as if it did, implemented by sparc-specific code
+   (sparc_do_fork).
+
+   It also has a unique return value convention:
+
+     Parent -->  %o0 == child's  pid, %o1 == 0
+     Child  -->  %o0 == parent's pid, %o1 == 1
+
+   Which required a special macro to correct issue the syscall
+   (INLINE_CLONE_SYSCALL).  */
+#undef __ASSUME_CLONE_DEFAULT
+#define __ASSUME_CLONE_BACKWARDS       1