summaryrefslogtreecommitdiff
path: root/libc/misc
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 /libc/misc
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.
Diffstat (limited to 'libc/misc')
-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
14 files changed, 30 insertions, 95 deletions
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 */