about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2018-04-02 18:08:37 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2018-04-02 18:08:37 +0000
commitf6fb29d22eefb208c0c7da463c31229d50ccbe01 (patch)
tree3db5f5950b7fb2ae65d2fc09f33fab2646687c94 /sysdeps
parentfa9e15558d711c098183be531043eae465b81036 (diff)
downloadglibc-f6fb29d22eefb208c0c7da463c31229d50ccbe01.tar.gz
glibc-f6fb29d22eefb208c0c7da463c31229d50ccbe01.tar.xz
glibc-f6fb29d22eefb208c0c7da463c31229d50ccbe01.zip
hurd: Avoid local PLTs in libpthread.
	* htl/cthreads-compat.c (__cthread_detach): Call __pthread_detach
	instead of pthread_detach.
	(__cthread_fork): Call __pthread_create instead of pthread_create.
	(__cthread_keycreate): Call __pthread_key_create instead of
	pthread_key_create.
	(__cthread_getspecific): Call __pthread_getspecific instead of
	pthread_getspecific.
	(__cthread_setspecific): Call __pthread_setspecific instead of
	pthread_setspecific.
	* htl/pt-alloc.c (__pthread_alloc): Call __pthread_mutex_lock and
	__pthread_mutex_unlock instead of pthread_mutex_lock and
	pthread_mutex_unlock.
	* htl/pt-cleanup.c (__pthread_get_cleanup_stack): Rename to
	___pthread_get_cleanup_stack.
	(__pthread_get_cleanup_stack): New strong alias.
	* htl/pt-create.c: Include <pthreadP.h>.
	(entry_point): Call __pthread_exit instead of pthread_exit.
	(pthread_create): Rename to __pthread_create.
	(pthread_create): New strong alias.
	* htl/pt-detach.c (pthread_detach): Rename to __pthread_detach.
	(pthread_detach): New strong alias.
	(__pthread_detach): Call __pthread_cond_broadcast instead of
	pthread_cond_broadcast.
	* htl/pt-exit.c (__pthread_exit): Call __pthread_setcancelstate
	instead of pthread_setcancelstate.
	* htl/pt-testcancel.c: Include <pthreadP.h>.
	(pthread_testcancel): Call __pthread_exit instead of pthread_exit.
	* sysdeps/htl/pt-attr-getstack.c: Include <pthreadP.h>
	(__pthread_attr_getstack): Call __pthread_attr_getstackaddr and
	__pthread_attr_getstacksize instead of pthread_attr_getstackaddr and
	pthread_attr_getstacksize.
	* sysdeps/htl/pt-attr-getstackaddr.c (pthread_attr_getstackaddr):
	Rename to __pthread_attr_getstackaddr.
	(pthread_attr_getstackaddr): New strong alias.
	* sysdeps/htl/pt-attr-getstacksize.c (pthread_attr_getstacksize):
	Rename to __pthread_attr_getstacksize.
	(pthread_attr_getstacksize): New strong alias.
	* sysdeps/htl/pt-attr-setstack.c: Include <pthreadP.h>.
	(pthread_attr_setstack): Rename to __pthread_attr_setstack.
	(pthread_attr_setstack): New strong alias.
	(__pthread_attr_setstack): Call __pthread_attr_getstacksize,
	__pthread_attr_setstacksize and __pthread_attr_setstackaddr instead of
	pthread_attr_getstacksize, pthread_attr_setstacksize and
	pthread_attr_setstackaddr.
	* sysdeps/htl/pt-attr-setstackaddr.c (pthread_attr_setstackaddr):
	Rename to __pthread_attr_setstackaddr.
	(pthread_attr_setstackaddr): New strong alias.
	* sysdeps/htl/pt-attr-setstacksize.c (pthread_attr_setstacksize):
	Rename to __pthread_attr_setstacksize.
	(pthread_attr_setstacksize): New strong alias.
	* sysdeps/htl/pt-cond-timedwait.c: Include <pthreadP.h>.
	(__pthread_cond_timedwait_internal): Use __pthread_exit instead of
	pthread_exit.
	* sysdeps/htl/pt-key-create.c: Include <pthreadP.h>.
	(__pthread_key_create): New hidden def.
	* sysdeps/htl/pt-key.h: Include <pthreadP.h>.
	* sysdeps/htl/pthreadP.h (_pthread_mutex_init,
	__pthread_cond_broadcast, __pthread_create, __pthread_detach,
	__pthread_exit, __pthread_key_create, __pthread_getspecific,
	__pthread_setspecific, __pthread_setcancelstate,
	__pthread_attr_getstackaddr, __pthread_attr_setstackaddr,
	__pthread_attr_getstacksize, __pthread_attr_setstacksize,
	__pthread_attr_setstack, ___pthread_get_cleanup_stack): New
	declarations.
	(__pthread_key_create, _pthread_mutex_init): New hidden declarations.
	* sysdeps/mach/hurd/htl/pt-attr-setstackaddr.c
	(pthread_attr_setstackaddr): Rename to __pthread_attr_setstackaddr.
	(pthread_attr_setstackaddr): New strong alias.
	* sysdeps/mach/hurd/htl/pt-attr-setstacksize.c
	(pthread_attr_setstacksize): Rename to __pthread_attr_setstacksize.
	(pthread_attr_setstacksize): New strong alias.
	* sysdeps/mach/hurd/htl/pt-docancel.c: Include <pthreadP.h>.
	(call_exit): Call __pthread_exit instead of pthread_exit.
	* sysdeps/mach/hurd/htl/pt-mutex-init.c: Include <pthreadP.h>.
	(_pthread_mutex_init): New hidden definition.
	* sysdeps/mach/hurd/htl/pt-sysdep.c: Include <pthreadP.h>.
	(_init_routine): Call __pthread_attr_init and __pthread_attr_setstack
	instead of pthread_attr_init and pthread_attr_setstack.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/htl/pt-attr-getstack.c5
