This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Clean pthread functions namespace for C11 threads


This patch creates weak aliases for all conflicting functions with
C11 threads.h functions, allowong user to redefine them. Some functions
do not need aliases as they have already been defined as versioned
symbols.

Cheers.

    * nptl/pthreadP.h (__pthread_mutex_timedlock, __pthread_key_delete)
    (__pthread_detach, __pthread_join): Add functions prototypes.
    * nptl/pthread_detach.c (pthread_detach): Declare as weak alias.
    (__pthread_detach): Rename pthread_detach function.
    * nptl/pthread_equal.c (pthread_equal): Declare as weak alias.
    * nptl/pthread_exit.c (pthread_exit): Likewise.
    * nptl/pthread_getspecific.c (pthread_getspecific): Likewise.
    * nptl/pthread_join.c (pthread_join): Declare as weak alias.
    (__pthread_join): Rename pthread_join function.
    * nptl/pthread_key_create.c (pthread_key_create):
    Declare as weak alias.
    * nptl/pthread_key_delete.c (pthread_key_delete):
    Declare as weak alias.
    (__pthread_key_delete): Rename pthread_key_delete function.
    * nptl/pthread_mutex_destroy.c (pthread_mutex_destroy):
    Declare as weak alias.
    * nptl/pthread_mutex_init.c (pthread_mutex_init): Likewise.
    * nptl/pthread_mutex_lock.c (pthread_mutex_lock): Likewise.
    * nptl/pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise.
    (__pthread_mutex_timedlock): Rename pthread_mutex_timedlock function.
    * nptl/pthread_mutex_trylock.c (pthread_mutex_trylock):
    Declare as weak alias.
    * nptl/pthread_mutex_unlock.c (pthread_mutex_unlock): Likewise.
    * nptl/pthread_self.c (pthread_self): Likewise.
    * nptl/pthread_setspecific.c (pthread_setspecific): Likewise.

-- 
Juan Manuel Torres Palma.
Computer Science Student at Universidad de Granada.

Attachment: ChangeLog-0002
Description: Binary data

commit e843bb5428ac1cbd1fd2bb57292d0b7e696ddaea
Author: Juan Manuel Torres Palma <jmtorrespalma@gmail.com>
Date:   Thu Jun 25 19:43:22 2015 +0200

    Clean pthread functions namespaces for C11 threads
    
    This patch creates weak aliases for all conflicting functions with
    C11 threads.h functions, allowong user to redefine them. Some
    functions do not need aliases as they have already been defined as
    versioned symbols.

diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index 84a7105..b997b22 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -414,6 +414,8 @@ extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
 extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
 extern int __pthread_mutex_trylock (pthread_mutex_t *_mutex);
 extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
+extern int __pthread_mutex_timedlock (pthread_mutex_t *__mutex,
+     const struct timespec *__abstime);
 extern int __pthread_mutex_cond_lock (pthread_mutex_t *__mutex)
      attribute_hidden internal_function;
 extern void __pthread_mutex_cond_lock_adjust (pthread_mutex_t *__mutex)
