Просмотр исходного кода

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.

Manuel Novoa III 20 лет назад
Родитель
Сommit
d05dafe2fc

+ 3 - 0
include/pthread.h

@@ -24,6 +24,9 @@
 #include <signal.h>
 #include <bits/pthreadtypes.h>
 #include <bits/initspin.h>
+#ifdef _LIBC
+#include <bits/uClibc_pthread.h>
+#endif
 
 
 __BEGIN_DECLS

+ 2 - 2
libc/inet/getnetent.c

@@ -25,8 +25,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

+ 2 - 2
libc/inet/getproto.c

@@ -65,8 +65,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

+ 2 - 2
libc/inet/getservice.c

@@ -70,8 +70,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

+ 6 - 6
libc/inet/resolv.c

@@ -180,8 +180,8 @@ extern char * __searchdomain[MAX_SEARCH];
 #ifdef __UCLIBC_HAS_THREADS__
 #include <pthread.h>
 extern pthread_mutex_t __resolv_lock;
-# define BIGLOCK	pthread_mutex_lock(&__resolv_lock)
-# define BIGUNLOCK	pthread_mutex_unlock(&__resolv_lock);
+# define BIGLOCK	__pthread_mutex_lock(&__resolv_lock)
+# define BIGUNLOCK	__pthread_mutex_unlock(&__resolv_lock);
 #else
 # define BIGLOCK
 # define BIGUNLOCK
@@ -645,8 +645,8 @@ int __form_query(int id, const char *name, int type, unsigned char *packet,
 
 #ifdef __UCLIBC_HAS_THREADS__
 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
@@ -1331,8 +1331,8 @@ int __read_etc_hosts_r(FILE * fp, const char * name, int type,
 
 #ifdef __UCLIBC_HAS_THREADS__
 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

+ 2 - 2
libc/inet/rpc/create_xid.c

@@ -30,8 +30,8 @@
 #ifdef __UCLIBC_HAS_THREADS__
 #include <pthread.h>
 static pthread_mutex_t createxid_lock = PTHREAD_MUTEX_INITIALIZER;
-# define LOCK	pthread_mutex_lock(&createxid_lock)
-# define UNLOCK	pthread_mutex_unlock(&createxid_lock);
+# define LOCK	__pthread_mutex_lock(&createxid_lock)
+# define UNLOCK	__pthread_mutex_unlock(&createxid_lock);
 #else
 # define LOCK
 # define UNLOCK

+ 2 - 2
libc/misc/dirent/closedir.c

@@ -20,12 +20,12 @@ int closedir(DIR * dir)
 		return -1;
 	}
 #ifdef __UCLIBC_HAS_THREADS__
-	pthread_mutex_lock(&(dir->dd_lock));
+	__pthread_mutex_lock(&(dir->dd_lock));
 #endif
 	fd = dir->dd_fd;
 	dir->dd_fd = -1;
 #ifdef __UCLIBC_HAS_THREADS__
-	pthread_mutex_unlock(&(dir->dd_lock));
+	__pthread_mutex_unlock(&(dir->dd_lock));
 #endif
 	free(dir->dd_buf);
 	free(dir);

+ 1 - 1
libc/misc/dirent/opendir.c

@@ -52,7 +52,7 @@ DIR *opendir(const char *name)
 	}
 	ptr->dd_buf = buf;
 #ifdef __UCLIBC_HAS_THREADS__
-	pthread_mutex_init(&(ptr->dd_lock), NULL);
+	__pthread_mutex_init(&(ptr->dd_lock), NULL);
 #endif
 	return ptr;
 }

+ 2 - 2
libc/misc/dirent/readdir.c

@@ -17,7 +17,7 @@ struct dirent *readdir(DIR * dir)
 	}
 
 #ifdef __UCLIBC_HAS_THREADS__
-	pthread_mutex_lock(&(dir->dd_lock));
+	__pthread_mutex_lock(&(dir->dd_lock));
 #endif
 
 	do {
@@ -45,7 +45,7 @@ struct dirent *readdir(DIR * dir)
 
 all_done:
 #ifdef __UCLIBC_HAS_THREADS__
-	pthread_mutex_unlock(&(dir->dd_lock));
+	__pthread_mutex_unlock(&(dir->dd_lock));
 #endif
 	return de;
 }