-rw-r--r--sysdeps/htl/pt-attr-getstackaddr.c3
-rw-r--r--sysdeps/htl/pt-attr-getstacksize.c3
-rw-r--r--sysdeps/htl/pt-attr-setstack.c12
-rw-r--r--sysdeps/htl/pt-attr-setstackaddr.c3
-rw-r--r--sysdeps/htl/pt-attr-setstacksize.c4
-rw-r--r--sysdeps/htl/pt-cond-timedwait.c5
-rw-r--r--sysdeps/htl/pt-key-create.c2
-rw-r--r--sysdeps/htl/pt-key.h1
-rw-r--r--sysdeps/htl/pthreadP.h28
-rw-r--r--sysdeps/mach/hurd/htl/pt-attr-setstackaddr.c3
-rw-r--r--sysdeps/mach/hurd/htl/pt-attr-setstacksize.c3
-rw-r--r--sysdeps/mach/hurd/htl/pt-docancel.c3
-rw-r--r--sysdeps/mach/hurd/htl/pt-mutex-init.c2
-rw-r--r--sysdeps/mach/hurd/htl/pt-sysdep.c5
15 files changed, 63 insertions, 19 deletions
diff --git a/sysdeps/htl/pt-attr-getstack.c b/sysdeps/htl/pt-attr-getstack.c
index db04665bfc..6d8b286889 100644
--- a/sysdeps/htl/pt-attr-getstack.c
+++ b/sysdeps/htl/pt-attr-getstack.c
@@ -18,13 +18,14 @@
 
 #include <pthread.h>
 #include <pt-internal.h>
+#include <pthreadP.h>
 
 int
 __pthread_attr_getstack (const pthread_attr_t *attr,
 			 void **stackaddr, size_t * stacksize)
 {
-  pthread_attr_getstackaddr (attr, stackaddr);
-  pthread_attr_getstacksize (attr, stacksize);
+  __pthread_attr_getstackaddr (attr, stackaddr);
+  __pthread_attr_getstacksize (attr, stacksize);
   return 0;
 }
 weak_alias (__pthread_attr_getstack, pthread_attr_getstack)
diff --git a/sysdeps/htl/pt-attr-getstackaddr.c b/sysdeps/htl/pt-attr-getstackaddr.c
index 63661c26dc..6f2507a0c1 100644
--- a/sysdeps/htl/pt-attr-getstackaddr.c
+++ b/sysdeps/htl/pt-attr-getstackaddr.c
@@ -20,8 +20,9 @@
 #include <pt-internal.h>
 
 int
-pthread_attr_getstackaddr (const pthread_attr_t *attr, void **stackaddr)
+__pthread_attr_getstackaddr (const pthread_attr_t *attr, void **stackaddr)
 {
   *stackaddr = attr->__stackaddr;
   return 0;
 }
