[git commit future] fork: provide __libc_fork only if THREADS are enabled

Peter S. Mazinger ps.m at gmx.net
Wed Apr 20 10:50:38 UTC 2011


commit: http://git.uclibc.org/uClibc/commit/?id=3f90b43e1fb48cbe7b43bb04953a03beb49c1d14
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/future

Signed-off-by: Peter S. Mazinger <ps.m at gmx.net>
---
 include/unistd.h                 |    2 ++
 libc/sysdeps/linux/common/fork.c |   18 +++++++++---------
 libc/sysdeps/linux/cris/fork.c   |   12 ++++++++----
 libc/sysdeps/linux/ia64/fork.S   |   14 +++++++++-----
 libc/sysdeps/linux/sparc/fork.S  |   17 +++++++++++------
 libc/sysdeps/linux/xtensa/fork.c |   17 ++++++++++-------
 6 files changed, 49 insertions(+), 31 deletions(-)

diff --git a/include/unistd.h b/include/unistd.h
index 9337c8b..e646e04 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -805,7 +805,9 @@ libc_hidden_proto(setresgid)
    and the process ID of the new process to the old process.  */
 extern __pid_t fork (void) __THROW;
 # ifdef _LIBC
+# ifdef __UCLIBC_HAS_THREADS__
 extern __typeof(fork) __libc_fork;
+# endif
 libc_hidden_proto(fork)
 # endif
 #endif
diff --git a/libc/sysdeps/linux/common/fork.c b/libc/sysdeps/linux/common/fork.c
index 88958b1..fa1f4af 100644
--- a/libc/sysdeps/linux/common/fork.c
+++ b/libc/sysdeps/linux/common/fork.c
@@ -8,15 +8,15 @@
  */
 
 #include <sys/syscall.h>
-#include <unistd.h>
 
-#ifdef __ARCH_USE_MMU__
-
-#ifdef __NR_fork
-#define __NR___libc_fork __NR_fork
-_syscall0(pid_t, __libc_fork)
-weak_alias(__libc_fork,fork)
+#if defined __NR_fork && defined __ARCH_USE_MMU__
+# include <unistd.h>
+# include <cancel.h>
+_syscall0(pid_t, fork)
+# ifdef __UCLIBC_HAS_THREADS__
+strong_alias(fork,__libc_fork)
 libc_hidden_weak(fork)
-#endif
-
+# else
+libc_hidden_def(fork)
+# endif
 #endif
diff --git a/libc/sysdeps/linux/cris/fork.c b/libc/sysdeps/linux/cris/fork.c
index 19aa172..7aff489 100644
--- a/libc/sysdeps/linux/cris/fork.c
+++ b/libc/sysdeps/linux/cris/fork.c
@@ -6,13 +6,17 @@
 
 #include "sysdep.h"
 
-#define __NR___libc_fork __NR_fork
-SYSCALL__ (__libc_fork, 0)
+#if defined __NR_fork && defined __ARCH_USE_MMU__
+# include <cancel.h>
+
+SYSCALL__ (fork, 0)
 	/* R1 is now 0 for the parent and 1 for the child.  Decrement it to
 	   make it -1 (all bits set) for the parent, and 0 (no bits set)
 	   for the child.  Then AND it with R0, so the parent gets
 	   R0&-1==R0, and the child gets R0&0==0.  */
      /* i dunno what the blurb above is useful for. we just return. */
 __asm__("ret\n\tnop");
-weak_alias(__libc_fork,fork)
-libc_hidden_weak(fork)
+
+lt_strong_alias(fork)
+lt_libc_hidden(fork)
+#endif
diff --git a/libc/sysdeps/linux/ia64/fork.S b/libc/sysdeps/linux/ia64/fork.S
index 0023a3b..968bb1c 100644
--- a/libc/sysdeps/linux/ia64/fork.S
+++ b/libc/sysdeps/linux/ia64/fork.S
@@ -24,7 +24,10 @@
 /* pid_t fork(void); */
 /* Implemented as a clone system call with parameters SIGCHLD and 0	*/
 
-ENTRY(__libc_fork)
+#ifdef __UCLIBC_HAS_THREADS__
+.weak fork
+#endif
+ENTRY(fork)
 	alloc r2=ar.pfs,0,0,2,0
 	mov out0=SIGCHLD	/* Return SIGCHLD when child finishes	*/
 				/* no other clone flags; nothing shared	*/
@@ -34,7 +37,8 @@ ENTRY(__libc_fork)
 	cmp.eq p6,p0=-1,r10
 (p6)	br.cond.spnt.few __syscall_error
 	ret
-PSEUDO_END(__libc_fork)
-
-weak_alias (__libc_fork, fork)
-libc_hidden_weak (fork)
+PSEUDO_END(fork)
+#ifdef __UCLIBC_HAS_THREADS__
+strong_alias(fork,__libc_fork)
+#endif
+libc_hidden_def(fork)
diff --git a/libc/sysdeps/linux/sparc/fork.S b/libc/sysdeps/linux/sparc/fork.S
index 7ead409..1795eb6 100644
--- a/libc/sysdeps/linux/sparc/fork.S
+++ b/libc/sysdeps/linux/sparc/fork.S
@@ -23,11 +23,14 @@
 #include <sys/syscall.h>
 
 .text
-.global	__libc_fork
-.type	__libc_fork,%function
+.global	fork
+#ifdef __UCLIBC_HAS_THREADS__
+.weak   fork
+#endif
+.type	fork,%function
 .align 4
 
-__libc_fork:
+fork:
 	mov __NR_fork, %g1
 	ta	0x10
 	bcc,a	9000f
@@ -44,6 +47,8 @@ __libc_fork:
 	retl
 	and	%o0, %o1, %o0
 
-.size __libc_fork,.-__libc_fork
-weak_alias(__libc_fork,fork)
-libc_hidden_weak(fork)
+.size fork,.-fork
+#ifdef __UCLIBC_HAS_THREADS__
+strong_alias(fork,__libc_fork)
+#endif
+libc_hidden_def(fork)
diff --git a/libc/sysdeps/linux/xtensa/fork.c b/libc/sysdeps/linux/xtensa/fork.c
index f8b77bf..e9b681c 100644
--- a/libc/sysdeps/linux/xtensa/fork.c
+++ b/libc/sysdeps/linux/xtensa/fork.c
@@ -7,16 +7,19 @@
  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  */
 
-#include <unistd.h>
-#include <sys/syscall.h>
-#define _SIGNAL_H
-#include <bits/signum.h>
 
 /* Xtensa doesn't provide a 'fork' system call, so we use 'clone'.  */
+#include <sys/syscall.h>
+
+#if defined __NR_clone && defined __ARCH_USE_MMU__
+# include <unistd.h>
+# include <signal.h>
+# include <cancel.h>
 
-pid_t __libc_fork(void)
+pid_t fork(void)
 {
 	return (pid_t) INLINE_SYSCALL(clone, 2, SIGCHLD, 0);
 }
-weak_alias(__libc_fork, fork)
-libc_hidden_weak(fork)
+lt_strong_alias(fork)
+lt_libc_hidden(fork)
+#endif
-- 
1.7.3.4



More information about the uClibc-cvs mailing list