@@ -477,6 +479,7 @@ extern int __pthread_cond_timedwait (pthread_cond_t *cond,
 extern int __pthread_condattr_destroy (pthread_condattr_t *attr);
 extern int __pthread_condattr_init (pthread_condattr_t *attr);
 extern int __pthread_key_create (pthread_key_t *key, void (*destr) (void *));
+extern int __pthread_key_delete (pthread_key_t key);
 extern void *__pthread_getspecific (pthread_key_t key);
 extern int __pthread_setspecific (pthread_key_t key, const void *value);
 extern int __pthread_once (pthread_once_t *once_control,
@@ -485,8 +488,10 @@ extern int __pthread_atfork (void (*prepare) (void), void (*parent) (void),
 			     void (*child) (void));
 extern pthread_t __pthread_self (void);
 extern int __pthread_equal (pthread_t thread1, pthread_t thread2);
+extern int __pthread_detach (pthread_t th);
 extern int __pthread_kill (pthread_t threadid, int signo);
 extern void __pthread_exit (void *value) __attribute__ ((__noreturn__));
+extern int __pthread_join (pthread_t threadid, void **thread_return);
 extern int __pthread_setcanceltype (int type, int *oldtype);
 extern int __pthread_enable_asynccancel (void) attribute_hidden;
 extern void __pthread_disable_asynccancel (int oldtype)
diff --git a/nptl/pthread_detach.c b/nptl/pthread_detach.c
index aa735f6..63e0635 100644
--- a/nptl/pthread_detach.c
+++ b/nptl/pthread_detach.c
@@ -22,7 +22,7 @@
 
 
 int
-pthread_detach (th)
+__pthread_detach (th)
      pthread_t th;
 {
   struct pthread *pd = (struct pthread *) th;
@@ -54,3 +54,4 @@ pthread_detach (th)
 
   return result;
 }
+weak_alias (__pthread_detach, pthread_detach);
diff --git a/nptl/pthread_equal.c b/nptl/pthread_equal.c
index 69f4c1b..2e730df 100644
--- a/nptl/pthread_equal.c
+++ b/nptl/pthread_equal.c
@@ -26,4 +26,4 @@ __pthread_equal (thread1, thread2)
 {
   return thread1 == thread2;
 }
-strong_alias (__pthread_equal, pthread_equal)
+weak_alias (__pthread_equal, pthread_equal)
diff --git a/nptl/pthread_exit.c b/nptl/pthread_exit.c
index a60adbd..9ec8b0d 100644
--- a/nptl/pthread_exit.c
+++ b/nptl/pthread_exit.c
@@ -27,7 +27,7 @@ __pthread_exit (void *value)
 
   __do_cancel ();
 }
-strong_alias (__pthread_exit, pthread_exit)
+weak_alias (__pthread_exit, pthread_exit)
 
 /* After a thread terminates, __libc_start_main decrements
    __nptl_nthreads defined in pthread_create.c.  */
diff --git a/nptl/pthread_getspecific.c b/nptl/pthread_getspecific.c
index 0bee354..a5e5f45 100644
--- a/nptl/pthread_getspecific.c
+++ b/nptl/pthread_getspecific.c
@@ -64,5 +64,5 @@ __pthread_getspecific (key)
 
   return result;
 }
-strong_alias (__pthread_getspecific, pthread_getspecific)
+weak_alias (__pthread_getspecific, pthread_getspecific)
 hidden_def (__pthread_getspecific)
diff --git a/nptl/pthread_join.c b/nptl/pthread_join.c
index c841ff9..687d9bb 100644
--- a/nptl/pthread_join.c
+++ b/nptl/pthread_join.c
@@ -37,7 +37,7 @@ cleanup (void *arg)
 
 
 int
-pthread_join (pthread_t threadid, void **thread_return)
+__pthread_join (pthread_t threadid, void **thread_return)
 {
   struct pthread *pd = (struct pthread *) threadid;
 
@@ -115,3 +115,4 @@ pthread_join (pthread_t threadid, void **thread_return)
 
   return result;
 }
+weak_alias(__pthread_join, pthread_join);
diff --git a/nptl/pthread_key_create.c b/nptl/pthread_key_create.c
index a642c69..9beec6b 100644
--- a/nptl/pthread_key_create.c
+++ b/nptl/pthread_key_create.c
@@ -49,5 +49,5 @@ __pthread_key_create (key, destr)
 
   return EAGAIN;
 }
-strong_alias (__pthread_key_create, pthread_key_create)
+weak_alias (__pthread_key_create, pthread_key_create)
 hidden_def (__pthread_key_create)
diff --git a/nptl/pthread_key_delete.c b/nptl/pthread_key_delete.c
index bd9b4a2..c6d4c06 100644
--- a/nptl/pthread_key_delete.c
+++ b/nptl/pthread_key_delete.c
@@ -22,7 +22,7 @@
 
 
 int
-pthread_key_delete (key)
+__pthread_key_delete (key)
      pthread_key_t key;
 {
   int result = EINVAL;
@@ -40,3 +40,4 @@ pthread_key_delete (key)
 
   return result;
 }
+weak_alias(__pthread_key_delete, pthread_key_delete);
diff --git a/nptl/pthread_mutex_destroy.c b/nptl/pthread_mutex_destroy.c
index f6089df..3d40205 100644
--- a/nptl/pthread_mutex_destroy.c
+++ b/nptl/pthread_mutex_destroy.c
@@ -37,5 +37,5 @@ __pthread_mutex_destroy (mutex)
 
   return 0;
 }