+strong_alias (__pthread_attr_getstackaddr, pthread_attr_getstackaddr)
diff --git a/sysdeps/htl/pt-attr-getstacksize.c b/sysdeps/htl/pt-attr-getstacksize.c
index f3f33b47c6..824d363538 100644
--- a/sysdeps/htl/pt-attr-getstacksize.c
+++ b/sysdeps/htl/pt-attr-getstacksize.c
@@ -20,8 +20,9 @@
 #include <pt-internal.h>
 
 int
-pthread_attr_getstacksize (const pthread_attr_t *attr, size_t * stacksize)
+__pthread_attr_getstacksize (const pthread_attr_t *attr, size_t * stacksize)
 {
   *stacksize = attr->__stacksize;
   return 0;
 }
+strong_alias (__pthread_attr_getstacksize, pthread_attr_getstacksize)
diff --git a/sysdeps/htl/pt-attr-setstack.c b/sysdeps/htl/pt-attr-setstack.c
index 70d6d0909f..f18025b264 100644
--- a/sysdeps/htl/pt-attr-setstack.c
+++ b/sysdeps/htl/pt-attr-setstack.c
@@ -20,25 +20,26 @@
 #include <assert.h>
 
 #include <pt-internal.h>
+#include <pthreadP.h>
 
 int
-pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr, size_t stacksize)
+__pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr, size_t stacksize)
 {
   int err;
   size_t s;
 
   /* pthread_attr_setstack should always succeed, thus we set the size
      first as it is more discriminating.  */
-  pthread_attr_getstacksize (attr, &s);
+  __pthread_attr_getstacksize (attr, &s);
 
-  err = pthread_attr_setstacksize (attr, stacksize);
+  err = __pthread_attr_setstacksize (attr, stacksize);
   if (err)
     return err;
 
-  err = pthread_attr_setstackaddr (attr, stackaddr);
+  err = __pthread_attr_setstackaddr (attr, stackaddr);
   if (err)
     {
-      int e = pthread_attr_setstacksize (attr, s);
+      int e = __pthread_attr_setstacksize (attr, s);
       assert_perror (e);
 
       return err;
@@ -46,3 +47,4 @@ pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr, size_t stacksize)
 
   return 0;
 }
+strong_alias (__pthread_attr_setstack, pthread_attr_setstack)
diff --git a/sysdeps/htl/pt-attr-setstackaddr.c b/sysdeps/htl/pt-attr-setstackaddr.c
index d15f5d74e0..491005bcc1 100644
--- a/sysdeps/htl/pt-attr-setstackaddr.c
+++ b/sysdeps/htl/pt-attr-setstackaddr.c
@@ -20,8 +20,9 @@
 #include <pt-internal.h>
 
 int
-pthread_attr_setstackaddr (pthread_attr_t *attr, void *stackaddr)
+__pthread_attr_setstackaddr (pthread_attr_t *attr, void *stackaddr)
 {
   attr->__stackaddr = stackaddr;
   return 0;
 }
+strong_alias (__pthread_attr_setstackaddr, pthread_attr_setstackaddr)
diff --git a/sysdeps/htl/pt-attr-setstacksize.c b/sysdeps/htl/pt-attr-setstacksize.c
index aa3e8000fa..38bec3f7c7 100644
--- a/sysdeps/htl/pt-attr-setstacksize.c
+++ b/sysdeps/htl/pt-attr-setstacksize.c
@@ -20,9 +20,9 @@
 #include <pt-internal.h>
 
 int
-pthread_attr_setstacksize (pthread_attr_t *attr, size_t stacksize)
+__pthread_attr_setstacksize (pthread_attr_t *attr, size_t stacksize)
 {
   attr->__stacksize = stacksize;
-
   return 0;
 }
+strong_alias (__pthread_attr_setstacksize, pthread_attr_setstacksize)
diff --git a/sysdeps/htl/pt-cond-timedwait.c b/sysdeps/htl/pt-cond-timedwait.c
index 7784a4a271..66051af417 100644
--- a/sysdeps/htl/pt-cond-timedwait.c
+++ b/sysdeps/htl/pt-cond-timedwait.c
@@ -19,6 +19,7 @@
 #include <pthread.h>
 
 #include <pt-internal.h>
