OSDN Git Service

Fix a long-standing bug with pthreads. A couple of linuxthreads files
authorManuel Novoa III <mjn3@codepoet.org>
Sat, 27 Dec 2003 23:30:50 +0000 (23:30 -0000)
committerManuel Novoa III <mjn3@codepoet.org>
Sat, 27 Dec 2003 23:30:50 +0000 (23:30 -0000)
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.

37 files changed:
include/pthread.h
libc/inet/getnetent.c
libc/inet/getproto.c
libc/inet/getservice.c
libc/inet/resolv.c
libc/inet/rpc/create_xid.c
libc/misc/dirent/closedir.c
libc/misc/dirent/opendir.c
libc/misc/dirent/readdir.c
libc/misc/dirent/readdir64.c
libc/misc/dirent/readdir64_r.c
libc/misc/dirent/readdir_r.c
libc/misc/dirent/rewinddir.c
libc/misc/dirent/seekdir.c
libc/misc/mntent/mntent.c
libc/misc/pthread/weaks.c
libc/misc/syslog/syslog.c
libc/misc/time/time.c
libc/misc/utmp/utent.c
libc/misc/wchar/wstdio.c
libc/pwd_grp/lckpwdf.c
libc/pwd_grp/pwd_grp.c
libc/stdio/stdio.c
libc/stdlib/abort.c
libc/stdlib/atexit.c
libc/stdlib/malloc-930716/malloc.c
libc/stdlib/malloc-930716/memalign.c
libc/stdlib/malloc-930716/realloc.c
libc/stdlib/malloc/heap.h
libc/stdlib/malloc/malloc.h
libc/stdlib/random.c
libc/stdlib/setenv.c
libc/sysdeps/linux/common/bits/uClibc_pthread.h [new file with mode: 0644]
libc/sysdeps/linux/common/bits/uClibc_stdio.h
libpthread/linuxthreads/lockfile.c
libpthread/linuxthreads/mutex.c
libpthread/linuxthreads/specific.c

index 2b7b798..846b9cc 100644 (file)
@@ -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
index 0b4c36d..9ade1f6 100644 (file)
@@ -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
index 2a5fc8f..1d3a5ef 100644 (file)
@@ -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
index 5e90f81..efa5d21 100644 (file)
@@ -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
index 43ed9ae..9231c0d 100644 (file)
@@ -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
index 50dc882..cbb961e 100644 (file)
@@ -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
index 0e176de..068e2d3 100644 (file)
@@ -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);
index cae8800..017684b 100644 (file)
@@ -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;
 }
index 8c5fd7f..1f196e1 100644 (file)
@@ -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;
 }
index ae9e771..f798c6f 100644 (file)
@@ -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;
index 6b22261..da3564e 100644 (file)
@@ -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);
 }
index 50bc9bb..245dcbd 100644 (file)
@@ -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);
 }
index 6083abf..60ef71d 100644 (file)
@@ -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
 }
index bfe61c0..139f1e1 100644 (file)
@@ -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
 }
index b1d27de..93d5918 100644 (file)
@@ -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
index 580e919..a08b009 100644 (file)
 #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)
 {
index 8822b02..d95be3e 100644 (file)
@@ -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
index be32164..c37874e 100644 (file)
@@ -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
 
index 7509681..c1d8d6f 100644 (file)
@@ -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
index 1069ee9..e984bf8 100644 (file)
@@ -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 */
 
index e09b611..6b9c251 100644 (file)
@@ -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
index 0260345..d3047e7 100644 (file)
@@ -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)
index e92a0bb..281dc5b 100644 (file)
@@ -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
 }
 
index 276ccf1..a7d9f55 100644 (file)
@@ -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
index ab124a0..9a467bf 100644 (file)
@@ -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 af26584..14047cb 100644 (file)
@@ -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
index eea460a..b891654 100644 (file)
@@ -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
index 8215afa..397534a 100644 (file)
@@ -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
index 3dab653..0210d90 100644 (file)
@@ -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
index c66778e..e5010d4 100644 (file)
@@ -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__ */
index bc20d1e..b0a00e1 100644 (file)
@@ -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;
 }
 
index 8b7a1bf..d0cfe52 100644 (file)
@@ -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
diff --git a/libc/sysdeps/linux/common/bits/uClibc_pthread.h b/libc/sysdeps/linux/common/bits/uClibc_pthread.h
new file mode 100644 (file)
index 0000000..348fd9d
--- /dev/null
@@ -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
index cd278c1..9046816 100644 (file)
 
 #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)
index dbb44bb..051bb75 100644 (file)
@@ -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>
 
index 3c97ea7..7cc344f 100644 (file)
@@ -14,7 +14,6 @@
 
 /* Mutexes */
 
-#include <bits/libc-lock.h>
 #include <errno.h>
 #include <sched.h>
 #include <stddef.h>
index 0fbc6c9..d8b5bb0 100644 (file)
@@ -23,7 +23,6 @@
 #include "internals.h"
 #include "spinlock.h"
 #include "restart.h"
-#include <bits/libc-lock.h>
 
 
 /* Table of keys. */