[uClibc-cvs] uClibc/libc/stdlib abort.c, 1.13, 1.14 atexit.c, 1.24, 1.25 random.c, 1.4, 1.5 setenv.c, 1.13, 1.14

Manuel Novoa III mjn3 at uclibc.org
Sat Dec 27 23:30:46 UTC 2003


Update of /var/cvs/uClibc/libc/stdlib
In directory nail:/tmp/cvs-serv11655/libc/stdlib

Modified Files:
	abort.c atexit.c random.c setenv.c 
Log Message:
Fix a long-standing bug with pthreads.  A couple of linuxthreads files
were including libc-lock.h which had a bunch of weak pragmas.  Also,
uClibc supplied a number of no-op weak thread functions even though
many weren't needed.  This combined result was that sometimes the
functional versions of thread functions in pthread would not override
the weaks in libc.

While fixing this, I also prepended double-underscore to all necessary
weak thread funcs in uClibc, and removed all unused weaks.

I did a test build, but haven't tested this since these changes are
a backport from my working tree.  I did test the changes there and
no longer need to explicitly add -lpthread in the perl build for
perl to pass its thread self tests.



Index: setenv.c
===================================================================
RCS file: /var/cvs/uClibc/libc/stdlib/setenv.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- setenv.c	18 Jun 2002 07:50:22 -0000	1.13
+++ setenv.c	27 Dec 2003 23:30:43 -0000	1.14
@@ -29,8 +29,8 @@
 #ifdef __UCLIBC_HAS_THREADS__
 #include <pthread.h>
 static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER;
-# define LOCK	pthread_mutex_lock(&mylock)
-# define UNLOCK	pthread_mutex_unlock(&mylock);
+# define LOCK	__pthread_mutex_lock(&mylock)
+# define UNLOCK	__pthread_mutex_unlock(&mylock);
 #else
 # define LOCK
 # define UNLOCK

Index: random.c
===================================================================
RCS file: /var/cvs/uClibc/libc/stdlib/random.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- random.c	19 Mar 2002 12:19:07 -0000	1.4
+++ random.c	27 Dec 2003 23:30:43 -0000	1.5
@@ -34,8 +34,8 @@
    data.  */
 static pthread_mutex_t lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
 #else
-#define pthread_mutex_lock(x)
-#define pthread_mutex_unlock(x)
+#define __pthread_mutex_lock(x)
+#define __pthread_mutex_unlock(x)
 #endif
 
 /* An improved random number generation package.  In addition to the standard
@@ -184,9 +184,9 @@
    for default usage relies on values produced by this routine.  */
 void srandom (unsigned int x)
 {
-    pthread_mutex_lock(&lock);
+    __pthread_mutex_lock(&lock);
     srandom_r (x, &unsafe_state);
-    pthread_mutex_unlock(&lock);
+    __pthread_mutex_unlock(&lock);
 }
 weak_alias (srandom, srand)
 
@@ -205,10 +205,10 @@
 {
     int32_t *ostate;
 
-    pthread_mutex_lock(&lock);
+    __pthread_mutex_lock(&lock);
     ostate = &unsafe_state.state[-1];
     initstate_r (seed, arg_state, n, &unsafe_state);
-    pthread_mutex_unlock(&lock);
+    __pthread_mutex_unlock(&lock);
     return (char *) ostate;
 }
 
@@ -224,11 +224,11 @@
 {
     int32_t *ostate;
 
-    pthread_mutex_lock(&lock);
+    __pthread_mutex_lock(&lock);
     ostate = &unsafe_state.state[-1];
     if (setstate_r (arg_state, &unsafe_state) < 0)
 	ostate = NULL;
-    pthread_mutex_unlock(&lock);
+    __pthread_mutex_unlock(&lock);
     return (char *) ostate;
 }
 
@@ -247,9 +247,9 @@
 {
   int32_t retval;
 
-  pthread_mutex_lock(&lock);
+  __pthread_mutex_lock(&lock);
   random_r (&unsafe_state, &retval);
-  pthread_mutex_unlock(&lock);
+  __pthread_mutex_unlock(&lock);
   return retval;
 }
 

Index: atexit.c
===================================================================
RCS file: /var/cvs/uClibc/libc/stdlib/atexit.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- atexit.c	2 Nov 2003 08:29:10 -0000	1.24
+++ atexit.c	27 Dec 2003 23:30:43 -0000	1.25
@@ -44,8 +44,8 @@
 #ifdef __UCLIBC_HAS_THREADS__
 #include <pthread.h>
 extern pthread_mutex_t mylock;
-# define LOCK	pthread_mutex_lock(&mylock)
-# define UNLOCK	pthread_mutex_unlock(&mylock);
+# define LOCK	__pthread_mutex_lock(&mylock)
+# define UNLOCK	__pthread_mutex_unlock(&mylock);
 #else
 # define LOCK
 # define UNLOCK

Index: abort.c
===================================================================
RCS file: /var/cvs/uClibc/libc/stdlib/abort.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- abort.c	8 Aug 2002 07:28:12 -0000	1.13
+++ abort.c	27 Dec 2003 23:30:43 -0000	1.14
@@ -56,8 +56,8 @@
 #ifdef __UCLIBC_HAS_THREADS__
 #include <pthread.h>
 static pthread_mutex_t mylock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
-# define LOCK	pthread_mutex_lock(&mylock)
-# define UNLOCK	pthread_mutex_unlock(&mylock);
+# define LOCK	__pthread_mutex_lock(&mylock)
+# define UNLOCK	__pthread_mutex_unlock(&mylock);
 #else
 # define LOCK
 # define UNLOCK




More information about the uClibc-cvs mailing list