+#include <pthreadP.h>
 
 extern int __pthread_cond_timedwait_internal (pthread_cond_t *cond,
 					      pthread_mutex_t *mutex,
@@ -115,7 +116,7 @@ __pthread_cond_timedwait_internal (pthread_cond_t *cond,
   __pthread_mutex_unlock (&self->cancel_lock);
 
   if (cancelled)
-    pthread_exit (PTHREAD_CANCELED);
+    __pthread_exit (PTHREAD_CANCELED);
 
   /* Release MUTEX before blocking.  */
   __pthread_mutex_unlock (mutex);
@@ -171,7 +172,7 @@ __pthread_cond_timedwait_internal (pthread_cond_t *cond,
   __pthread_mutex_lock (mutex);
 
   if (cancelled)
-    pthread_exit (PTHREAD_CANCELED);
+    __pthread_exit (PTHREAD_CANCELED);
 
   return err;
 }
diff --git a/sysdeps/htl/pt-key-create.c b/sysdeps/htl/pt-key-create.c
index 430dd2315e..a295bc78d9 100644
--- a/sysdeps/htl/pt-key-create.c
+++ b/sysdeps/htl/pt-key-create.c
@@ -21,6 +21,7 @@
 #include <assert.h>
 
 #include <pt-internal.h>
+#include <pthreadP.h>
 
 pthread_mutex_t __pthread_key_lock;
 
@@ -106,3 +107,4 @@ do_search:
   return 0;
 }
 strong_alias (__pthread_key_create, pthread_key_create)
+hidden_def (__pthread_key_create)
diff --git a/sysdeps/htl/pt-key.h b/sysdeps/htl/pt-key.h
index 09aa35c357..893adccd2e 100644
--- a/sysdeps/htl/pt-key.h
+++ b/sysdeps/htl/pt-key.h
@@ -18,6 +18,7 @@
 
 #include <pthread.h>
 #include <libc-lockP.h>
+#include <pthreadP.h>
 
 #define PTHREAD_KEY_MEMBERS \
   void **thread_specifics;		/* This is only resized by the thread, and always growing */ \
diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h
index c37974945a..6c9aa6cb75 100644
--- a/sysdeps/htl/pthreadP.h
+++ b/sysdeps/htl/pthreadP.h
@@ -27,20 +27,48 @@ extern pthread_t __pthread_self (void);
 extern int __pthread_kill (pthread_t threadid, int signo);
 extern struct __pthread **__pthread_threads;
 
+extern int _pthread_mutex_init (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr);
 extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
 extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex);
 
+extern int __pthread_cond_broadcast (pthread_cond_t *cond);
+
 typedef struct __cthread *__cthread_t;
 typedef int __cthread_key_t;
 typedef void *	(*__cthread_fn_t)(void *__arg);
 
 __cthread_t __cthread_fork (__cthread_fn_t, void *);
+int __pthread_create (pthread_t *newthread,
+		      const pthread_attr_t *attr,
+		      void *(*start_routine) (void *), void *arg);
+
 void __cthread_detach (__cthread_t);
+int __pthread_detach (pthread_t __threadp);
+void __pthread_exit (void *value) __attribute__ ((__noreturn__));
 int __cthread_keycreate (__cthread_key_t *);
 int __cthread_getspecific (__cthread_key_t, void **);
 int __cthread_setspecific (__cthread_key_t, void *);
+int __pthread_key_create (pthread_key_t *key, void (*destr) (void *));
+void *__pthread_getspecific (pthread_key_t key);
+int __pthread_setspecific (pthread_key_t key, const void *value);
+
+int __pthread_setcancelstate (int state, int *oldstate);
 
 int __pthread_getattr_np (pthread_t, pthread_attr_t *);
+int __pthread_attr_getstackaddr (const pthread_attr_t *__restrict __attr,
+				 void **__restrict __stackaddr);
+int __pthread_attr_setstackaddr (pthread_attr_t *__attr, void *__stackaddr);
+int __pthread_attr_getstacksize (const pthread_attr_t *__restrict __attr,
+				 size_t *__restrict __stacksize);
+int __pthread_attr_setstacksize (pthread_attr_t *__attr, size_t __stacksize);
+int __pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
+			     size_t __stacksize);
 int __pthread_attr_getstack (const pthread_attr_t *, void **, size_t *);
