From 19451dc5e3337ab361837bde4e0e875049f51aa5 Mon Sep 17 00:00:00 2001 From: zrj Date: Fri, 16 Sep 2016 12:18:50 +0300 Subject: [PATCH] pthread: General pre-cleanup (style, typos etc) No functional change. --- lib/libthread_xu/Makefile | 1 - .../arch/x86_64/include/pthread_md.h | 1 - .../arch/x86_64/x86_64/pthread_md.c | 2 +- lib/libthread_xu/pthread.map | 1 - lib/libthread_xu/thread/Makefile.inc | 1 - lib/libthread_xu/thread/thr_attr.c | 8 +- lib/libthread_xu/thread/thr_barrier.c | 13 +- lib/libthread_xu/thread/thr_barrierattr.c | 6 +- lib/libthread_xu/thread/thr_cancel.c | 2 - lib/libthread_xu/thread/thr_clean.c | 3 - lib/libthread_xu/thread/thr_concurrency.c | 1 - lib/libthread_xu/thread/thr_cond.c | 19 +- lib/libthread_xu/thread/thr_condattr.c | 5 +- lib/libthread_xu/thread/thr_create.c | 5 +- lib/libthread_xu/thread/thr_equal.c | 2 - lib/libthread_xu/thread/thr_event.c | 1 - lib/libthread_xu/thread/thr_exit.c | 4 +- lib/libthread_xu/thread/thr_fork.c | 6 +- lib/libthread_xu/thread/thr_getprio.c | 1 - lib/libthread_xu/thread/thr_getschedparam.c | 4 +- lib/libthread_xu/thread/thr_info.c | 1 - lib/libthread_xu/thread/thr_init.c | 4 +- lib/libthread_xu/thread/thr_join.c | 3 +- lib/libthread_xu/thread/thr_kern.c | 6 +- lib/libthread_xu/thread/thr_kill.c | 2 - lib/libthread_xu/thread/thr_list.c | 3 +- lib/libthread_xu/thread/thr_main_np.c | 3 +- lib/libthread_xu/thread/thr_multi_np.c | 1 - lib/libthread_xu/thread/thr_mutex.c | 7 +- .../thread/thr_mutex_prioceiling.c | 2 - lib/libthread_xu/thread/thr_mutex_protocol.c | 2 - lib/libthread_xu/thread/thr_mutexattr.c | 11 +- lib/libthread_xu/thread/thr_once.c | 6 +- lib/libthread_xu/thread/thr_printf.c | 2 +- lib/libthread_xu/thread/thr_private.h | 52 +++--- lib/libthread_xu/thread/thr_pspinlock.c | 22 +-- lib/libthread_xu/thread/thr_resume_np.c | 3 - lib/libthread_xu/thread/thr_rtld.c | 3 +- lib/libthread_xu/thread/thr_rwlock.c | 7 +- lib/libthread_xu/thread/thr_rwlockattr.c | 37 ++-- lib/libthread_xu/thread/thr_self.c | 1 - lib/libthread_xu/thread/thr_sem.c | 13 +- lib/libthread_xu/thread/thr_setprio.c | 1 - lib/libthread_xu/thread/thr_setschedparam.c | 4 +- lib/libthread_xu/thread/thr_sig.c | 3 - lib/libthread_xu/thread/thr_single_np.c | 4 +- lib/libthread_xu/thread/thr_spec.c | 17 +- lib/libthread_xu/thread/thr_spinlock.c | 1 - lib/libthread_xu/thread/thr_stack.c | 7 +- lib/libthread_xu/thread/thr_suspend_np.c | 4 +- lib/libthread_xu/thread/thr_switch_np.c | 2 - lib/libthread_xu/thread/thr_symbols.c | 1 - lib/libthread_xu/thread/thr_syscalls.c | 44 ++--- lib/libthread_xu/thread/thr_umtx.c | 175 +++++++++--------- lib/libthread_xu/thread/thr_umtx.h | 30 ++- lib/libthread_xu/thread/thr_yield.c | 1 - 56 files changed, 235 insertions(+), 336 deletions(-) diff --git a/lib/libthread_xu/Makefile b/lib/libthread_xu/Makefile index e0ee428e74..44a31662f3 100644 --- a/lib/libthread_xu/Makefile +++ b/lib/libthread_xu/Makefile @@ -1,5 +1,4 @@ # $FreeBSD: src/lib/libpthread/Makefile,v 1.53 2004/10/24 15:32:32 ru Exp $ -# $DragonFly: src/lib/libthread_xu/Makefile,v 1.7 2008/10/28 17:23:46 swildner Exp $ LIB=thread_xu SHLIB_MAJOR= 2 diff --git a/lib/libthread_xu/arch/x86_64/include/pthread_md.h b/lib/libthread_xu/arch/x86_64/include/pthread_md.h index 4b925d9aa9..8db1d190ee 100644 --- a/lib/libthread_xu/arch/x86_64/include/pthread_md.h +++ b/lib/libthread_xu/arch/x86_64/include/pthread_md.h @@ -35,7 +35,6 @@ #include #include - #include #include diff --git a/lib/libthread_xu/arch/x86_64/x86_64/pthread_md.c b/lib/libthread_xu/arch/x86_64/x86_64/pthread_md.c index a8f30887c1..c8b0c7cf77 100644 --- a/lib/libthread_xu/arch/x86_64/x86_64/pthread_md.c +++ b/lib/libthread_xu/arch/x86_64/x86_64/pthread_md.c @@ -44,7 +44,7 @@ _tcb_ctor(struct pthread *thread, int initial) if (initial) tcb = tls_get_tcb(); else - tcb = _libc_allocate_tls(); + tcb = _libc_allocate_tls(); if (tcb == NULL) return (NULL); diff --git a/lib/libthread_xu/pthread.map b/lib/libthread_xu/pthread.map index ae622cf585..e38cc19631 100644 --- a/lib/libthread_xu/pthread.map +++ b/lib/libthread_xu/pthread.map @@ -1,4 +1,3 @@ -# $FreeBSD: src/lib/libpthread/pthread.map,v 1.13 2010/10/23 $ LIBTHREAD_1_0 { global: diff --git a/lib/libthread_xu/thread/Makefile.inc b/lib/libthread_xu/thread/Makefile.inc index 6bb4620f44..d8ee33e20c 100644 --- a/lib/libthread_xu/thread/Makefile.inc +++ b/lib/libthread_xu/thread/Makefile.inc @@ -1,4 +1,3 @@ -# $DragonFly: src/lib/libthread_xu/thread/Makefile.inc,v 1.5 2008/01/19 14:05:29 corecode Exp $ # thr sources .PATH: ${.CURDIR}/thread diff --git a/lib/libthread_xu/thread/thr_attr.c b/lib/libthread_xu/thread/thr_attr.c index 273f43c1a6..c614ed7a53 100644 --- a/lib/libthread_xu/thread/thr_attr.c +++ b/lib/libthread_xu/thread/thr_attr.c @@ -33,7 +33,6 @@ #include "namespace.h" #include - #include #include #include @@ -210,8 +209,8 @@ __strong_reference(_pthread_attr_getscope, pthread_attr_getscope); int _pthread_attr_getstack(const pthread_attr_t * __restrict attr, - void ** __restrict stackaddr, - size_t * __restrict stacksize) + void ** __restrict stackaddr, + size_t * __restrict stacksize) { int ret; @@ -432,7 +431,7 @@ __strong_reference(_pthread_attr_setscope, pthread_attr_setscope); int _pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, - size_t stacksize) + size_t stacksize) { int ret; @@ -486,4 +485,3 @@ _pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize) } __strong_reference(_pthread_attr_setstacksize, pthread_attr_setstacksize); - diff --git a/lib/libthread_xu/thread/thr_barrier.c b/lib/libthread_xu/thread/thr_barrier.c index 7eca777320..4e2ea0387e 100644 --- a/lib/libthread_xu/thread/thr_barrier.c +++ b/lib/libthread_xu/thread/thr_barrier.c @@ -24,12 +24,10 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libpthread/thread/thr_barrier.c,v 1.1 2003/09/04 14:06:43 davidxu Exp $ - * $DragonFly: src/lib/libthread_xu/thread/thr_barrier.c,v 1.6 2006/04/06 13:03:09 davidxu Exp $ */ #include "namespace.h" #include - #include #include #include @@ -40,7 +38,7 @@ int _pthread_barrier_destroy(pthread_barrier_t *barrier) { - pthread_barrier_t bar; + pthread_barrier_t bar; if (barrier == NULL || *barrier == NULL) return (EINVAL); @@ -55,9 +53,9 @@ _pthread_barrier_destroy(pthread_barrier_t *barrier) int _pthread_barrier_init(pthread_barrier_t *barrier, - const pthread_barrierattr_t *attr __unused, unsigned count) + const pthread_barrierattr_t *attr __unused, unsigned count) { - pthread_barrier_t bar; + pthread_barrier_t bar; if (barrier == NULL || count <= 0) return (EINVAL); @@ -78,15 +76,16 @@ _pthread_barrier_init(pthread_barrier_t *barrier, int _pthread_barrier_wait(pthread_barrier_t *barrier) { - struct pthread *curthread = tls_get_curthread(); + struct pthread *curthread; pthread_barrier_t bar; - long cycle; + int64_t cycle; int ret; if (barrier == NULL || *barrier == NULL) return (EINVAL); bar = *barrier; + curthread = tls_get_curthread(); THR_UMTX_LOCK(curthread, &bar->b_lock); if (++bar->b_waiters == bar->b_count) { /* Current thread is lastest thread */ diff --git a/lib/libthread_xu/thread/thr_barrierattr.c b/lib/libthread_xu/thread/thr_barrierattr.c index 403a8d8a9e..0f621e5ab0 100644 --- a/lib/libthread_xu/thread/thr_barrierattr.c +++ b/lib/libthread_xu/thread/thr_barrierattr.c @@ -7,7 +7,7 @@ * are met: * 1. Redistributions of source code must retain the above copyright * notice(s), this list of conditions and the following disclaimer as - * the first lines of this file unmodified other than the possible + * the first lines of this file unmodified other than the possible * addition of one or more copyright notices. * 2. Redistributions in binary form must reproduce the above copyright * notice(s), this list of conditions and the following disclaimer in the @@ -26,7 +26,6 @@ * DAMAGE. * * $FreeBSD: src/lib/libpthread/thread/thr_barrierattr.c,v 1.1 2003/09/04 14:06:43 davidxu Exp $ - * $DragonFly: src/lib/libthread_xu/thread/thr_barrierattr.c,v 1.3 2006/04/06 13:03:09 davidxu Exp $ */ #include "namespace.h" @@ -50,7 +49,7 @@ _pthread_barrierattr_destroy(pthread_barrierattr_t *attr) int _pthread_barrierattr_getpshared(const pthread_barrierattr_t *attr, - int *pshared) + int *pshared) { if (attr == NULL || *attr == NULL) @@ -95,4 +94,3 @@ __strong_reference(_pthread_barrierattr_setpshared, pthread_barrierattr_setpshared); __strong_reference(_pthread_barrierattr_getpshared, pthread_barrierattr_getpshared); - diff --git a/lib/libthread_xu/thread/thr_cancel.c b/lib/libthread_xu/thread/thr_cancel.c index ad57138ea7..074b77c51f 100644 --- a/lib/libthread_xu/thread/thr_cancel.c +++ b/lib/libthread_xu/thread/thr_cancel.c @@ -23,7 +23,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_cancel.c,v 1.4 2006/04/06 13:03:09 davidxu Exp $ */ #include "namespace.h" @@ -163,4 +162,3 @@ __strong_reference(_pthread_cancel, pthread_cancel); __strong_reference(_pthread_setcancelstate, pthread_setcancelstate); __strong_reference(_pthread_setcanceltype, pthread_setcanceltype); __strong_reference(_pthread_testcancel, pthread_testcancel); - diff --git a/lib/libthread_xu/thread/thr_clean.c b/lib/libthread_xu/thread/thr_clean.c index a58c25a76c..3e5b70ca44 100644 --- a/lib/libthread_xu/thread/thr_clean.c +++ b/lib/libthread_xu/thread/thr_clean.c @@ -27,12 +27,10 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libpthread/thread/thr_clean.c,v 1.9 2004/12/18 18:07:37 deischen Exp $ - * $DragonFly: src/lib/libthread_xu/thread/thr_clean.c,v 1.4 2006/04/06 13:03:09 davidxu Exp $ */ #include "namespace.h" #include - #include #include #include @@ -75,4 +73,3 @@ _pthread_cleanup_pop(int execute) __strong_reference(_pthread_cleanup_push, pthread_cleanup_push); __strong_reference(_pthread_cleanup_pop, pthread_cleanup_pop); - diff --git a/lib/libthread_xu/thread/thr_concurrency.c b/lib/libthread_xu/thread/thr_concurrency.c index d9baf279fd..ae36ebc46c 100644 --- a/lib/libthread_xu/thread/thr_concurrency.c +++ b/lib/libthread_xu/thread/thr_concurrency.c @@ -25,7 +25,6 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libpthread/thread/thr_concurrency.c,v 1.8 2004/03/14 05:24:27 bde Exp $ - * $DragonFly: src/lib/libthread_xu/thread/thr_concurrency.c,v 1.4 2006/04/06 13:03:09 davidxu Exp $ */ #include "namespace.h" diff --git a/lib/libthread_xu/thread/thr_cond.c b/lib/libthread_xu/thread/thr_cond.c index da403c4cf1..109539a8a9 100644 --- a/lib/libthread_xu/thread/thr_cond.c +++ b/lib/libthread_xu/thread/thr_cond.c @@ -23,12 +23,10 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_cond.c,v 1.12 2008/04/15 01:45:22 dillon Exp $ */ #include "namespace.h" #include - #include #include #include @@ -39,22 +37,22 @@ umtx_t _cond_static_lock; -int __pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex); -int __pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, - const struct timespec *abstime); /* * Prototypes */ +int __pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex); +int __pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, + const struct timespec *abstime); static int cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr); static int cond_wait_common(pthread_cond_t *cond, pthread_mutex_t *mutex, - const struct timespec *abstime, int cancel); + const struct timespec *abstime, int cancel); static int cond_signal_common(pthread_cond_t *cond, int broadcast); static int cond_init(pthread_cond_t *cond, const pthread_condattr_t *cond_attr) { - pthread_cond_t pcond; - int rval = 0; + pthread_cond_t pcond; + int rval = 0; if ((pcond = (pthread_cond_t) malloc(sizeof(struct pthread_cond))) == NULL) { @@ -151,7 +149,7 @@ struct cond_cancel_info pthread_mutex_t *mutex; pthread_cond_t *cond; int seqno; - int count; + int count; }; static void @@ -267,7 +265,7 @@ __pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) } int -_pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, +_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec * abstime) { if (abstime == NULL || abstime->tv_sec < 0 || abstime->tv_nsec < 0 || @@ -347,4 +345,3 @@ __strong_reference(_pthread_cond_init, pthread_cond_init); __strong_reference(_pthread_cond_destroy, pthread_cond_destroy); __strong_reference(_pthread_cond_signal, pthread_cond_signal); __strong_reference(_pthread_cond_broadcast, pthread_cond_broadcast); - diff --git a/lib/libthread_xu/thread/thr_condattr.c b/lib/libthread_xu/thread/thr_condattr.c index e50750e5b7..2b9b31050f 100644 --- a/lib/libthread_xu/thread/thr_condattr.c +++ b/lib/libthread_xu/thread/thr_condattr.c @@ -92,8 +92,9 @@ _pthread_condattr_setclock(pthread_condattr_t *attr, if (attr == NULL || *attr == NULL) return (EINVAL); if (clock_id != CLOCK_REALTIME && - clock_id != CLOCK_MONOTONIC) + clock_id != CLOCK_MONOTONIC) { return (EINVAL); + } (*attr)->c_clockid = clock_id; return (0); } @@ -104,7 +105,6 @@ _pthread_condattr_getpshared(const pthread_condattr_t *attr, { if (attr == NULL || *attr == NULL) return (EINVAL); - *pshared = PTHREAD_PROCESS_PRIVATE; return (0); } @@ -126,4 +126,3 @@ __strong_reference(_pthread_condattr_getclock, pthread_condattr_getclock); __strong_reference(_pthread_condattr_setclock, pthread_condattr_setclock); __strong_reference(_pthread_condattr_getpshared, pthread_condattr_getpshared); __strong_reference(_pthread_condattr_setpshared, pthread_condattr_setpshared); - diff --git a/lib/libthread_xu/thread/thr_create.c b/lib/libthread_xu/thread/thr_create.c index bb4d558e3c..094820ec0c 100644 --- a/lib/libthread_xu/thread/thr_create.c +++ b/lib/libthread_xu/thread/thr_create.c @@ -36,7 +36,6 @@ #include #include #include - #include #include #include "un-namespace.h" @@ -49,7 +48,7 @@ static void thread_start(void *); int _pthread_create(pthread_t * thread, const pthread_attr_t * attr, - void *(*start_routine) (void *), void *arg) + void *(*start_routine) (void *), void *arg) { struct lwp_params create_params; void *stack; @@ -154,7 +153,7 @@ _pthread_create(pthread_t * thread, const pthread_attr_t * attr, locked = 0; /* Schedule the new thread. */ stack = (char *)new_thread->attr.stackaddr_attr + - new_thread->attr.stacksize_attr; + new_thread->attr.stacksize_attr; bzero(&create_params, sizeof(create_params)); create_params.lwp_func = thread_start; create_params.lwp_arg = new_thread; diff --git a/lib/libthread_xu/thread/thr_equal.c b/lib/libthread_xu/thread/thr_equal.c index b14efd9a02..ffa2695043 100644 --- a/lib/libthread_xu/thread/thr_equal.c +++ b/lib/libthread_xu/thread/thr_equal.c @@ -26,13 +26,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_equal.c,v 1.3 2006/04/06 13:03:09 davidxu Exp $ */ #include "namespace.h" #include #include "un-namespace.h" - #include "thr_private.h" int diff --git a/lib/libthread_xu/thread/thr_event.c b/lib/libthread_xu/thread/thr_event.c index 1ba24ac5f3..74cb687895 100644 --- a/lib/libthread_xu/thread/thr_event.c +++ b/lib/libthread_xu/thread/thr_event.c @@ -23,7 +23,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_event.c,v 1.2 2006/04/05 12:12:23 davidxu Exp $ */ #include "thr_private.h" diff --git a/lib/libthread_xu/thread/thr_exit.c b/lib/libthread_xu/thread/thr_exit.c index cafe637d52..b59d69b774 100644 --- a/lib/libthread_xu/thread/thr_exit.c +++ b/lib/libthread_xu/thread/thr_exit.c @@ -27,12 +27,10 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libpthread/thread/thr_exit.c,v 1.39 2004/10/23 23:37:54 davidxu Exp $ - * $DragonFly: src/lib/libthread_xu/thread/thr_exit.c,v 1.9 2007/03/13 00:19:29 corecode Exp $ */ #include "namespace.h" #include - #include #include #include @@ -98,7 +96,7 @@ _pthread_exit(void *status) /* Flag this thread as exiting. */ atomic_set_int(&curthread->cancelflags, THR_CANCEL_EXITING); - + _thr_exit_cleanup(); /* Save the return value: */ diff --git a/lib/libthread_xu/thread/thr_fork.c b/lib/libthread_xu/thread/thr_fork.c index b1d2a007ae..161e8635d2 100644 --- a/lib/libthread_xu/thread/thr_fork.c +++ b/lib/libthread_xu/thread/thr_fork.c @@ -61,7 +61,6 @@ #include #include - #include #include #include @@ -210,7 +209,7 @@ _fork(void) /* reinitalize library. */ _libpthread_init(curthread); - /* Ready to continue, unblock signals. */ + /* Ready to continue, unblock signals. */ _thr_signal_unblock(curthread); /* Run down atfork child handlers. */ @@ -227,7 +226,7 @@ _fork(void) _spinunlock(__malloc_lock); #endif - /* Ready to continue, unblock signals. */ + /* Ready to continue, unblock signals. */ _thr_signal_unblock(curthread); /* Run down atfork parent handlers. */ @@ -250,4 +249,3 @@ _fork(void) __strong_reference(_fork, fork); __strong_reference(_pthread_atfork, pthread_atfork); - diff --git a/lib/libthread_xu/thread/thr_getprio.c b/lib/libthread_xu/thread/thr_getprio.c index 55e567b57b..7472e1cfb9 100644 --- a/lib/libthread_xu/thread/thr_getprio.c +++ b/lib/libthread_xu/thread/thr_getprio.c @@ -26,7 +26,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_getprio.c,v 1.3 2006/04/06 13:03:09 davidxu Exp $ */ #include "namespace.h" diff --git a/lib/libthread_xu/thread/thr_getschedparam.c b/lib/libthread_xu/thread/thr_getschedparam.c index 2e9aacda6d..8025565711 100644 --- a/lib/libthread_xu/thread/thr_getschedparam.c +++ b/lib/libthread_xu/thread/thr_getschedparam.c @@ -29,12 +29,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_getschedparam.c,v 1.5 2007/05/03 23:08:34 dillon Exp $ */ #include "namespace.h" #include - #include #include #include "un-namespace.h" @@ -42,7 +40,7 @@ #include "thr_private.h" int -_pthread_getschedparam(pthread_t pthread, int *policy, +_pthread_getschedparam(pthread_t pthread, int *policy, struct sched_param *param) { struct pthread *curthread = tls_get_curthread(); diff --git a/lib/libthread_xu/thread/thr_info.c b/lib/libthread_xu/thread/thr_info.c index 112ad751bf..0be54c7a10 100644 --- a/lib/libthread_xu/thread/thr_info.c +++ b/lib/libthread_xu/thread/thr_info.c @@ -27,7 +27,6 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libthr/thread/thr_info.c,v 1.10 2007/04/05 07:20:31 davidxu Exp $ - * $DragonFly: src/lib/libthread_xu/thread/thr_info.c,v 1.6 2008/01/19 14:05:29 corecode Exp $ */ #include "namespace.h" diff --git a/lib/libthread_xu/thread/thr_init.c b/lib/libthread_xu/thread/thr_init.c index 96dbc8442c..20567238d1 100644 --- a/lib/libthread_xu/thread/thr_init.c +++ b/lib/libthread_xu/thread/thr_init.c @@ -34,13 +34,11 @@ #include "namespace.h" #include #include - #include #include #include #include #include - #include #include #include @@ -363,7 +361,7 @@ init_private(void) _thr_page_size = getpagesize(); _thr_guard_default = _thr_page_size; _pthread_attr_default.guardsize_attr = _thr_guard_default; - + TAILQ_INIT(&_thr_atfork_list); #ifdef SYSTEM_SCOPE_ONLY _thread_scope_system = 1; diff --git a/lib/libthread_xu/thread/thr_join.c b/lib/libthread_xu/thread/thr_join.c index 6dbde16d03..5464b576b8 100644 --- a/lib/libthread_xu/thread/thr_join.c +++ b/lib/libthread_xu/thread/thr_join.c @@ -73,7 +73,7 @@ join_common(pthread_t pthread, void **thread_return, long state; int oldcancel; int ret = 0; - + if (pthread == NULL) return (EINVAL); @@ -142,4 +142,3 @@ join_common(pthread_t pthread, void **thread_return, __strong_reference(_pthread_join, pthread_join); __strong_reference(_pthread_timedjoin_np, pthread_timedjoin_np); - diff --git a/lib/libthread_xu/thread/thr_kern.c b/lib/libthread_xu/thread/thr_kern.c index efaf1824b9..28f48ecbd5 100644 --- a/lib/libthread_xu/thread/thr_kern.c +++ b/lib/libthread_xu/thread/thr_kern.c @@ -62,7 +62,7 @@ void _thr_signal_block(struct pthread *curthread) { sigset_t set; - + if (curthread->sigblock > 0) { curthread->sigblock++; return; @@ -119,8 +119,8 @@ _thr_set_sched_other_prio(struct pthread *pth __unused, int prio) * case 0: need initialization * case 1: initialization successful * case 2: initialization failed. can't happen, but if - * it does, accept all and hope for the best. - * It's not like we use it anyway. + * it does, accept all and hope for the best. + * It's not like we use it anyway. */ if (!init_status) { int tmp = errno; diff --git a/lib/libthread_xu/thread/thr_kill.c b/lib/libthread_xu/thread/thr_kill.c index 2c6caa5059..3ea76acb7c 100644 --- a/lib/libthread_xu/thread/thr_kill.c +++ b/lib/libthread_xu/thread/thr_kill.c @@ -26,12 +26,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_kill.c,v 1.4 2006/04/06 13:03:09 davidxu Exp $ */ #include "namespace.h" #include - #include #include #include diff --git a/lib/libthread_xu/thread/thr_list.c b/lib/libthread_xu/thread/thr_list.c index 17558d5202..849817d6f5 100644 --- a/lib/libthread_xu/thread/thr_list.c +++ b/lib/libthread_xu/thread/thr_list.c @@ -343,14 +343,13 @@ _thr_find_thread(struct pthread *curthread __unused, struct pthread *thread, struct pthread *pthread; if (thread == NULL) - /* Invalid thread: */ return (EINVAL); pthread = _thr_hash_find(thread); if (pthread) { if (include_dead == 0 && pthread->state == PS_DEAD) { pthread = NULL; - } + } } /* Return zero if the thread exists: */ diff --git a/lib/libthread_xu/thread/thr_main_np.c b/lib/libthread_xu/thread/thr_main_np.c index 84749f08eb..172fa1b332 100644 --- a/lib/libthread_xu/thread/thr_main_np.c +++ b/lib/libthread_xu/thread/thr_main_np.c @@ -25,7 +25,6 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libpthread/thread/thr_main_np.c,v 1.5 2003/04/18 05:04:16 deischen Exp $ - * $DragonFly: src/lib/libthread_xu/thread/thr_main_np.c,v 1.4 2008/09/30 16:57:06 swildner Exp $ */ #include "namespace.h" @@ -36,7 +35,7 @@ #include "thr_private.h" /* - * Provide the equivelant to Solaris thr_main() function + * Provide the equivalent to Solaris thr_main() function. */ int _pthread_main_np(void) diff --git a/lib/libthread_xu/thread/thr_multi_np.c b/lib/libthread_xu/thread/thr_multi_np.c index c05d6c73b5..e3cb7faff4 100644 --- a/lib/libthread_xu/thread/thr_multi_np.c +++ b/lib/libthread_xu/thread/thr_multi_np.c @@ -26,7 +26,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_multi_np.c,v 1.4 2008/09/30 16:57:06 swildner Exp $ */ #include "namespace.h" diff --git a/lib/libthread_xu/thread/thr_mutex.c b/lib/libthread_xu/thread/thr_mutex.c index 973fb40682..5a36649fdd 100644 --- a/lib/libthread_xu/thread/thr_mutex.c +++ b/lib/libthread_xu/thread/thr_mutex.c @@ -34,7 +34,6 @@ #include "namespace.h" #include - #include #include #include @@ -45,7 +44,7 @@ #include "thr_private.h" #if defined(_PTHREADS_INVARIANTS) -#define MUTEX_INIT_LINK(m) do { \ +#define MUTEX_INIT_LINK(m) do { \ (m)->m_qe.tqe_prev = NULL; \ (m)->m_qe.tqe_next = NULL; \ } while (0) @@ -475,7 +474,7 @@ mutex_self_trylock(pthread_mutex_t m) /* case PTHREAD_MUTEX_DEFAULT: */ case PTHREAD_MUTEX_ERRORCHECK: case PTHREAD_MUTEX_NORMAL: - ret = EBUSY; + ret = EBUSY; break; case PTHREAD_MUTEX_RECURSIVE: @@ -514,7 +513,7 @@ mutex_self_lock(pthread_mutex_t m, const struct timespec *abstime) * POSIX specifies that mutexes should return * EDEADLK if a recursive lock is detected. */ - ret = EDEADLK; + ret = EDEADLK; } break; diff --git a/lib/libthread_xu/thread/thr_mutex_prioceiling.c b/lib/libthread_xu/thread/thr_mutex_prioceiling.c index 04268b647f..86b389e065 100644 --- a/lib/libthread_xu/thread/thr_mutex_prioceiling.c +++ b/lib/libthread_xu/thread/thr_mutex_prioceiling.c @@ -29,7 +29,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_mutex_prioceiling.c,v 1.3 2006/04/06 13:03:09 davidxu Exp $ */ #include "namespace.h" @@ -109,4 +108,3 @@ __strong_reference(_pthread_mutexattr_getprioceiling, pthread_mutexattr_getprioc __strong_reference(_pthread_mutexattr_setprioceiling, pthread_mutexattr_setprioceiling); __strong_reference(_pthread_mutex_getprioceiling, pthread_mutex_getprioceiling); __strong_reference(_pthread_mutex_setprioceiling, pthread_mutex_setprioceiling); - diff --git a/lib/libthread_xu/thread/thr_mutex_protocol.c b/lib/libthread_xu/thread/thr_mutex_protocol.c index 7bb0a6f79d..92774d481b 100644 --- a/lib/libthread_xu/thread/thr_mutex_protocol.c +++ b/lib/libthread_xu/thread/thr_mutex_protocol.c @@ -29,7 +29,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_mutex_protocol.c,v 1.4 2008/07/15 01:18:53 dillon Exp $ */ #include "namespace.h" @@ -69,4 +68,3 @@ _pthread_mutexattr_setprotocol(pthread_mutexattr_t *mattr, int protocol) __strong_reference(_pthread_mutexattr_getprotocol, pthread_mutexattr_getprotocol); __strong_reference(_pthread_mutexattr_setprotocol, pthread_mutexattr_setprotocol); - diff --git a/lib/libthread_xu/thread/thr_mutexattr.c b/lib/libthread_xu/thread/thr_mutexattr.c index 2330d3d860..6b19210f68 100644 --- a/lib/libthread_xu/thread/thr_mutexattr.c +++ b/lib/libthread_xu/thread/thr_mutexattr.c @@ -83,19 +83,21 @@ int _pthread_mutexattr_getkind_np(pthread_mutexattr_t attr) { int ret; + if (attr == NULL) { errno = EINVAL; ret = -1; } else { ret = attr->m_type; } - return(ret); + return (ret); } int _pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) { int ret; + if (attr == NULL || *attr == NULL || type >= PTHREAD_MUTEX_TYPE_MAX) { errno = EINVAL; ret = -1; @@ -103,7 +105,7 @@ _pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) (*attr)->m_type = type; ret = 0; } - return(ret); + return (ret); } int @@ -118,7 +120,7 @@ _pthread_mutexattr_gettype(pthread_mutexattr_t *attr, int *type) *type = (*attr)->m_type; ret = 0; } - return ret; + return (ret); } int @@ -132,7 +134,7 @@ _pthread_mutexattr_destroy(pthread_mutexattr_t *attr) *attr = NULL; ret = 0; } - return(ret); + return (ret); } int @@ -142,7 +144,6 @@ _pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr, if (attr == NULL || *attr == NULL) return (EINVAL); - *pshared = PTHREAD_PROCESS_PRIVATE; return (0); } diff --git a/lib/libthread_xu/thread/thr_once.c b/lib/libthread_xu/thread/thr_once.c index 2b4dfd7897..ef172f3f0a 100644 --- a/lib/libthread_xu/thread/thr_once.c +++ b/lib/libthread_xu/thread/thr_once.c @@ -32,8 +32,8 @@ #define ONCE_NEVER_DONE PTHREAD_NEEDS_INIT #define ONCE_DONE PTHREAD_DONE_INIT -#define ONCE_IN_PROGRESS 0x02 -#define ONCE_MASK 0x03 +#define ONCE_IN_PROGRESS 0x02 +#define ONCE_MASK 0x03 static pthread_mutex_t once_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t once_cv = PTHREAD_COND_INITIALIZER; @@ -44,7 +44,7 @@ static pthread_cond_t once_cv = PTHREAD_COND_INITIALIZER; * if init_routine is a cancellation point and is canceled, the effect * on once_control shall be as if pthread_once() was never called. */ - + static void once_cancel_handler(void *arg) { diff --git a/lib/libthread_xu/thread/thr_printf.c b/lib/libthread_xu/thread/thr_printf.c index c9cbf4c7bf..ed1e148bca 100644 --- a/lib/libthread_xu/thread/thr_printf.c +++ b/lib/libthread_xu/thread/thr_printf.c @@ -107,7 +107,7 @@ next: c = *fmt++; } pchar(fd, c); } -out: +out: va_end(ap); } diff --git a/lib/libthread_xu/thread/thr_private.h b/lib/libthread_xu/thread/thr_private.h index 151f363237..420096e802 100644 --- a/lib/libthread_xu/thread/thr_private.h +++ b/lib/libthread_xu/thread/thr_private.h @@ -79,7 +79,7 @@ #endif #ifdef PIC -#define STATIC_LIB_REQUIRE(name) +#define STATIC_LIB_REQUIRE(name) #else #define STATIC_LIB_REQUIRE(name) __asm(".globl " #name) #endif @@ -88,7 +88,7 @@ TAILQ_HEAD(thread_head, pthread) thread_head; TAILQ_HEAD(atfork_head, pthread_atfork) atfork_head; #define TIMESPEC_ADD(dst, src, val) \ - do { \ + do { \ (dst)->tv_sec = (src)->tv_sec + (val)->tv_sec; \ (dst)->tv_nsec = (src)->tv_nsec + (val)->tv_nsec; \ if ((dst)->tv_nsec >= 1000000000) { \ @@ -98,7 +98,7 @@ TAILQ_HEAD(atfork_head, pthread_atfork) atfork_head; } while (0) #define TIMESPEC_SUB(dst, src, val) \ - do { \ + do { \ (dst)->tv_sec = (src)->tv_sec - (val)->tv_sec; \ (dst)->tv_nsec = (src)->tv_nsec - (val)->tv_nsec; \ if ((dst)->tv_nsec < 0) { \ @@ -124,12 +124,12 @@ struct pthread_mutex { * Used for priority inheritence and protection. * * m_prio - For priority inheritence, the highest active - * priority (threads locking the mutex inherit - * this priority). For priority protection, the - * ceiling priority of this mutex. + * priority (threads locking the mutex inherit + * this priority). For priority protection, the + * ceiling priority of this mutex. * m_saved_prio - mutex owners inherited priority before - * taking the mutex, restored when the owner - * unlocks the mutex. + * taking the mutex, restored when the owner + * unlocks the mutex. */ int m_prio; int m_saved_prio; @@ -146,7 +146,7 @@ struct pthread_mutex { {0, PTHREAD_MUTEX_DEFAULT, PTHREAD_PRIO_NONE, TAILQ_INITIALIZER, \ NULL, { NULL }, MUTEX_FLAGS_PRIVATE, 0, 0, 0, TAILQ_INITIALIZER } /* - * Flags for mutexes. + * Flags for mutexes. */ #define MUTEX_FLAGS_PRIVATE 0x01 #define MUTEX_FLAGS_INITED 0x02 @@ -312,7 +312,7 @@ struct pthread_key { volatile int allocated; volatile int count; int seqno; - void (*destructor)(void *); + void (*destructor)(void *); }; /* @@ -374,8 +374,8 @@ struct pthread { void *arg; struct pthread_attr attr; - /* - * Cancelability flags + /* + * Cancelability flags */ #define THR_CANCEL_DISABLE 0x0001 #define THR_CANCEL_EXITING 0x0002 @@ -474,14 +474,14 @@ struct pthread { struct tls_tcb *tcb; /* Cleanup handlers Link List */ - struct pthread_cleanup *cleanup; + struct pthread_cleanup *cleanup; /* Enable event reporting */ int report_events; - + /* Event mask */ td_thr_events_t event_mask; - + /* Event */ td_event_msg_t event_buf; }; @@ -579,7 +579,7 @@ do { \ #define THR_IN_SYNCQ(thrd) (((thrd)->sflags & THR_FLAGS_IN_SYNCQ) != 0) #define SHOULD_REPORT_EVENT(curthr, e) \ - (curthr->report_events && \ + (curthr->report_events && \ (((curthr)->event_mask | _thread_event_mask ) & e) != 0) extern int __isthreaded; @@ -656,8 +656,8 @@ void _thr_stack_free(struct pthread_attr *); void _thr_stack_cleanup(void); void _thr_free(struct pthread *, struct pthread *); void _thr_gc(struct pthread *); -void _thread_cleanupspecific(void); -void _thread_dump_info(void); +void _thread_cleanupspecific(void); +void _thread_dump_info(void); void _thread_printf(int, const char *, ...); void _thr_spinlock_init(void); int _thr_cancel_enter(struct pthread *); @@ -689,8 +689,8 @@ int _rtp_to_schedparam(const struct rtprio *rtp, int *policy, struct sched_param *param); int _schedparam_to_rtp(int policy, const struct sched_param *param, struct rtprio *rtp); -int _umtx_sleep_err(volatile const int *, int, int); -int _umtx_wakeup_err(volatile const int *, int); +int _umtx_sleep_err(volatile const int *, int, int); +int _umtx_wakeup_err(volatile const int *, int); /* #include */ #ifdef _SYS_AIO_H_ @@ -751,11 +751,11 @@ int __sys_nanosleep(const struct timespec *, struct timespec *); /* #include */ #ifdef _UNISTD_H_ -int __sys_close(int); -int __sys_execve(const char *, char * const *, char * const *); +int __sys_close(int); +int __sys_execve(const char *, char * const *, char * const *); int __sys_fsync(int); pid_t __sys_getpid(void); -int __sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); +int __sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); ssize_t __sys_read(int, void *, size_t); ssize_t __sys_write(int, const void *, size_t); void __sys_exit(int); @@ -767,8 +767,8 @@ int __sys_sigwaitinfo(const sigset_t *set, siginfo_t *info); /* #include */ #ifdef _SYS_POLL_H_ -int __sys_poll(struct pollfd *, unsigned, int); -int __sys_ppoll(struct pollfd *, unsigned, const struct timespec *, +int __sys_poll(struct pollfd *, unsigned, int); +int __sys_ppoll(struct pollfd *, unsigned, const struct timespec *, const sigset_t *); #endif @@ -793,7 +793,7 @@ static inline void _thr_check_init(void) { if (_thr_initial == NULL) - _libpthread_init(0); + _libpthread_init(NULL); } struct dl_phdr_info; diff --git a/lib/libthread_xu/thread/thr_pspinlock.c b/lib/libthread_xu/thread/thr_pspinlock.c index 35aa3ac6b0..827220288d 100644 --- a/lib/libthread_xu/thread/thr_pspinlock.c +++ b/lib/libthread_xu/thread/thr_pspinlock.c @@ -23,12 +23,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_pspinlock.c,v 1.4 2006/04/06 13:03:09 davidxu Exp $ */ #include "namespace.h" #include - #include #include #include @@ -45,11 +43,11 @@ _pthread_spin_init(pthread_spinlock_t *lock, int pshared) struct pthread_spinlock *lck; int ret; - if (lock == NULL || pshared != PTHREAD_PROCESS_PRIVATE) + if (lock == NULL || pshared != PTHREAD_PROCESS_PRIVATE) { ret = EINVAL; - else if ((lck = malloc(sizeof(struct pthread_spinlock))) == NULL) + } else if ((lck = malloc(sizeof(struct pthread_spinlock))) == NULL) { ret = ENOMEM; - else { + } else { _thr_umtx_init(&lck->s_lock); *lock = lck; ret = 0; @@ -63,14 +61,13 @@ _pthread_spin_destroy(pthread_spinlock_t *lock) { int ret; - if (lock == NULL || *lock == NULL) + if (lock == NULL || *lock == NULL) { ret = EINVAL; - else { + } else { free(*lock); *lock = NULL; ret = 0; } - return (ret); } @@ -95,9 +92,9 @@ _pthread_spin_lock(pthread_spinlock_t *lock) struct pthread_spinlock *lck; int ret, count; - if (lock == NULL || (lck = *lock) == NULL) + if (lock == NULL || (lck = *lock) == NULL) { ret = EINVAL; - else { + } else { count = SPIN_COUNT; while ((ret = THR_UMTX_TRYLOCK(curthread, &lck->s_lock)) != 0) { while (lck->s_lock) { @@ -124,9 +121,9 @@ _pthread_spin_unlock(pthread_spinlock_t *lock) struct pthread_spinlock *lck; int ret; - if (lock == NULL || (lck = *lock) == NULL) + if (lock == NULL || (lck = *lock) == NULL) { ret = EINVAL; - else { + } else { THR_UMTX_UNLOCK(curthread, &lck->s_lock); ret = 0; } @@ -138,4 +135,3 @@ __strong_reference(_pthread_spin_destroy, pthread_spin_destroy); __strong_reference(_pthread_spin_trylock, pthread_spin_trylock); __strong_reference(_pthread_spin_lock, pthread_spin_lock); __strong_reference(_pthread_spin_unlock, pthread_spin_unlock); - diff --git a/lib/libthread_xu/thread/thr_resume_np.c b/lib/libthread_xu/thread/thr_resume_np.c index 0e253c1635..a3fa19b42d 100644 --- a/lib/libthread_xu/thread/thr_resume_np.c +++ b/lib/libthread_xu/thread/thr_resume_np.c @@ -26,12 +26,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_resume_np.c,v 1.5 2006/04/06 13:03:09 davidxu Exp $ */ #include "namespace.h" #include - #include #include #include @@ -90,4 +88,3 @@ resume_common(struct pthread *thread) __strong_reference(_pthread_resume_np, pthread_resume_np); __strong_reference(_pthread_resume_all_np, pthread_resume_all_np); - diff --git a/lib/libthread_xu/thread/thr_rtld.c b/lib/libthread_xu/thread/thr_rtld.c index a84527557b..3cbec69655 100644 --- a/lib/libthread_xu/thread/thr_rtld.c +++ b/lib/libthread_xu/thread/thr_rtld.c @@ -24,10 +24,9 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/lib/libpthread/thread/thr_rtld.c,v 1.5 2003/11/05 18:19:24 deischen Exp $ - * $DragonFly: src/lib/libthread_xu/thread/thr_rtld.c,v 1.2 2005/03/29 19:26:20 joerg Exp $ */ -#include +#include #include #include diff --git a/lib/libthread_xu/thread/thr_rwlock.c b/lib/libthread_xu/thread/thr_rwlock.c index 6761ef735a..8bb7c9d06c 100644 --- a/lib/libthread_xu/thread/thr_rwlock.c +++ b/lib/libthread_xu/thread/thr_rwlock.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libpthread/thread/thr_rwlock.c,v 1.14 2004/01/08 15:37:09 deischen Exp $ - * $DragonFly: src/lib/libthread_xu/thread/thr_rwlock.c,v 1.7 2006/04/06 13:03:09 davidxu Exp $ */ #include "namespace.h" @@ -35,7 +34,6 @@ #include #include #include "un-namespace.h" - #include "thr_private.h" /* maximum number of times a read lock may be obtained */ @@ -129,14 +127,14 @@ init_static(struct pthread *thread, pthread_rwlock_t *rwlock) } int -_pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) +_pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) { *rwlock = NULL; return (rwlock_init(rwlock, attr)); } static int -rwlock_rdlock_common (pthread_rwlock_t *rwlock, const struct timespec *abstime) +rwlock_rdlock_common(pthread_rwlock_t *rwlock, const struct timespec *abstime) { struct pthread *curthread = tls_get_curthread(); pthread_rwlock_t prwlock; @@ -421,4 +419,3 @@ __strong_reference(_pthread_rwlock_trywrlock, pthread_rwlock_trywrlock); __strong_reference(_pthread_rwlock_unlock, pthread_rwlock_unlock); __strong_reference(_pthread_rwlock_wrlock, pthread_rwlock_wrlock); __strong_reference(_pthread_rwlock_timedwrlock, pthread_rwlock_timedwrlock); - diff --git a/lib/libthread_xu/thread/thr_rwlockattr.c b/lib/libthread_xu/thread/thr_rwlockattr.c index 0d0804e1f0..b672d7a362 100644 --- a/lib/libthread_xu/thread/thr_rwlockattr.c +++ b/lib/libthread_xu/thread/thr_rwlockattr.c @@ -24,13 +24,11 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libpthread/thread/thr_rwlockattr.c,v 1.8 2002/09/16 08:45:35 mini Exp $ - * $DragonFly: src/lib/libthread_xu/thread/thr_rwlockattr.c,v 1.3 2006/04/06 13:03:09 davidxu Exp $ */ #include "namespace.h" #include #include - #include #include "un-namespace.h" @@ -42,25 +40,20 @@ _pthread_rwlockattr_destroy(pthread_rwlockattr_t *rwlockattr) pthread_rwlockattr_t prwlockattr; if (rwlockattr == NULL) - return(EINVAL); - + return (EINVAL); prwlockattr = *rwlockattr; - if (prwlockattr == NULL) - return(EINVAL); - + return (EINVAL); free(prwlockattr); - - return(0); + return (0); } int _pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *rwlockattr, - int *pshared) + int *pshared) { *pshared = (*rwlockattr)->pshared; - - return(0); + return (0); } int @@ -69,18 +62,15 @@ _pthread_rwlockattr_init(pthread_rwlockattr_t *rwlockattr) pthread_rwlockattr_t prwlockattr; if (rwlockattr == NULL) - return(EINVAL); - - prwlockattr = (pthread_rwlockattr_t) - malloc(sizeof(struct pthread_rwlockattr)); + return (EINVAL); + prwlockattr = malloc(sizeof(struct pthread_rwlockattr)); if (prwlockattr == NULL) - return(ENOMEM); - - prwlockattr->pshared = PTHREAD_PROCESS_PRIVATE; - *rwlockattr = prwlockattr; + return (ENOMEM); - return(0); + prwlockattr->pshared = PTHREAD_PROCESS_PRIVATE; + *rwlockattr = prwlockattr; + return (0); } int @@ -89,14 +79,11 @@ _pthread_rwlockattr_setpshared(pthread_rwlockattr_t *rwlockattr, int pshared) /* Only PTHREAD_PROCESS_PRIVATE is supported. */ if (pshared != PTHREAD_PROCESS_PRIVATE) return(EINVAL); - (*rwlockattr)->pshared = pshared; - - return(0); + return (0); } __strong_reference(_pthread_rwlockattr_destroy, pthread_rwlockattr_destroy); __strong_reference(_pthread_rwlockattr_getpshared, pthread_rwlockattr_getpshared); __strong_reference(_pthread_rwlockattr_init, pthread_rwlockattr_init); __strong_reference(_pthread_rwlockattr_setpshared, pthread_rwlockattr_setpshared); - diff --git a/lib/libthread_xu/thread/thr_self.c b/lib/libthread_xu/thread/thr_self.c index 0d5e363dd4..0a10a9b151 100644 --- a/lib/libthread_xu/thread/thr_self.c +++ b/lib/libthread_xu/thread/thr_self.c @@ -26,7 +26,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_self.c,v 1.4 2006/04/06 13:03:09 davidxu Exp $ */ #include "namespace.h" diff --git a/lib/libthread_xu/thread/thr_sem.c b/lib/libthread_xu/thread/thr_sem.c index 27cf1c9a26..687166fb46 100644 --- a/lib/libthread_xu/thread/thr_sem.c +++ b/lib/libthread_xu/thread/thr_sem.c @@ -35,7 +35,6 @@ #include #include #include - #include #include #include @@ -46,6 +45,7 @@ #include #include #include "un-namespace.h" + #include "thr_private.h" #define container_of(ptr, type, member) \ @@ -341,7 +341,7 @@ get_path(const char *name, char *path, size_t len, char const **prefix) size_t path_len; *prefix = NULL; - + if (name[0] == '/') { *prefix = getenv("LIBTHREAD_SEM_PREFIX"); @@ -429,7 +429,7 @@ sem_close_mapping(sem_t *sem) } else { if (ni->inode != 0) { LIST_REMOVE(ni, next); - } + } munmap(ni->sem, getpagesize()); __sys_close(ni->fd); free(ni); @@ -487,7 +487,7 @@ retry: fd = __sys_open(path, O_RDWR | O_CLOEXEC); if (fd > 0) { - + if ((oflag & O_EXCL) == O_EXCL) { __sys_close(fd); errno = EEXIST; @@ -533,7 +533,7 @@ retry: if (path_len > sizeof(tmppath)) { errno = ENAMETOOLONG; - goto error; + goto error; } @@ -589,7 +589,7 @@ retry: if (create) unlink(tmppath); - __sys_close(fd); + __sys_close(fd); goto error; } @@ -691,4 +691,3 @@ __strong_reference(_sem_post, sem_post); __strong_reference(_sem_open, sem_open); __strong_reference(_sem_close, sem_close); __strong_reference(_sem_unlink, sem_unlink); - diff --git a/lib/libthread_xu/thread/thr_setprio.c b/lib/libthread_xu/thread/thr_setprio.c index 62a445f087..45d504a3d1 100644 --- a/lib/libthread_xu/thread/thr_setprio.c +++ b/lib/libthread_xu/thread/thr_setprio.c @@ -26,7 +26,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_setprio.c,v 1.3 2006/04/06 13:03:09 davidxu Exp $ */ #include "namespace.h" diff --git a/lib/libthread_xu/thread/thr_setschedparam.c b/lib/libthread_xu/thread/thr_setschedparam.c index 5cbae7d64e..485d8fe687 100644 --- a/lib/libthread_xu/thread/thr_setschedparam.c +++ b/lib/libthread_xu/thread/thr_setschedparam.c @@ -29,12 +29,10 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_setschedparam.c,v 1.7 2007/05/04 17:18:55 dillon Exp $ */ #include "namespace.h" #include - #include #include #include @@ -43,7 +41,7 @@ #include "thr_private.h" int -_pthread_setschedparam(pthread_t pthread, int policy, +_pthread_setschedparam(pthread_t pthread, int policy, const struct sched_param *param) { struct pthread *curthread = tls_get_curthread(); diff --git a/lib/libthread_xu/thread/thr_sig.c b/lib/libthread_xu/thread/thr_sig.c index 84f2c3d819..86ee4589ea 100644 --- a/lib/libthread_xu/thread/thr_sig.c +++ b/lib/libthread_xu/thread/thr_sig.c @@ -26,9 +26,7 @@ #include "namespace.h" #include - #include - #include #include #include @@ -261,4 +259,3 @@ __sigwait(const sigset_t *set, int *sig) } __strong_reference(__sigwait, sigwait); - diff --git a/lib/libthread_xu/thread/thr_single_np.c b/lib/libthread_xu/thread/thr_single_np.c index aa15b6ff5c..a829a316f5 100644 --- a/lib/libthread_xu/thread/thr_single_np.c +++ b/lib/libthread_xu/thread/thr_single_np.c @@ -26,7 +26,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_single_np.c,v 1.4 2008/09/30 16:57:06 swildner Exp $ */ #include "namespace.h" @@ -34,7 +33,8 @@ #include #include "un-namespace.h" -int _pthread_single_np(void) +int +_pthread_single_np(void) { /* Enter single-threaded (non-POSIX) scheduling mode: */ diff --git a/lib/libthread_xu/thread/thr_spec.c b/lib/libthread_xu/thread/thr_spec.c index d615b33303..a2efed43cb 100644 --- a/lib/libthread_xu/thread/thr_spec.c +++ b/lib/libthread_xu/thread/thr_spec.c @@ -26,7 +26,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_spec.c,v 1.5 2006/04/06 13:03:09 davidxu Exp $ */ #include "namespace.h" @@ -98,7 +97,7 @@ _pthread_key_delete(pthread_key_t key) return (ret); } -void +void _thread_cleanupspecific(void) { struct pthread *curthread = tls_get_curthread(); @@ -122,18 +121,17 @@ _thread_cleanupspecific(void) (curthread->specific[key].data != NULL)) { if (curthread->specific[key].seqno == _thread_keytable[key].seqno) { - data = - curthread->specific[key].data; + data = curthread->specific[key].data; destructor = _thread_keytable[key].destructor; } curthread->specific[key].data = NULL; curthread->specific_data_count--; } else if (curthread->specific[key].data != NULL) { - /* + /* * This can happen if the key is deleted via * pthread_key_delete without first setting the value - * to NULL in all threads. POSIX says that the - * destructor is not invoked in this case. + * to NULL in all threads. POSIX says that the + * destructor is not invoked in this case. */ curthread->specific[key].data = NULL; curthread->specific_data_count--; @@ -177,7 +175,7 @@ pthread_key_allocate_data(void) return (new_data); } -int +int _pthread_setspecific(pthread_key_t key, const void *value) { struct pthread *pthread; @@ -227,7 +225,7 @@ _pthread_getspecific(pthread_key_t key) } else { /* * This key has not been used before, so return NULL - * instead: + * instead. */ data = NULL; } @@ -241,4 +239,3 @@ __strong_reference(_pthread_key_create, pthread_key_create); __strong_reference(_pthread_key_delete, pthread_key_delete); __strong_reference(_pthread_getspecific, pthread_getspecific); __strong_reference(_pthread_setspecific, pthread_setspecific); - diff --git a/lib/libthread_xu/thread/thr_spinlock.c b/lib/libthread_xu/thread/thr_spinlock.c index e4d8217e7e..ba04795baf 100644 --- a/lib/libthread_xu/thread/thr_spinlock.c +++ b/lib/libthread_xu/thread/thr_spinlock.c @@ -26,7 +26,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_spinlock.c,v 1.3 2006/04/06 13:03:09 davidxu Exp $ */ #include "namespace.h" diff --git a/lib/libthread_xu/thread/thr_stack.c b/lib/libthread_xu/thread/thr_stack.c index dc277a0afb..069a1522e5 100644 --- a/lib/libthread_xu/thread/thr_stack.c +++ b/lib/libthread_xu/thread/thr_stack.c @@ -25,14 +25,11 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libpthread/thread/thr_stack.c,v 1.9 2004/10/06 08:11:07 davidxu Exp $ - * $DragonFly: src/lib/libthread_xu/thread/thr_stack.c,v 1.4 2006/04/06 13:03:09 davidxu Exp $ */ #include #include #include - #include - #include #include #include "thr_private.h" @@ -74,7 +71,7 @@ static LIST_HEAD(, stack) mstackq = LIST_HEAD_INITIALIZER(mstackq); * the next. * * low memory - * . . . . . . . . . . . . . . . . . . + * . . . . . . . . . . . . . . . . . . * | | * | stack 3 | start of 3rd thread stack * +-----------------------------------+ @@ -250,7 +247,7 @@ _thr_stack_free(struct pthread_attr *attr) if ((attr != NULL) && ((attr->flags & THR_STACK_USER) == 0) && (attr->stackaddr_attr != NULL)) { spare_stack = (struct stack *)((char *)attr->stackaddr_attr + - attr->stacksize_attr - sizeof(struct stack)); + attr->stacksize_attr - sizeof(struct stack)); spare_stack->stacksize = round_up(attr->stacksize_attr); spare_stack->guardsize = round_up(attr->guardsize_attr); spare_stack->stackaddr = attr->stackaddr_attr; diff --git a/lib/libthread_xu/thread/thr_suspend_np.c b/lib/libthread_xu/thread/thr_suspend_np.c index 50dea7717c..d490ecfeb5 100644 --- a/lib/libthread_xu/thread/thr_suspend_np.c +++ b/lib/libthread_xu/thread/thr_suspend_np.c @@ -26,7 +26,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_suspend_np.c,v 1.5 2006/04/06 13:03:09 davidxu Exp $ */ #include "namespace.h" @@ -79,7 +78,7 @@ _pthread_suspend_all_np(void) if (thread != curthread) { THR_THREAD_LOCK(curthread, thread); if (thread->state != PS_DEAD && - !(thread->flags & THR_FLAGS_SUSPENDED)) + !(thread->flags & THR_FLAGS_SUSPENDED)) thread->flags |= THR_FLAGS_NEED_SUSPEND; THR_THREAD_UNLOCK(curthread, thread); } @@ -140,4 +139,3 @@ suspend_common(struct pthread *curthread, struct pthread *thread, __strong_reference(_pthread_suspend_np, pthread_suspend_np); __strong_reference(_pthread_suspend_all_np, pthread_suspend_all_np); - diff --git a/lib/libthread_xu/thread/thr_switch_np.c b/lib/libthread_xu/thread/thr_switch_np.c index 20fb4afb76..5cd95b957e 100644 --- a/lib/libthread_xu/thread/thr_switch_np.c +++ b/lib/libthread_xu/thread/thr_switch_np.c @@ -29,7 +29,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_switch_np.c,v 1.3 2006/04/06 13:03:09 davidxu Exp $ */ #include "namespace.h" @@ -54,4 +53,3 @@ _pthread_switch_delete_np(pthread_switch_routine_t routine __unused) __strong_reference(_pthread_switch_add_np, pthread_switch_add_np); __strong_reference(_pthread_switch_delete_np, pthread_switch_delete_np); - diff --git a/lib/libthread_xu/thread/thr_symbols.c b/lib/libthread_xu/thread/thr_symbols.c index 2a62a0b9c4..bd2d4aae50 100644 --- a/lib/libthread_xu/thread/thr_symbols.c +++ b/lib/libthread_xu/thread/thr_symbols.c @@ -27,7 +27,6 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libpthread/thread/thr_symbols.c,v 1.1 2004/08/16 03:25:07 davidxu Exp $ - * $DragonFly: src/lib/libthread_xu/thread/thr_symbols.c,v 1.4 2006/04/05 12:12:23 davidxu Exp $ */ #include diff --git a/lib/libthread_xu/thread/thr_syscalls.c b/lib/libthread_xu/thread/thr_syscalls.c index 7e8d5785a5..67a3a93414 100644 --- a/lib/libthread_xu/thread/thr_syscalls.c +++ b/lib/libthread_xu/thread/thr_syscalls.c @@ -3,7 +3,7 @@ * Copyright (c) 2003 Daniel Eischen . * Copyright (C) 2000 Jason Evans . * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -15,7 +15,7 @@ * notice(s), this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR @@ -27,8 +27,6 @@ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $DragonFly: src/lib/libthread_xu/thread/thr_syscalls.c,v 1.8 2008/01/10 22:30:27 nth Exp $ */ /* @@ -173,7 +171,7 @@ __accept(int s, struct sockaddr *addr, socklen_t *addrlen) ret = __sys_accept(s, addr, addrlen); _thr_cancel_leave(curthread, oldcancel); - return (ret); + return (ret); } __strong_reference(__accept, accept); @@ -205,7 +203,7 @@ __close(int fd) oldcancel = _thr_cancel_enter(curthread); ret = __sys_close(fd); _thr_cancel_leave(curthread, oldcancel); - + return (ret); } @@ -222,7 +220,7 @@ __connect(int fd, const struct sockaddr *name, socklen_t namelen) ret = __sys_connect(fd, name, namelen); _thr_cancel_leave(curthread, oldcancel); - return (ret); + return (ret); } __strong_reference(__connect, connect); @@ -237,7 +235,7 @@ ___creat(const char *path, mode_t mode) oldcancel = _thr_cancel_enter(curthread); ret = __creat(path, mode); _thr_cancel_leave(curthread, oldcancel); - + return ret; } @@ -250,7 +248,7 @@ __fcntl(int fd, int cmd,...) int oldcancel; int ret; va_list ap; - + oldcancel = _thr_cancel_enter(curthread); va_start(ap, cmd); @@ -337,7 +335,7 @@ __open(const char *path, int flags,...) va_list ap; oldcancel = _thr_cancel_enter(curthread); - + /* Check if the file is being created: */ if (flags & O_CREAT) { /* Get the creation mode: */ @@ -345,7 +343,7 @@ __open(const char *path, int flags,...) mode = va_arg(ap, int); va_end(ap); } - + ret = __sys_open(path, flags, mode); _thr_cancel_leave(curthread, oldcancel); @@ -365,7 +363,7 @@ __openat(int fd, const char *path, int flags,...) va_list ap; oldcancel = _thr_cancel_enter(curthread); - + /* Check if the file is being created: */ if (flags & O_CREAT) { /* Get the creation mode: */ @@ -373,7 +371,7 @@ __openat(int fd, const char *path, int flags,...) mode = va_arg(ap, int); va_end(ap); } - + ret = __sys_openat(fd, path, flags, mode); _thr_cancel_leave(curthread, oldcancel); @@ -393,7 +391,7 @@ _pause(void) oldcancel = _thr_cancel_enter(curthread); ret = __pause(); _thr_cancel_leave(curthread, oldcancel); - + return ret; } @@ -432,7 +430,7 @@ __ppoll(struct pollfd *fds, unsigned int nfds, const struct timespec *ts, __strong_reference(__ppoll, ppoll); -int +int __pselect(int count, fd_set *rfds, fd_set *wfds, fd_set *efds, const struct timespec *timo, const sigset_t *mask) { @@ -473,7 +471,6 @@ __read(int fd, void *buf, size_t nbytes) oldcancel = _thr_cancel_enter(curthread); ret = __sys_read(fd, buf, nbytes); _thr_cancel_leave(curthread, oldcancel); - return ret; } @@ -489,7 +486,6 @@ __readv(int fd, const struct iovec *iov, int iovcnt) oldcancel = _thr_cancel_enter(curthread); ret = __sys_readv(fd, iov, iovcnt); _thr_cancel_leave(curthread, oldcancel); - return ret; } @@ -526,7 +522,7 @@ __recvmsg(int s, struct msghdr *m, int f) __strong_reference(__recvmsg, recvmsg); -int +int __select(int numfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) { @@ -583,7 +579,6 @@ _sleep(unsigned int seconds) oldcancel = _thr_cancel_enter(curthread); ret = __sleep(seconds); _thr_cancel_leave(curthread, oldcancel); - return (ret); } @@ -597,7 +592,6 @@ _system(const char *string) oldcancel = _thr_cancel_enter(curthread); ret = __system(string); _thr_cancel_leave(curthread, oldcancel); - return ret; } @@ -609,11 +603,10 @@ _tcdrain(int fd) struct pthread *curthread = tls_get_curthread(); int oldcancel; int ret; - + oldcancel = _thr_cancel_enter(curthread); ret = __tcdrain(fd); _thr_cancel_leave(curthread, oldcancel); - return (ret); } @@ -629,7 +622,6 @@ ___usleep(unsigned int useconds) oldcancel = _thr_cancel_enter(curthread); ret = __usleep(useconds); _thr_cancel_leave(curthread, oldcancel); - return (ret); } @@ -659,7 +651,6 @@ _wait(int *istat) oldcancel = _thr_cancel_enter(curthread); ret = __wait(istat); _thr_cancel_leave(curthread, oldcancel); - return ret; } @@ -675,7 +666,6 @@ __wait4(pid_t pid, int *istat, int options, struct rusage *rusage) oldcancel = _thr_cancel_enter(curthread); ret = __sys_wait4(pid, istat, options, rusage); _thr_cancel_leave(curthread, oldcancel); - return ret; } @@ -691,7 +681,6 @@ _waitpid(pid_t wpid, int *status, int options) oldcancel = _thr_cancel_enter(curthread); ret = __waitpid(wpid, status, options); _thr_cancel_leave(curthread, oldcancel); - return ret; } @@ -707,7 +696,6 @@ __write(int fd, const void *buf, size_t nbytes) oldcancel = _thr_cancel_enter(curthread); ret = __sys_write(fd, buf, nbytes); _thr_cancel_leave(curthread, oldcancel); - return ret; } @@ -723,9 +711,7 @@ __writev(int fd, const struct iovec *iov, int iovcnt) oldcancel = _thr_cancel_enter(curthread); ret = __sys_writev(fd, iov, iovcnt); _thr_cancel_leave(curthread, oldcancel); - return ret; } __strong_reference(__writev, writev); - diff --git a/lib/libthread_xu/thread/thr_umtx.c b/lib/libthread_xu/thread/thr_umtx.c index 55f80e1723..386b330de8 100644 --- a/lib/libthread_xu/thread/thr_umtx.c +++ b/lib/libthread_xu/thread/thr_umtx.c @@ -25,7 +25,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_umtx.c,v 1.4 2008/04/14 20:12:41 dillon Exp $ */ #include @@ -88,109 +87,113 @@ __thr_umtx_unlock(volatile umtx_t *mtx) int __thr_umtx_timedlock(volatile umtx_t *mtx, const struct timespec *timeout) { - struct timespec ts, ts2, ts3; - int timo, ret; + struct timespec ts, ts2, ts3; + int timo, ret; - if ((timeout->tv_sec < 0) || - (timeout->tv_sec == 0 && timeout->tv_nsec <= 0)) + if ((timeout->tv_sec < 0) || + (timeout->tv_sec == 0 && timeout->tv_nsec <= 0)) return (ETIMEDOUT); - /* XXX there should have MONO timer! */ - clock_gettime(CLOCK_REALTIME, &ts); - TIMESPEC_ADD(&ts, &ts, timeout); - ts2 = *timeout; - - for (;;) { - if (ts2.tv_nsec) { - timo = (int)(ts2.tv_nsec / 1000); - if (timo == 0) - timo = 1; - } else { - timo = 1000000; - } - ret = __thr_umtx_lock(mtx, timo); - if (ret != EINTR && ret != ETIMEDOUT) - break; - clock_gettime(CLOCK_REALTIME, &ts3); - TIMESPEC_SUB(&ts2, &ts, &ts3); - if (ts2.tv_sec < 0 || (ts2.tv_sec == 0 && ts2.tv_nsec <= 0)) { - ret = ETIMEDOUT; - break; + /* XXX there should have MONO timer! */ + clock_gettime(CLOCK_REALTIME, &ts); + TIMESPEC_ADD(&ts, &ts, timeout); + ts2 = *timeout; + + for (;;) { + if (ts2.tv_nsec) { + timo = (int)(ts2.tv_nsec / 1000); + if (timo == 0) + timo = 1; + } else { + timo = 1000000; + } + ret = __thr_umtx_lock(mtx, timo); + if (ret != EINTR && ret != ETIMEDOUT) + break; + clock_gettime(CLOCK_REALTIME, &ts3); + TIMESPEC_SUB(&ts2, &ts, &ts3); + if (ts2.tv_sec < 0 || + (ts2.tv_sec == 0 && ts2.tv_nsec <= 0)) { + ret = ETIMEDOUT; + break; + } } - } - return (ret); + return (ret); } int _thr_umtx_wait(volatile umtx_t *mtx, int exp, const struct timespec *timeout, int clockid) { - struct timespec ts, ts2, ts3; - int timo, errval, ret = 0; - - if (*mtx != exp) - return (0); - - if (timeout == NULL) { - while ( (errval = _umtx_sleep_err(mtx, exp, 10000000)) > 0) { - if (errval == EBUSY) - break; - if (errval == EINTR) { - ret = EINTR; - break; - } + struct timespec ts, ts2, ts3; + int timo, errval, ret = 0; + + if (*mtx != exp) + return (0); + + if (timeout == NULL) { + while ( (errval = _umtx_sleep_err(mtx, exp, 10000000)) > 0) { + if (errval == EBUSY) + break; + if (errval == EINTR) { + ret = EINTR; + break; + } #if 0 - if (errval == ETIMEDOUT || errval == EWOULDBLOCK) { - if (*mtx != exp) { - fprintf(stderr, - "thr_umtx_wait: FAULT VALUE CHANGE " - "%d -> %d oncond %p\n", - exp, *mtx, mtx); - } - } + if (errval == ETIMEDOUT || errval == EWOULDBLOCK) { + if (*mtx != exp) { + fprintf(stderr, + "thr_umtx_wait: FAULT VALUE CHANGE " + "%d -> %d oncond %p\n", + exp, *mtx, mtx); + } + } #endif - if (*mtx != exp) - return(0); + if (*mtx != exp) + return(0); + } + return (ret); } - return (ret); - } - if ((timeout->tv_sec < 0) || - (timeout->tv_sec == 0 && timeout->tv_nsec <= 0)) + if ((timeout->tv_sec < 0) || + (timeout->tv_sec == 0 && timeout->tv_nsec <= 0)) return (ETIMEDOUT); - clock_gettime(clockid, &ts); - TIMESPEC_ADD(&ts, &ts, timeout); - ts2 = *timeout; - - for (;;) { - if (ts2.tv_nsec) { - timo = (int)(ts2.tv_nsec / 1000); - if (timo == 0) - timo = 1; - } else { - timo = 1000000; - } - if ( (errval = _umtx_sleep_err(mtx, exp, timo)) > 0) { - if (errval == EBUSY) { - ret = 0; - break; - } else if (errval == EINTR) { - ret = EINTR; - break; - } - } - clock_gettime(clockid, &ts3); - TIMESPEC_SUB(&ts2, &ts, &ts3); - if (ts2.tv_sec < 0 || (ts2.tv_sec == 0 && ts2.tv_nsec <= 0)) { - ret = ETIMEDOUT; - break; + clock_gettime(clockid, &ts); + TIMESPEC_ADD(&ts, &ts, timeout); + ts2 = *timeout; + + for (;;) { + if (ts2.tv_nsec) { + timo = (int)(ts2.tv_nsec / 1000); + if (timo == 0) + timo = 1; + } else { + timo = 1000000; + } + + if ( (errval = _umtx_sleep_err(mtx, exp, timo)) > 0) { + if (errval == EBUSY) { + ret = 0; + break; + } else if (errval == EINTR) { + ret = EINTR; + break; + } + } + + clock_gettime(clockid, &ts3); + TIMESPEC_SUB(&ts2, &ts, &ts3); + if (ts2.tv_sec < 0 || (ts2.tv_sec == 0 && ts2.tv_nsec <= 0)) { + ret = ETIMEDOUT; + break; + } } - } - return (ret); + return (ret); } -void _thr_umtx_wake(volatile umtx_t *mtx, int count) +void +_thr_umtx_wake(volatile umtx_t *mtx, int count) { - _umtx_wakeup_err(mtx, count); + _umtx_wakeup_err(mtx, count); } diff --git a/lib/libthread_xu/thread/thr_umtx.h b/lib/libthread_xu/thread/thr_umtx.h index 6dc26416b5..a514211eae 100644 --- a/lib/libthread_xu/thread/thr_umtx.h +++ b/lib/libthread_xu/thread/thr_umtx.h @@ -23,7 +23,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_umtx.h,v 1.5 2008/04/14 20:12:41 dillon Exp $ */ #ifndef _THR_DFLY_UMTX_H_ @@ -31,7 +30,7 @@ #include -#define UMTX_LOCKED 1 +#define UMTX_LOCKED 1 #define UMTX_CONTESTED 2 typedef int umtx_t; @@ -44,44 +43,43 @@ void __thr_umtx_unlock(volatile umtx_t *mtx); static inline void _thr_umtx_init(volatile umtx_t *mtx) { - *mtx = 0; + *mtx = 0; } static inline int _thr_umtx_trylock(volatile umtx_t *mtx, int id __unused) { - if (atomic_cmpset_acq_int(mtx, 0, 1)) - return (0); - return (EBUSY); + if (atomic_cmpset_acq_int(mtx, 0, 1)) + return (0); + return (EBUSY); } static inline int _thr_umtx_lock(volatile umtx_t *mtx, int id __unused) { - if (atomic_cmpset_acq_int(mtx, 0, 1)) - return (0); - return (__thr_umtx_lock(mtx, 0)); + if (atomic_cmpset_acq_int(mtx, 0, 1)) + return (0); + return (__thr_umtx_lock(mtx, 0)); } static inline int _thr_umtx_timedlock(volatile umtx_t *mtx, int id __unused, const struct timespec *timeout) { - if (atomic_cmpset_acq_int(mtx, 0, 1)) - return (0); - return (__thr_umtx_timedlock(mtx, timeout)); + if (atomic_cmpset_acq_int(mtx, 0, 1)) + return (0); + return (__thr_umtx_timedlock(mtx, timeout)); } static inline void _thr_umtx_unlock(volatile umtx_t *mtx, int id __unused) { - if (atomic_cmpset_acq_int(mtx, 1, 0)) - return; - __thr_umtx_unlock(mtx); + if (atomic_cmpset_acq_int(mtx, 1, 0)) + return; + __thr_umtx_unlock(mtx); } int _thr_umtx_wait(volatile umtx_t *mtx, umtx_t exp, const struct timespec *timeout, int clockid); void _thr_umtx_wake(volatile umtx_t *mtx, int count); - #endif diff --git a/lib/libthread_xu/thread/thr_yield.c b/lib/libthread_xu/thread/thr_yield.c index e7ca81bb3a..47ffda5622 100644 --- a/lib/libthread_xu/thread/thr_yield.c +++ b/lib/libthread_xu/thread/thr_yield.c @@ -26,7 +26,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/lib/libthread_xu/thread/thr_yield.c,v 1.3 2006/04/06 13:03:09 davidxu Exp $ */ #include "namespace.h" -- 2.41.0