-strong_alias (__pthread_mutex_destroy, pthread_mutex_destroy)
+weak_alias (__pthread_mutex_destroy, pthread_mutex_destroy)
 hidden_def (__pthread_mutex_destroy)
diff --git a/nptl/pthread_mutex_init.c b/nptl/pthread_mutex_init.c
index d71cfef..6b9ab16 100644
--- a/nptl/pthread_mutex_init.c
+++ b/nptl/pthread_mutex_init.c
@@ -148,5 +148,5 @@ __pthread_mutex_init (mutex, mutexattr)
 
   return 0;
 }
-strong_alias (__pthread_mutex_init, pthread_mutex_init)
+weak_alias (__pthread_mutex_init, pthread_mutex_init)
 hidden_def (__pthread_mutex_init)
diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c
index 9607512..4ee4280 100644
--- a/nptl/pthread_mutex_lock.c
+++ b/nptl/pthread_mutex_lock.c
@@ -516,7 +516,7 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex)
   return 0;
 }
 #ifndef __pthread_mutex_lock
-strong_alias (__pthread_mutex_lock, pthread_mutex_lock)
+weak_alias (__pthread_mutex_lock, pthread_mutex_lock)
 hidden_def (__pthread_mutex_lock)
 #endif
 
diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c
index 109a46a..cb91fde 100644
--- a/nptl/pthread_mutex_timedlock.c
+++ b/nptl/pthread_mutex_timedlock.c
@@ -40,7 +40,7 @@
 #endif
 
 int
-pthread_mutex_timedlock (mutex, abstime)
+__pthread_mutex_timedlock (mutex, abstime)
      pthread_mutex_t *mutex;
      const struct timespec *abstime;
 {
@@ -522,3 +522,4 @@ pthread_mutex_timedlock (mutex, abstime)
  out:
   return result;
 }
+weak_alias(__pthread_mutex_timedlock, pthread_mutex_timedlock);
diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c
index 33df384..229afdf 100644
--- a/nptl/pthread_mutex_trylock.c
+++ b/nptl/pthread_mutex_trylock.c
@@ -404,6 +404,6 @@ __pthread_mutex_trylock (mutex)
 
 #ifndef __pthread_mutex_trylock
 #ifndef pthread_mutex_trylock
-strong_alias (__pthread_mutex_trylock, pthread_mutex_trylock)
+weak_alias (__pthread_mutex_trylock, pthread_mutex_trylock)
 #endif
 #endif
diff --git a/nptl/pthread_mutex_unlock.c b/nptl/pthread_mutex_unlock.c
index 80939ba..d9ff351 100644
--- a/nptl/pthread_mutex_unlock.c
+++ b/nptl/pthread_mutex_unlock.c
@@ -314,5 +314,5 @@ __pthread_mutex_unlock (mutex)
 {
   return __pthread_mutex_unlock_usercnt (mutex, 1);
 }
-strong_alias (__pthread_mutex_unlock, pthread_mutex_unlock)
+weak_alias (__pthread_mutex_unlock, pthread_mutex_unlock)
 hidden_def (__pthread_mutex_unlock)
diff --git a/nptl/pthread_self.c b/nptl/pthread_self.c
index d6ba45c..422151e 100644
--- a/nptl/pthread_self.c
+++ b/nptl/pthread_self.c
@@ -25,4 +25,4 @@ __pthread_self (void)
 {
   return (pthread_t) THREAD_SELF;
 }
-strong_alias (__pthread_self, pthread_self)
+weak_alias (__pthread_self, pthread_self)
diff --git a/nptl/pthread_setspecific.c b/nptl/pthread_setspecific.c
index a9cf26c..36b42f8 100644
--- a/nptl/pthread_setspecific.c
+++ b/nptl/pthread_setspecific.c
@@ -91,5 +91,5 @@ __pthread_setspecific (key, value)
 
   return 0;
 }
-strong_alias (__pthread_setspecific, pthread_setspecific)
+weak_alias (__pthread_setspecific, pthread_setspecific)
 hidden_def (__pthread_setspecific)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]