diff options
| author | joerg <joerg@NetBSD.org> | 2012-03-12 21:35:10 +0000 |
|---|---|---|
| committer | joerg <joerg@NetBSD.org> | 2012-03-12 21:35:10 +0000 |
| commit | ec7655a88ca7fce2db118bbf584c6b7770553dbd (patch) | |
| tree | db9cfa361e0a9dea9e606114c7d6c051aab20972 /lib/libpthread/pthread_mutex.c | |
| parent | 5f486c0418a1150a217a311b5f87e07a48a51413 (diff) | |
Move pthread_once implementation into a separate file, it doesn't depend
on the mutex implementation in any way.
Diffstat (limited to 'lib/libpthread/pthread_mutex.c')
| -rw-r--r-- | lib/libpthread/pthread_mutex.c | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/lib/libpthread/pthread_mutex.c b/lib/libpthread/pthread_mutex.c index cf05088d22d..757d4f21d4f 100644 --- a/lib/libpthread/pthread_mutex.c +++ b/lib/libpthread/pthread_mutex.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_mutex.c,v 1.51 2008/08/02 19:46:30 matt Exp $ */ +/* $NetBSD: pthread_mutex.c,v 1.52 2012/03/12 21:35:10 joerg Exp $ */ /*- * Copyright (c) 2001, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -47,7 +47,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: pthread_mutex.c,v 1.51 2008/08/02 19:46:30 matt Exp $"); +__RCSID("$NetBSD: pthread_mutex.c,v 1.52 2012/03/12 21:35:10 joerg Exp $"); #include <sys/types.h> #include <sys/lwpctl.h> @@ -548,7 +548,6 @@ pthread_mutexattr_destroy(pthread_mutexattr_t *attr) return 0; } - int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *typep) { @@ -560,7 +559,6 @@ pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *typep) return 0; } - int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) { @@ -579,32 +577,6 @@ pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) } } - -static void -once_cleanup(void *closure) -{ - - pthread_mutex_unlock((pthread_mutex_t *)closure); -} - - -int -pthread_once(pthread_once_t *once_control, void (*routine)(void)) -{ - - if (once_control->pto_done == 0) { - pthread_mutex_lock(&once_control->pto_mutex); - pthread_cleanup_push(&once_cleanup, &once_control->pto_mutex); - if (once_control->pto_done == 0) { - routine(); - once_control->pto_done = 1; - } - pthread_cleanup_pop(1); - } - - return 0; -} - void pthread__mutex_deferwake(pthread_t self, pthread_mutex_t *ptm) { |