+struct __pthread_cancelation_handler **___pthread_get_cleanup_stack (void);
+
+#if IS_IN (libpthread)
+hidden_proto (__pthread_key_create)
+hidden_proto (_pthread_mutex_init)
+#endif
 
 #endif	/* pthreadP.h */
diff --git a/sysdeps/mach/hurd/htl/pt-attr-setstackaddr.c b/sysdeps/mach/hurd/htl/pt-attr-setstackaddr.c
index 3c0d73d1e8..ff6bee83d0 100644
--- a/sysdeps/mach/hurd/htl/pt-attr-setstackaddr.c
+++ b/sysdeps/mach/hurd/htl/pt-attr-setstackaddr.c
@@ -20,8 +20,9 @@
 #include <pt-internal.h>
 
 int
-pthread_attr_setstackaddr (pthread_attr_t *attr, void *stackaddr)
+__pthread_attr_setstackaddr (pthread_attr_t *attr, void *stackaddr)
 {
   attr->__stackaddr = stackaddr;
   return 0;
 }
+strong_alias (__pthread_attr_setstackaddr, pthread_attr_setstackaddr)
diff --git a/sysdeps/mach/hurd/htl/pt-attr-setstacksize.c b/sysdeps/mach/hurd/htl/pt-attr-setstacksize.c
index 9aff6ba7ac..e5c59d14b4 100644
--- a/sysdeps/mach/hurd/htl/pt-attr-setstacksize.c
+++ b/sysdeps/mach/hurd/htl/pt-attr-setstacksize.c
@@ -20,8 +20,9 @@
 #include <pt-internal.h>
 
 int
-pthread_attr_setstacksize (pthread_attr_t *attr, size_t stacksize)
+__pthread_attr_setstacksize (pthread_attr_t *attr, size_t stacksize)
 {
   attr->__stacksize = stacksize;
   return 0;
 }
+strong_alias (__pthread_attr_setstacksize, pthread_attr_setstacksize)
diff --git a/sysdeps/mach/hurd/htl/pt-docancel.c b/sysdeps/mach/hurd/htl/pt-docancel.c
index 839529cdbb..6e9428ce57 100644
--- a/sysdeps/mach/hurd/htl/pt-docancel.c
+++ b/sysdeps/mach/hurd/htl/pt-docancel.c
@@ -19,11 +19,12 @@
 #include <pthread.h>
 
 #include <pt-internal.h>
+#include <pthreadP.h>
 
 static void
 call_exit (void)
 {
-  pthread_exit (0);
+  __pthread_exit (0);
 }
 
 int
diff --git a/sysdeps/mach/hurd/htl/pt-mutex-init.c b/sysdeps/mach/hurd/htl/pt-mutex-init.c
index c90fc35d23..687a4c0e67 100644
--- a/sysdeps/mach/hurd/htl/pt-mutex-init.c
+++ b/sysdeps/mach/hurd/htl/pt-mutex-init.c
@@ -20,6 +20,7 @@
 #include <stdlib.h>
 #include <assert.h>
 #include <pt-internal.h>
+#include <pthreadP.h>
 #include "pt-mutex.h"
 #include <hurdlock.h>
 
@@ -53,3 +54,4 @@ _pthread_mutex_init (pthread_mutex_t *mtxp, const pthread_mutexattr_t *attrp)
 }
 
 strong_alias (_pthread_mutex_init, pthread_mutex_init)
+hidden_def (_pthread_mutex_init)
diff --git a/sysdeps/mach/hurd/htl/pt-sysdep.c b/sysdeps/mach/hurd/htl/pt-sysdep.c
index 4342d6d21b..673f048c37 100644
--- a/sysdeps/mach/hurd/htl/pt-sysdep.c
+++ b/sysdeps/mach/hurd/htl/pt-sysdep.c
@@ -24,6 +24,7 @@
 #include <mach/mig_support.h>
 
 #include <pt-internal.h>
+#include <pthreadP.h>
 
 __thread struct __pthread *___pthread_self;
 
@@ -57,8 +58,8 @@ _init_routine (void *stack)
          while the main program was not linked against libpthread.  */
       /* Avoid allocating another stack */
       attrp = &attr;
-      pthread_attr_init (attrp);
-      pthread_attr_setstack (attrp, stack, __vm_page_size);
+      __pthread_attr_init (attrp);
+      __pthread_attr_setstack (attrp, stack, __vm_page_size);
     }
 
   /* Create the pthread structure for the main thread (i.e. us).  */