From d021e6252b33e779857846714fb1899a25c9965d Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sat, 23 Jun 2012 15:59:01 -0700
Subject: [PATCH] nptl/atfork: Hide pthread_atfork in shared versions

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Upstream-Status: Pending
---
 libpthread/nptl/Makefile.in      |    4 +++-
 libpthread/nptl/pthread_atfork.c |   12 ++++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/libpthread/nptl/Makefile.in b/libpthread/nptl/Makefile.in
index 158bcae..3ef7175 100644
--- a/libpthread/nptl/Makefile.in
+++ b/libpthread/nptl/Makefile.in
@@ -16,6 +16,7 @@ libc-shared-routines-y = forward.c libc-cancellation.c
 libc-static-routines-y = alloca_cutoff.c libc-cancellation.c
 libpthread-shared-only-routines-y = version.c
 libpthread-static-only-routines-y = pthread_atfork.c
+
 libpthread-routines- += $(notdir $(wildcard $(libpthread_DIR)/gen_*.c)) # dummy generated files
 libpthread-routines- += allocatestack.c # dummy included by pthread_create.c
 libpthread-routines- += pthread_mutex_getprioceiling.c pthread_mutex_setprioceiling.c # XXX: delete those or use them!
@@ -208,7 +209,7 @@ CFLAGS-msgsnd.c = -fexceptions -fasynchronous-unwind-tables
 CFLAGS-tcdrain.c = -fexceptions -fasynchronous-unwind-tables
 
 CFLAGS-pt-system.c = -fexceptions -I$(top_srcdir)libc/stdlib
-
+CFLAGS-pthread_atfork.c = -DNOT_IN_libc
 #
 # The rest of this file is uClibc specific.
 #
@@ -224,3 +225,4 @@ CFLAGS-OMIT-alloca_cutoff.c = $(CFLAGS-nptl)
 CFLAGS-OMIT-forward.c = $(CFLAGS-nptl)
 CFLAGS-OMIT-libc-lowlevelock.c = $(CFLAGS-nptl)
 CFLAGS-OMIT-libc-cancellation.c = $(CFLAGS-nptl)
+
diff --git a/libpthread/nptl/pthread_atfork.c b/libpthread/nptl/pthread_atfork.c
index e607d49..6224c17 100644
--- a/libpthread/nptl/pthread_atfork.c
+++ b/libpthread/nptl/pthread_atfork.c
@@ -38,13 +38,17 @@
 #include <fork.h>
 
 /* This is defined by newer gcc version unique for each module.  */
-extern void *__dso_handle __attribute__ ((__weak__));
-					  //,__visibility__ ("hidden")));
+extern void *__dso_handle __attribute__ ((__weak__,
+					  __visibility__ ("hidden")));
 
 
 /* Hide the symbol so that no definition but the one locally in the
    executable or DSO is used.  */
 int
+#ifndef __pthread_atfork
+/* Don't mark the compatibility function as hidden.  */
+attribute_hidden
+#endif
 __pthread_atfork (
      void (*prepare) (void),
      void (*parent) (void),
@@ -53,4 +57,8 @@ __pthread_atfork (
   return __register_atfork (prepare, parent, child,
 			    &__dso_handle == NULL ? NULL : __dso_handle);
 }
+#ifndef __pthread_atfork
+extern int pthread_atfork (void (*prepare) (void), void (*parent) (void),
+	                           void (*child) (void)) attribute_hidden;
 strong_alias (__pthread_atfork, pthread_atfork)
+#endif
-- 
1.7.9.5