+ 2 - 2
libc/misc/dirent/readdir64.c

@@ -32,7 +32,7 @@ struct dirent64 *readdir64(DIR * dir)
 	}
 
 #ifdef __UCLIBC_HAS_THREADS__
-	pthread_mutex_lock(&(dir->dd_lock));
+	__pthread_mutex_lock(&(dir->dd_lock));
 #endif
 
 	do {
@@ -60,7 +60,7 @@ struct dirent64 *readdir64(DIR * dir)
 
 all_done:
 #ifdef __UCLIBC_HAS_THREADS__
-	pthread_mutex_unlock(&(dir->dd_lock));
+	__pthread_mutex_unlock(&(dir->dd_lock));
 #endif
 
 	return de;

+ 2 - 2
libc/misc/dirent/readdir64_r.c

@@ -33,7 +33,7 @@ int readdir64_r(DIR *dir, struct dirent64 *entry, struct dirent64 **result)
 	de = NULL;
 
 #ifdef __UCLIBC_HAS_THREADS__
-	pthread_mutex_lock(&(dir->dd_lock));
+	__pthread_mutex_lock(&(dir->dd_lock));
 #endif
 
 	do {
@@ -69,7 +69,7 @@ int readdir64_r(DIR *dir, struct dirent64 *entry, struct dirent64 **result)
 all_done:
 
 #ifdef __UCLIBC_HAS_THREADS__
-	pthread_mutex_unlock(&(dir->dd_lock));
+	__pthread_mutex_unlock(&(dir->dd_lock));
 #endif
         return((de != NULL)? 0 : ret);
 }

+ 2 - 2
libc/misc/dirent/readdir_r.c

@@ -19,7 +19,7 @@ int readdir_r(DIR *dir, struct dirent *entry, struct dirent **result)
 	de = NULL;
 
 #ifdef __UCLIBC_HAS_THREADS__
-	pthread_mutex_lock(&(dir->dd_lock));
+	__pthread_mutex_lock(&(dir->dd_lock));
 #endif
 
 	do {
@@ -55,7 +55,7 @@ int readdir_r(DIR *dir, struct dirent *entry, struct dirent **result)
 all_done:
 
 #ifdef __UCLIBC_HAS_THREADS__
-	pthread_mutex_unlock(&(dir->dd_lock));
+	__pthread_mutex_unlock(&(dir->dd_lock));
 #endif
         return((de != NULL)? 0 : ret);
 }

+ 2 - 2
libc/misc/dirent/rewinddir.c

@@ -12,11 +12,11 @@ void rewinddir(DIR * dir)
 		return;
 	}
 #ifdef __UCLIBC_HAS_THREADS__
-	pthread_mutex_lock(&(dir->dd_lock));
+	__pthread_mutex_lock(&(dir->dd_lock));
 #endif
 	lseek(dir->dd_fd, 0, SEEK_SET);
 	dir->dd_nextoff = dir->dd_nextloc = dir->dd_size = 0;
 #ifdef __UCLIBC_HAS_THREADS__
-	pthread_mutex_unlock(&(dir->dd_lock));
+	__pthread_mutex_unlock(&(dir->dd_lock));
 #endif
 }

+ 2 - 2
libc/misc/dirent/seekdir.c

@@ -11,11 +11,11 @@ void seekdir(DIR * dir, long int offset)
 		return;
 	}
 #ifdef __UCLIBC_HAS_THREADS__
-	pthread_mutex_lock(&(dir->dd_lock));
+	__pthread_mutex_lock(&(dir->dd_lock));
 #endif
 	dir->dd_nextoff = lseek(dir->dd_fd, offset, SEEK_SET);
 	dir->dd_size = dir->dd_nextloc = 0;
 #ifdef __UCLIBC_HAS_THREADS__
-	pthread_mutex_unlock(&(dir->dd_lock));
+	__pthread_mutex_unlock(&(dir->dd_lock));
 #endif
 }

+ 2 - 2
libc/misc/mntent/mntent.c

@@ -6,8 +6,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

+ 4 - 69
libc/misc/pthread/weaks.c

