summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2003-12-27 23:30:50 +0000
committerManuel Novoa III <mjn3@codepoet.org>2003-12-27 23:30:50 +0000
commitd05dafe2fc23137f8decd641d82d23f45e16281c (patch)
tree83fb903ed075f81269ef2b1ee4b0edf0741ff70f
parentcb19f2f71fa01b6d40dae3190cb6dd1d2116f852 (diff)
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.
-rw-r--r--include/pthread.h3
-rw-r--r--libc/inet/getnetent.c4
-rw-r--r--libc/inet/getproto.c4
-rw-r--r--libc/inet/getservice.c4
-rw-r--r--libc/inet/resolv.c12
-rw-r--r--libc/inet/rpc/create_xid.c4
-rw-r--r--libc/misc/dirent/closedir.c4
-rw-r--r--libc/misc/dirent/opendir.c2
-rw-r--r--libc/misc/dirent/readdir.c4
-rw-r--r--libc/misc/dirent/readdir64.c4
-rw-r--r--libc/misc/dirent/readdir64_r.c4
-rw-r--r--libc/misc/dirent/readdir_r.c4
-rw-r--r--libc/misc/dirent/rewinddir.c4
-rw-r--r--libc/misc/dirent/seekdir.c4
-rw-r--r--libc/misc/mntent/mntent.c4
-rw-r--r--libc/misc/pthread/weaks.c73
-rw-r--r--libc/misc/syslog/syslog.c4
-rw-r--r--libc/misc/time/time.c4
-rw-r--r--libc/misc/utmp/utent.c4
-rw-r--r--libc/misc/wchar/wstdio.c6
-rw-r--r--libc/pwd_grp/lckpwdf.c4
-rw-r--r--libc/pwd_grp/pwd_grp.c12
-rw-r--r--libc/stdio/stdio.c12
-rw-r--r--libc/stdlib/abort.c4
-rw-r--r--libc/stdlib/atexit.c4
-rw-r--r--libc/stdlib/malloc-930716/malloc.c4
-rw-r--r--libc/stdlib/malloc-930716/memalign.c4
-rw-r--r--libc/stdlib/malloc-930716/realloc.c4
-rw-r--r--libc/stdlib/malloc/heap.h4
-rw-r--r--libc/stdlib/malloc/malloc.h4
-rw-r--r--libc/stdlib/random.c20
-rw-r--r--libc/stdlib/setenv.c4
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_pthread.h39
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_stdio.h6
-rw-r--r--libpthread/linuxthreads/lockfile.c1
-rw-r--r--libpthread/linuxthreads/mutex.c1
-rw-r--r--libpthread/linuxthreads/specific.c1
37 files changed, 129 insertions, 155 deletions
diff --git a/include/pthread.h b/include/pthread.h
index 2b7b79834..846b9cc93 100644
--- a/include/pthread.h
+++ b/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
diff --git a/libc/inet/getnetent.c b/libc/inet/getnetent.c
index 0b4c36dcb..9ade1f6b2 100644
--- a/libc/inet/getnetent.c
+++ b/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
diff --git a/libc/inet/getproto.c b/libc/inet/getproto.c
index 2a5fc8f8f..1d3a5eff5 100644
--- a/libc/inet/getproto.c
+++ b/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
diff --git a/libc/inet/getservice.c b/libc/inet/getservice.c
index 5e90f8198..efa5d214d 100644
--- a/libc/inet/getservice.c
+++ b/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
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index 43ed9ae1e..9231c0d9e 100644
--- a/libc/inet/resolv.c
+++ b/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
diff --git a/libc/inet/rpc/create_xid.c b/libc/inet/rpc/create_xid.c
index 50dc882e5..cbb961e4d 100644
--- a/libc/inet/rpc/create_xid.c
+++ b/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
diff --git a/libc/misc/dirent/closedir.c b/libc/misc/dirent/closedir.c
index 0e176deb7..068e2d3e2 100644
--- a/libc/misc/dirent/closedir.c
+++ b/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);
diff --git a/libc/misc/dirent/opendir.c b/libc/misc/dirent/opendir.c
index cae8800d8..017684b40 100644
--- a/libc/misc/dirent/opendir.c
+++ b/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;
}
diff --git a/libc/misc/dirent/readdir.c b/libc/misc/dirent/readdir.c
index 8c5fd7f1a..1f196e1e7 100644
--- a/libc/misc/dirent/readdir.c
+++ b/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;
}
diff --git a/libc/misc/dirent/readdir64.c b/libc/misc/dirent/readdir64.c
index ae9e771e8..f798c6fbb 100644
--- a/libc/misc/dirent/readdir64.c
+++ b/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;
diff --git a/libc/misc/dirent/readdir64_r.c b/libc/misc/dirent/readdir64_r.c
index 6b22261db..da3564edb 100644
--- a/libc/misc/dirent/readdir64_r.c
+++ b/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);
}
diff --git a/libc/misc/dirent/readdir_r.c b/libc/misc/dirent/readdir_r.c
index 50bc9bb6d..245dcbdde 100644
--- a/libc/misc/dirent/readdir_r.c
+++ b/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);
}
diff --git a/libc/misc/dirent/rewinddir.c b/libc/misc/dirent/rewinddir.c
index 6083abf13..60ef71da7 100644
--- a/libc/misc/dirent/rewinddir.c
+++ b/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
}
diff --git a/libc/misc/dirent/seekdir.c b/libc/misc/dirent/seekdir.c
index bfe61c0c2..139f1e1e5 100644
--- a/libc/misc/dirent/seekdir.c
+++ b/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
}
diff --git a/libc/misc/mntent/mntent.c b/libc/misc/mntent/mntent.c
index b1d27de2c..93d591812 100644
--- a/libc/misc/mntent/mntent.c
+++ b/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
diff --git a/libc/misc/pthread/weaks.c b/libc/misc/pthread/weaks.c
index 580e9192e..a08b00984 100644
--- a/libc/misc/pthread/weaks.c
+++ b/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)
{
diff --git a/libc/misc/syslog/syslog.c b/libc/misc/syslog/syslog.c
index 8822b02a5..d95be3e5e 100644
--- a/libc/misc/syslog/syslog.c
+++ b/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
diff --git a/libc/misc/time/time.c b/libc/misc/time/time.c
index be3216423..c37874e28 100644
--- a/libc/misc/time/time.c
+++ b/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
diff --git a/libc/misc/utmp/utent.c b/libc/misc/utmp/utent.c
index 7509681a9..c1d8d6fa2 100644
--- a/libc/misc/utmp/utent.c
+++ b/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
diff --git a/libc/misc/wchar/wstdio.c b/libc/misc/wchar/wstdio.c
index 1069ee938..e984bf837 100644
--- a/libc/misc/wchar/wstdio.c
+++ b/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 */
diff --git a/libc/pwd_grp/lckpwdf.c b/libc/pwd_grp/lckpwdf.c
index e09b611e2..6b9c2519b 100644
--- a/libc/pwd_grp/lckpwdf.c
+++ b/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
diff --git a/libc/pwd_grp/pwd_grp.c b/libc/pwd_grp/pwd_grp.c
index 026034515..d3047e760 100644
--- a/libc/pwd_grp/pwd_grp.c
+++ b/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)
diff --git a/libc/stdio/stdio.c b/libc/stdio/stdio.c
index e92a0bb00..281dc5bf5 100644
--- a/libc/stdio/stdio.c
+++ b/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
}
diff --git a/libc/stdlib/abort.c b/libc/stdlib/abort.c
index 276ccf1a6..a7d9f5575 100644
--- a/libc/stdlib/abort.c
+++ b/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
diff --git a/libc/stdlib/atexit.c b/libc/stdlib/atexit.c
index ab124a09f..9a467bf79 100644
--- a/libc/stdlib/atexit.c
+++ b/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
diff --git a/libc/stdlib/malloc-930716/malloc.c b/libc/stdlib/malloc-930716/malloc.c
index af2658415..14047cb02 100644
--- a/libc/stdlib/malloc-930716/malloc.c
+++ b/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
diff --git a/libc/stdlib/malloc-930716/memalign.c b/libc/stdlib/malloc-930716/memalign.c
index eea460aad..b89165452 100644
--- a/libc/stdlib/malloc-930716/memalign.c
+++ b/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
diff --git a/libc/stdlib/malloc-930716/realloc.c b/libc/stdlib/malloc-930716/realloc.c
index 8215afa8d..397534a5a 100644
--- a/libc/stdlib/malloc-930716/realloc.c
+++ b/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
diff --git a/libc/stdlib/malloc/heap.h b/libc/stdlib/malloc/heap.h
index 3dab65396..0210d9098 100644
--- a/libc/stdlib/malloc/heap.h
+++ b/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
diff --git a/libc/stdlib/malloc/malloc.h b/libc/stdlib/malloc/malloc.h
index c66778eeb..e5010d49b 100644
--- a/libc/stdlib/malloc/malloc.h
+++ b/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__ */
diff --git a/libc/stdlib/random.c b/libc/stdlib/random.c
index bc20d1e1b..b0a00e15c 100644
--- a/libc/stdlib/random.c
+++ b/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;
}
diff --git a/libc/stdlib/setenv.c b/libc/stdlib/setenv.c
index 8b7a1bf2d..d0cfe526d 100644
--- a/libc/stdlib/setenv.c
+++ b/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
diff --git a/libc/sysdeps/linux/common/bits/uClibc_pthread.h b/libc/sysdeps/linux/common/bits/uClibc_pthread.h
new file mode 100644
index 000000000..348fd9d7d
--- /dev/null
+++ b/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
diff --git a/libc/sysdeps/linux/common/bits/uClibc_stdio.h b/libc/sysdeps/linux/common/bits/uClibc_stdio.h
index cd278c13c..904681631 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_stdio.h
+++ b/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)
diff --git a/libpthread/linuxthreads/lockfile.c b/libpthread/linuxthreads/lockfile.c
index dbb44bb31..051bb75bc 100644
--- a/libpthread/linuxthreads/lockfile.c
+++ b/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>
diff --git a/libpthread/linuxthreads/mutex.c b/libpthread/linuxthreads/mutex.c
index 3c97ea7d6..7cc344fac 100644
--- a/libpthread/linuxthreads/mutex.c
+++ b/libpthread/linuxthreads/mutex.c
@@ -14,7 +14,6 @@
/* Mutexes */
-#include <bits/libc-lock.h>
#include <errno.h>
#include <sched.h>
#include <stddef.h>
diff --git a/libpthread/linuxthreads/specific.c b/libpthread/linuxthreads/specific.c
index 0fbc6c9da..d8b5bb0b3 100644
--- a/libpthread/linuxthreads/specific.c
+++ b/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. */