summaryrefslogtreecommitdiffstats
path: root/lib/libc_r/uthread/uthread_mutex.c
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>2002-11-13 18:13:26 +0000
committerdeischen <deischen@FreeBSD.org>2002-11-13 18:13:26 +0000
commit524a6c841c467da890061cbdc2ace08d30e6e780 (patch)
tree666eecc4a4a3cc9346ca8828770bb7ef3723e4b2 /lib/libc_r/uthread/uthread_mutex.c
parentbf8788517dc3dbb62a46b61b9a2e31a4ba2d3dd4 (diff)
downloadFreeBSD-src-524a6c841c467da890061cbdc2ace08d30e6e780.zip
FreeBSD-src-524a6c841c467da890061cbdc2ace08d30e6e780.tar.gz
At initialization, override the pthread stub routines in libc
by filling in the jump table. Convert uses of pthread routines within libc_r to use the internal versions (_pthread_foo instead of pthread_foo). Remove a couple of globals from application namespace.
Diffstat (limited to 'lib/libc_r/uthread/uthread_mutex.c')
-rw-r--r--lib/libc_r/uthread/uthread_mutex.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/lib/libc_r/uthread/uthread_mutex.c b/lib/libc_r/uthread/uthread_mutex.c
index 7951815..dc94d45 100644
--- a/lib/libc_r/uthread/uthread_mutex.c
+++ b/lib/libc_r/uthread/uthread_mutex.c
@@ -88,7 +88,9 @@ __weak_reference(_pthread_mutex_destroy, pthread_mutex_destroy);
__weak_reference(_pthread_mutex_unlock, pthread_mutex_unlock);
-/* Reinitialize a mutex to defaults. */
+/*
+ * Reinitialize a private mutex; this is only used for internal mutexes.
+ */
int
_mutex_reinit(pthread_mutex_t * mutex)
{
@@ -97,7 +99,7 @@ _mutex_reinit(pthread_mutex_t * mutex)
if (mutex == NULL)
ret = EINVAL;
else if (*mutex == NULL)
- ret = pthread_mutex_init(mutex, NULL);
+ ret = _pthread_mutex_init(mutex, NULL);
else {
/*
* Initialize the mutex structure:
@@ -107,8 +109,7 @@ _mutex_reinit(pthread_mutex_t * mutex)
TAILQ_INIT(&(*mutex)->m_queue);
(*mutex)->m_owner = NULL;
(*mutex)->m_data.m_count = 0;
- (*mutex)->m_flags &= MUTEX_FLAGS_PRIVATE;
- (*mutex)->m_flags |= MUTEX_FLAGS_INITED;
+ (*mutex)->m_flags |= MUTEX_FLAGS_INITED | MUTEX_FLAGS_PRIVATE;
(*mutex)->m_refcount = 0;
(*mutex)->m_prio = 0;
(*mutex)->m_saved_prio = 0;
@@ -133,7 +134,7 @@ _pthread_mutex_init(pthread_mutex_t * mutex,
ret = EINVAL;
/* Check if default mutex attributes: */
- else if (mutex_attr == NULL || *mutex_attr == NULL) {
+ if (mutex_attr == NULL || *mutex_attr == NULL) {
/* Default to a (error checking) POSIX mutex: */
type = PTHREAD_MUTEX_ERRORCHECK;
protocol = PTHREAD_PRIO_NONE;
@@ -213,7 +214,7 @@ _pthread_mutex_init(pthread_mutex_t * mutex,
}
}
/* Return the completion status: */
- return(ret);
+ return (ret);
}
int
@@ -272,7 +273,7 @@ init_static(pthread_mutex_t *mutex)
_SPINUNLOCK(&static_init_lock);
- return(ret);
+ return (ret);
}
static int
@@ -289,7 +290,7 @@ init_static_private(pthread_mutex_t *mutex)
_SPINUNLOCK(&static_init_lock);
- return(ret);
+ return (ret);
}
static int
@@ -759,7 +760,7 @@ int
_mutex_cv_lock(pthread_mutex_t * mutex)
{
int ret;
- if ((ret = pthread_mutex_lock(mutex)) == 0)
+ if ((ret = _pthread_mutex_lock(mutex)) == 0)
(*mutex)->m_refcount--;
return (ret);
}
@@ -791,7 +792,7 @@ mutex_self_trylock(pthread_mutex_t mutex)
ret = EINVAL;
}
- return(ret);
+ return (ret);
}
static inline int
@@ -828,7 +829,7 @@ mutex_self_lock(pthread_mutex_t mutex)
ret = EINVAL;
}
- return(ret);
+ return (ret);
}
static inline int
@@ -1445,7 +1446,7 @@ _mutex_unlock_private(pthread_t pthread)
for (m = TAILQ_FIRST(&pthread->mutexq); m != NULL; m = m_next) {
m_next = TAILQ_NEXT(m, m_qe);
if ((m->m_flags & MUTEX_FLAGS_PRIVATE) != 0)
- pthread_mutex_unlock(&m);
+ _pthread_mutex_unlock(&m);
}
}
@@ -1502,7 +1503,7 @@ mutex_queue_deq(pthread_mutex_t mutex)
break;
}
- return(pthread);
+ return (pthread);
}
/*
OpenPOWER on IntegriCloud