@@ -22,74 +22,15 @@
 #include <stdlib.h>
 
 extern int __pthread_return_0 __P ((void));
-extern int __pthread_return_1 __P ((void));
 extern void __pthread_return_void __P ((void));
 
-weak_alias (__pthread_return_0, pthread_attr_init)
-weak_alias (__pthread_return_0, pthread_attr_destroy)
-weak_alias (__pthread_return_0, pthread_attr_setdetachstate)
-weak_alias (__pthread_return_0, pthread_attr_getdetachstate)
-weak_alias (__pthread_return_0, pthread_attr_setschedparam)
-weak_alias (__pthread_return_0, pthread_attr_getschedparam)
-weak_alias (__pthread_return_0, pthread_attr_setschedpolicy)
-weak_alias (__pthread_return_0, pthread_attr_getschedpolicy)
-weak_alias (__pthread_return_0, pthread_attr_setinheritsched)
-weak_alias (__pthread_return_0, pthread_attr_getinheritsched)
-weak_alias (__pthread_return_0, pthread_attr_setscope)
-weak_alias (__pthread_return_0, pthread_attr_getscope)
-weak_alias (__pthread_return_0, pthread_attr_setstackaddr)
-weak_alias (__pthread_return_0, pthread_attr_getstackaddr)
-weak_alias (__pthread_return_0, pthread_attr_setstacksize)
-weak_alias (__pthread_return_0, pthread_attr_getstacksize)
-weak_alias (__pthread_return_0, pthread_mutex_init)
-weak_alias (__pthread_return_0, pthread_mutex_destroy)
-weak_alias (__pthread_return_0, pthread_mutex_lock)
-weak_alias (__pthread_return_0, pthread_mutex_trylock)
-weak_alias (__pthread_return_0, pthread_mutex_unlock)
-weak_alias (__pthread_return_0, pthread_mutexattr_init)
-weak_alias (__pthread_return_0, pthread_mutexattr_destroy)
-weak_alias (__pthread_return_0, pthread_mutexattr_settype)
-weak_alias (__pthread_return_0, pthread_mutexattr_gettype)
-weak_alias (__pthread_return_0, pthread_condattr_init)
-weak_alias (__pthread_return_0, pthread_condattr_destroy)
-weak_alias (__pthread_return_0, pthread_setschedparam)
-weak_alias (__pthread_return_0, pthread_getschedparam)
-weak_alias (__pthread_return_0, pthread_getcancelstate)
-weak_alias (__pthread_return_0, pthread_setcancelstate)
-weak_alias (__pthread_return_0, pthread_setcanceltype)
-weak_alias (__pthread_return_0, pthread_setconcurrency)
-weak_alias (__pthread_return_0, pthread_getconcurrency)
-weak_alias (__pthread_return_0, pthread_self)
-weak_alias (__pthread_return_0, pthread_cond_init)
-weak_alias (__pthread_return_0, pthread_cond_destroy)
-weak_alias (__pthread_return_0, pthread_cond_wait)
-weak_alias (__pthread_return_0, pthread_cond_timedwait)
-weak_alias (__pthread_return_0, pthread_cond_signal)
-weak_alias (__pthread_return_0, pthread_cond_broadcast)
-weak_alias (__pthread_return_0, pthread_rwlock_init)
-weak_alias (__pthread_return_0, pthread_rwlock_destroy)
-weak_alias (__pthread_return_0, pthread_rwlock_rdlock)
-weak_alias (__pthread_return_0, pthread_rwlock_wrlock)
-weak_alias (__pthread_return_0, pthread_rwlock_tryrdlock)
-weak_alias (__pthread_return_0, pthread_rwlock_trywrlock)
-weak_alias (__pthread_return_0, pthread_rwlock_unlock)
-weak_alias (__pthread_return_0, pthread_rwlockattr_init)
-weak_alias (__pthread_return_0, pthread_rwlockattr_destroy)
-weak_alias (__pthread_return_0, pthread_rwlockattr_setpshared)
-weak_alias (__pthread_return_0, pthread_rwlockattr_getpshared)
 weak_alias (__pthread_return_0, __pthread_once)
 weak_alias (__pthread_return_void, __pthread_initialize_minimal)
 
