summaryrefslogtreecommitdiff
path: root/libpthread/linuxthreads/mutex.c
diff options
context:
space:
mode:
Diffstat (limited to 'libpthread/linuxthreads/mutex.c')
-rw-r--r--libpthread/linuxthreads/mutex.c57
1 files changed, 31 insertions, 26 deletions
diff --git a/libpthread/linuxthreads/mutex.c b/libpthread/linuxthreads/mutex.c
index 3c97ea7d6..890841452 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>
@@ -25,7 +24,7 @@
#include "queue.h"
#include "restart.h"
-int __pthread_mutex_init(pthread_mutex_t * mutex,
+int attribute_hidden __pthread_mutex_init(pthread_mutex_t * mutex,
const pthread_mutexattr_t * mutex_attr)
{
__pthread_init_lock(&mutex->__m_lock);
@@ -37,7 +36,7 @@ int __pthread_mutex_init(pthread_mutex_t * mutex,
}
strong_alias (__pthread_mutex_init, pthread_mutex_init)
-int __pthread_mutex_destroy(pthread_mutex_t * mutex)
+int attribute_hidden __pthread_mutex_destroy(pthread_mutex_t * mutex)
{
switch (mutex->__m_kind) {
case PTHREAD_MUTEX_ADAPTIVE_NP:
@@ -56,7 +55,7 @@ int __pthread_mutex_destroy(pthread_mutex_t * mutex)
}
strong_alias (__pthread_mutex_destroy, pthread_mutex_destroy)
-int __pthread_mutex_trylock(pthread_mutex_t * mutex)
+int attribute_hidden __pthread_mutex_trylock(pthread_mutex_t * mutex)
{
pthread_descr self;
int retcode;
@@ -92,7 +91,7 @@ int __pthread_mutex_trylock(pthread_mutex_t * mutex)
}
strong_alias (__pthread_mutex_trylock, pthread_mutex_trylock)
-int __pthread_mutex_lock(pthread_mutex_t * mutex)
+int attribute_hidden __pthread_mutex_lock(pthread_mutex_t * mutex)
{
pthread_descr self;
@@ -125,7 +124,7 @@ int __pthread_mutex_lock(pthread_mutex_t * mutex)
}
strong_alias (__pthread_mutex_lock, pthread_mutex_lock)
-int __pthread_mutex_timedlock (pthread_mutex_t *mutex,
+int pthread_mutex_timedlock (pthread_mutex_t *mutex,
const struct timespec *abstime)
{
pthread_descr self;
@@ -167,9 +166,8 @@ int __pthread_mutex_timedlock (pthread_mutex_t *mutex,
return EINVAL;
}
}
-strong_alias (__pthread_mutex_timedlock, pthread_mutex_timedlock)
-int __pthread_mutex_unlock(pthread_mutex_t * mutex)
+int attribute_hidden __pthread_mutex_unlock(pthread_mutex_t * mutex)
{
switch (mutex->__m_kind) {
case PTHREAD_MUTEX_ADAPTIVE_NP:
@@ -200,20 +198,20 @@ int __pthread_mutex_unlock(pthread_mutex_t * mutex)
}
strong_alias (__pthread_mutex_unlock, pthread_mutex_unlock)
-int __pthread_mutexattr_init(pthread_mutexattr_t *attr)
+int attribute_hidden __pthread_mutexattr_init(pthread_mutexattr_t *attr)
{
attr->__mutexkind = PTHREAD_MUTEX_TIMED_NP;
return 0;
}
-strong_alias (__pthread_mutexattr_init, pthread_mutexattr_init)
+strong_alias(__pthread_mutexattr_init,pthread_mutexattr_init)
-int __pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
+int attribute_hidden __pthread_mutexattr_destroy(pthread_mutexattr_t *attr attribute_unused)
{
return 0;
}
-strong_alias (__pthread_mutexattr_destroy, pthread_mutexattr_destroy)
+strong_alias(__pthread_mutexattr_destroy,pthread_mutexattr_destroy)
-int __pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind)
+int attribute_hidden __pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind)
{
if (kind != PTHREAD_MUTEX_ADAPTIVE_NP
&& kind != PTHREAD_MUTEX_RECURSIVE_NP
@@ -223,10 +221,11 @@ int __pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind)
attr->__mutexkind = kind;
return 0;
}
-weak_alias (__pthread_mutexattr_settype, pthread_mutexattr_settype)
-strong_alias ( __pthread_mutexattr_settype, __pthread_mutexattr_setkind_np)
+strong_alias(__pthread_mutexattr_settype,pthread_mutexattr_settype)
+strong_alias (__pthread_mutexattr_settype, __pthread_mutexattr_setkind_np)
weak_alias (__pthread_mutexattr_setkind_np, pthread_mutexattr_setkind_np)
+int __pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *kind) attribute_hidden;
int __pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *kind)
{
*kind = attr->__mutexkind;
@@ -236,7 +235,9 @@ weak_alias (__pthread_mutexattr_gettype, pthread_mutexattr_gettype)
strong_alias (__pthread_mutexattr_gettype, __pthread_mutexattr_getkind_np)
weak_alias (__pthread_mutexattr_getkind_np, pthread_mutexattr_getkind_np)
-int __pthread_mutexattr_getpshared (const pthread_mutexattr_t *attr,
+int __pthread_mutexattr_getpshared (const pthread_mutexattr_t *attr attribute_unused,
+ int *pshared) attribute_hidden;
+int __pthread_mutexattr_getpshared (const pthread_mutexattr_t *attr attribute_unused,
int *pshared)
{
*pshared = PTHREAD_PROCESS_PRIVATE;
@@ -244,7 +245,8 @@ int __pthread_mutexattr_getpshared (const pthread_mutexattr_t *attr,
}
weak_alias (__pthread_mutexattr_getpshared, pthread_mutexattr_getpshared)
-int __pthread_mutexattr_setpshared (pthread_mutexattr_t *attr, int pshared)
+int __pthread_mutexattr_setpshared (pthread_mutexattr_t *attr attribute_unused, int pshared) attribute_hidden;
+int __pthread_mutexattr_setpshared (pthread_mutexattr_t *attr attribute_unused, int pshared)
{
if (pshared != PTHREAD_PROCESS_PRIVATE && pshared != PTHREAD_PROCESS_SHARED)
return EINVAL;
@@ -273,9 +275,9 @@ static void pthread_once_cancelhandler(void *arg)
{
pthread_once_t *once_control = arg;
- pthread_mutex_lock(&once_masterlock);
+ __pthread_mutex_lock(&once_masterlock);
*once_control = NEVER;
- pthread_mutex_unlock(&once_masterlock);
+ __pthread_mutex_unlock(&once_masterlock);
pthread_cond_broadcast(&once_finished);
}
@@ -293,7 +295,7 @@ int __pthread_once(pthread_once_t * once_control, void (*init_routine)(void))
state_changed = 0;
- pthread_mutex_lock(&once_masterlock);
+ __pthread_mutex_lock(&once_masterlock);
/* If this object was left in an IN_PROGRESS state in a parent
process (indicated by stale generation field), reset it to NEVER. */
@@ -308,16 +310,16 @@ int __pthread_once(pthread_once_t * once_control, void (*init_routine)(void))
/* Here *once_control is stable and either NEVER or DONE. */
if (*once_control == NEVER) {
*once_control = IN_PROGRESS | fork_generation;
- pthread_mutex_unlock(&once_masterlock);
+ __pthread_mutex_unlock(&once_masterlock);
pthread_cleanup_push(pthread_once_cancelhandler, once_control);
init_routine();
pthread_cleanup_pop(0);
- pthread_mutex_lock(&once_masterlock);
+ __pthread_mutex_lock(&once_masterlock);
WRITE_MEMORY_BARRIER();
*once_control = DONE;
state_changed = 1;
}
- pthread_mutex_unlock(&once_masterlock);
+ __pthread_mutex_unlock(&once_masterlock);
if (state_changed)
pthread_cond_broadcast(&once_finished);
@@ -336,19 +338,22 @@ strong_alias (__pthread_once, pthread_once)
* and reset them back to NEVER.
*/
+void __pthread_once_fork_prepare(void);
void __pthread_once_fork_prepare(void)
{
- pthread_mutex_lock(&once_masterlock);
+ __pthread_mutex_lock(&once_masterlock);
}
+void __pthread_once_fork_parent(void);
void __pthread_once_fork_parent(void)
{
- pthread_mutex_unlock(&once_masterlock);
+ __pthread_mutex_unlock(&once_masterlock);
}
+void __pthread_once_fork_child(void);
void __pthread_once_fork_child(void)
{
- pthread_mutex_init(&once_masterlock, NULL);
+ __pthread_mutex_init(&once_masterlock, NULL);
pthread_cond_init(&once_finished, NULL);
if (fork_generation <= INT_MAX - 4)
fork_generation += 4; /* leave least significant two bits zero */