-
-/* Those are pthread functions which return 1 if successful. */
-weak_alias (__pthread_return_1, pthread_equal)
-
-/* pthread_exit () is a special case. */
-void weak_function 
-pthread_exit (void *retval)
-{
-  exit (EXIT_SUCCESS);
-}
+weak_alias (__pthread_return_0, __pthread_mutex_init)
+weak_alias (__pthread_return_0, __pthread_mutex_lock)
+weak_alias (__pthread_return_0, __pthread_mutex_trylock)
+weak_alias (__pthread_return_0, __pthread_mutex_unlock)
 
 int
 __pthread_return_0 (void)
@@ -97,12 +38,6 @@ __pthread_return_0 (void)
   return 0;
 }
 
-int
-__pthread_return_1 (void)
-{
-  return 1;
-}
-
 void
 __pthread_return_void (void)
 {

+ 2 - 2
libc/misc/syslog/syslog.c

@@ -84,8 +84,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

+ 2 - 2
libc/misc/time/time.c

@@ -202,8 +202,8 @@ typedef struct {
 
 extern pthread_mutex_t _time_tzlock;
 
-#define TZLOCK		pthread_mutex_lock(&_time_tzlock)
-#define TZUNLOCK	pthread_mutex_unlock(&_time_tzlock)
+#define TZLOCK		__pthread_mutex_lock(&_time_tzlock)
+#define TZUNLOCK	__pthread_mutex_unlock(&_time_tzlock)
 
 #else
 

+ 2 - 2
libc/misc/utmp/utent.c

@@ -25,8 +25,8 @@
 #ifdef __UCLIBC_HAS_THREADS__
 #include <pthread.h>
 static pthread_mutex_t utmplock = PTHREAD_MUTEX_INITIALIZER;
-# define LOCK	pthread_mutex_lock(&utmplock)
-# define UNLOCK	pthread_mutex_unlock(&utmplock);
+# define LOCK	__pthread_mutex_lock(&utmplock)
+# define UNLOCK	__pthread_mutex_unlock(&utmplock)
 #else
 # define LOCK
 # define UNLOCK

+ 3 - 3
libc/misc/wchar/wstdio.c

@@ -113,13 +113,13 @@ void NAME PARAMS \
 void NAME##_unlocked PARAMS
 
 #define __STDIO_THREADLOCK_OPENLIST \
-	pthread_mutex_lock(&_stdio_openlist_lock)
+	__pthread_mutex_lock(&_stdio_openlist_lock)
 
 #define __STDIO_THREADUNLOCK_OPENLIST \
-	pthread_mutex_unlock(&_stdio_openlist_lock)
+	__pthread_mutex_unlock(&_stdio_openlist_lock)
 
 #define __STDIO_THREADTRYLOCK_OPENLIST \
-	pthread_mutex_trylock(&_stdio_openlist_lock)
+	__pthread_mutex_trylock(&_stdio_openlist_lock)
 
 #endif /* __STDIO_THREADSAFE */
 

+ 2 - 2
libc/pwd_grp/lckpwdf.c

@@ -30,8 +30,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

+ 6 - 6
libc/pwd_grp/pwd_grp.c

@@ -445,8 +445,8 @@ int getpw(uid_t uid, char *buf)
 
 #ifdef __UCLIBC_HAS_THREADS__
 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		((void) 0)
 # define UNLOCK		((void) 0)
@@ -509,8 +509,8 @@ int getpwent_r(struct passwd *__restrict resultbuf,
 
 #ifdef __UCLIBC_HAS_THREADS__
 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		((void) 0)
 # define UNLOCK		((void) 0)
@@ -572,8 +572,8 @@ int getgrent_r(struct group *__restrict resultbuf,
 
 #ifdef __UCLIBC_HAS_THREADS__
 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		((void) 0)
 # define UNLOCK		((void) 0)

+ 6 - 6
libc/stdio/stdio.c

@@ -193,13 +193,13 @@ void NAME PARAMS \
 void NAME##_unlocked PARAMS
 
 #define __STDIO_THREADLOCK_OPENLIST \
-	pthread_mutex_lock(&_stdio_openlist_lock)
+	__pthread_mutex_lock(&_stdio_openlist_lock)
 
 #define __STDIO_THREADUNLOCK_OPENLIST \
-	pthread_mutex_unlock(&_stdio_openlist_lock)
+	__pthread_mutex_unlock(&_stdio_openlist_lock)
 
 #define __STDIO_THREADTRYLOCK_OPENLIST \
-	pthread_mutex_trylock(&_stdio_openlist_lock)
+	__pthread_mutex_trylock(&_stdio_openlist_lock)
 
 #endif /* __STDIO_THREADSAFE */
 
@@ -1124,7 +1124,7 @@ int __fsetlocking(FILE *stream, int locking_mode)
 void flockfile(FILE *stream)
 {
 #ifdef __STDIO_THREADSAFE
-	pthread_mutex_lock(&stream->lock);
+	__pthread_mutex_lock(&stream->lock);
 #endif
 }
 
@@ -1135,7 +1135,7 @@ void flockfile(FILE *stream)
 int ftrylockfile(FILE *stream)
 {
 #ifdef __STDIO_THREADSAFE
-	return pthread_mutex_trylock(&stream->lock);
+	return __pthread_mutex_trylock(&stream->lock);
 #else
 	return 1;
 #endif
@@ -1148,7 +1148,7 @@ int ftrylockfile(FILE *stream)
 void funlockfile(FILE *stream)
 {
 #ifdef __STDIO_THREADSAFE
-	pthread_mutex_unlock(&stream->lock);
+	__pthread_mutex_unlock(&stream->lock);
 #endif
 }
 

+ 2 - 2
libc/stdlib/abort.c

@@ -56,8 +56,8 @@ static int been_there_done_that = 0;
 #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

+ 2 - 2
libc/stdlib/atexit.c

@@ -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

+ 2 - 2
libc/stdlib/malloc-930716/malloc.c

@@ -21,8 +21,8 @@
 #ifdef __UCLIBC_HAS_THREADS__
 #include <pthread.h>
 pthread_mutex_t __malloclock = PTHREAD_MUTEX_INITIALIZER;
-# define LOCK	pthread_mutex_lock(&__malloclock)
-# define UNLOCK	pthread_mutex_unlock(&__malloclock);
+# define LOCK	__pthread_mutex_lock(&__malloclock)
+# define UNLOCK	__pthread_mutex_unlock(&__malloclock);
 #else
 # define LOCK
 # define UNLOCK

+ 2 - 2
libc/stdlib/malloc-930716/memalign.c

@@ -20,8 +20,8 @@
 #ifdef __UCLIBC_HAS_THREADS__
 #include <pthread.h>
 extern pthread_mutex_t __malloclock;
-# define LOCK	pthread_mutex_lock(&__malloclock)
-# define UNLOCK	pthread_mutex_unlock(&__malloclock);
+# define LOCK	__pthread_mutex_lock(&__malloclock)
+# define UNLOCK	__pthread_mutex_unlock(&__malloclock);
 #else
 # define LOCK
 # define UNLOCK

+ 2 - 2
libc/stdlib/malloc-930716/realloc.c

@@ -21,8 +21,8 @@
 #ifdef __UCLIBC_HAS_THREADS__
 #include <pthread.h>
 extern pthread_mutex_t __malloclock;
-# define LOCK	pthread_mutex_lock(&__malloclock)
-# define UNLOCK	pthread_mutex_unlock(&__malloclock);
+# define LOCK	__pthread_mutex_lock(&__malloclock)
+# define UNLOCK	__pthread_mutex_unlock(&__malloclock);
 #else
 # define LOCK
 # define UNLOCK

+ 2 - 2
libc/stdlib/malloc/heap.h

@@ -136,8 +136,8 @@ extern void __heap_check (struct heap *heap, const char *str);
 
 
 #ifdef HEAP_USE_LOCKING
-# define __heap_lock(heap)	pthread_mutex_lock (&(heap)->lock)
-# define __heap_unlock(heap)	pthread_mutex_unlock (&(heap)->lock)
+# define __heap_lock(heap)	__pthread_mutex_lock (&(heap)->lock)
+# define __heap_unlock(heap)	__pthread_mutex_unlock (&(heap)->lock)
 #else /* !__UCLIBC_HAS_THREADS__ */
 /* Without threads, mutex operations are a nop.  */
 # define __heap_lock(heap)	(void)0

+ 2 - 2
libc/stdlib/malloc/malloc.h

@@ -136,8 +136,8 @@ typedef pthread_mutex_t malloc_mutex_t;
    things will break if these multiple calls are interleaved with another
    thread's use of sbrk!).  */
 extern malloc_mutex_t __malloc_sbrk_lock;
-#  define __malloc_lock_sbrk()	pthread_mutex_lock (&__malloc_sbrk_lock)
-#  define __malloc_unlock_sbrk() pthread_mutex_unlock (&__malloc_sbrk_lock)
+#  define __malloc_lock_sbrk()	__pthread_mutex_lock (&__malloc_sbrk_lock)
+#  define __malloc_unlock_sbrk() __pthread_mutex_unlock (&__malloc_sbrk_lock)
 # endif /* MALLOC_USE_SBRK */
 
 #else /* !__UCLIBC_HAS_THREADS__ */

+ 10 - 10
libc/stdlib/random.c

@@ -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 @@ static struct random_data unsafe_state =
    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 @@ char * initstate (unsigned int seed, char *arg_state, size_t n)
 {
     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 @@ char * setstate (char *arg_state)
 {
     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 @@ long int random ()
 {
   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;
 }
 

+ 2 - 2
libc/stdlib/setenv.c

@@ -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

+ 39 - 0
libc/sysdeps/linux/common/bits/uClibc_pthread.h

@@ -0,0 +1,39 @@
+/*  Copyright (C) 2003     Manuel Novoa III
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public
+ *  License along with this library; if not, write to the Free
+ *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/* Supply prototypes for the (weak) thread functions used by the
+ * uClibc library code.
+ */
+
+#ifndef _UCLIBC_PTHREAD_H
+#define _UCLIBC_PTHREAD_H
+
+#ifndef _PTHREAD_H
+#error Always include <pthread.h> rather than <bits/uClibc_pthread.h>
+#endif
+
+extern int __pthread_mutex_init (pthread_mutex_t *__restrict __mutex,
+								 __const pthread_mutexattr_t *__restrict
+								 __mutex_attr) __THROW;
+
+extern int __pthread_mutex_trylock (pthread_mutex_t *__mutex) __THROW;
+
+extern int __pthread_mutex_lock (pthread_mutex_t *__mutex) __THROW;
+
+extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex) __THROW;
+
+#endif

+ 3 - 3
libc/sysdeps/linux/common/bits/uClibc_stdio.h

@@ -204,17 +204,17 @@
 
 #define __STDIO_THREADLOCK(STREAM) \
 	if ((STREAM)->user_locking == 0) { \
-		pthread_mutex_lock(&(STREAM)->lock); \
+		__pthread_mutex_lock(&(STREAM)->lock); \
 	}
 
 #define __STDIO_THREADUNLOCK(STREAM) \
 	if ((STREAM)->user_locking == 0) { \
-		pthread_mutex_unlock(&(STREAM)->lock); \
+		__pthread_mutex_unlock(&(STREAM)->lock); \
 	}
 
 #define __STDIO_THREADTRYLOCK(STREAM) \
 	if ((STREAM)->user_locking == 0) { \
-		pthread_mutex_trylock(&(STREAM)->lock); \
+		__pthread_mutex_trylock(&(STREAM)->lock); \
 	}
 
 #define __STDIO_SET_USER_LOCKING(STREAM)   	((STREAM)->user_locking = 1)

+ 0 - 1
libpthread/linuxthreads/lockfile.c

@@ -17,7 +17,6 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-/*  #include <bits/libc-lock.h> */
 #include <stdio.h>
 #include <pthread.h>
 

+ 0 - 1
libpthread/linuxthreads/mutex.c

@@ -14,7 +14,6 @@
 
 /* Mutexes */
 
-#include <bits/libc-lock.h>
 #include <errno.h>
 #include <sched.h>
 #include <stddef.h>

+ 0 - 1
libpthread/linuxthreads/specific.c

@@ -23,7 +23,6 @@
 #include "internals.h"
 #include "spinlock.h"
 #include "restart.h"
-#include <bits/libc-lock.h>
 
 
 /* Table of keys. */