From ef701f63fa3053a2d0560ac02390b3c8c912fa01 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Wed, 28 Mar 2018 01:44:43 +0200 Subject: Fix coding style --- sysdeps/mach/hurd/pt-attr-setstackaddr.c | 3 +- sysdeps/mach/hurd/pt-attr-setstacksize.c | 3 +- sysdeps/mach/hurd/pt-docancel.c | 2 +- sysdeps/mach/hurd/pt-hurd-cond-timedwait.c | 31 +++++---- sysdeps/mach/hurd/pt-hurd-cond-wait.c | 6 +- sysdeps/mach/hurd/pt-mutex-consistent.c | 8 ++- sysdeps/mach/hurd/pt-mutex-destroy.c | 5 +- sysdeps/mach/hurd/pt-mutex-getprioceiling.c | 6 +- sysdeps/mach/hurd/pt-mutex-init.c | 14 ++-- sysdeps/mach/hurd/pt-mutex-lock.c | 67 +++++++++--------- sysdeps/mach/hurd/pt-mutex-setprioceiling.c | 7 +- sysdeps/mach/hurd/pt-mutex-timedlock.c | 74 ++++++++++---------- sysdeps/mach/hurd/pt-mutex-transfer-np.c | 49 ++++++------- sysdeps/mach/hurd/pt-mutex-trylock.c | 79 ++++++++++----------- sysdeps/mach/hurd/pt-mutex-unlock.c | 91 +++++++++++++------------ sysdeps/mach/hurd/pt-mutexattr-destroy.c | 6 +- sysdeps/mach/hurd/pt-mutexattr-getprioceiling.c | 6 +- sysdeps/mach/hurd/pt-mutexattr-getprotocol.c | 3 +- sysdeps/mach/hurd/pt-mutexattr-getpshared.c | 3 +- sysdeps/mach/hurd/pt-mutexattr-getrobust.c | 5 +- sysdeps/mach/hurd/pt-mutexattr-gettype.c | 3 +- sysdeps/mach/hurd/pt-mutexattr-init.c | 6 +- sysdeps/mach/hurd/pt-mutexattr-setprioceiling.c | 6 +- sysdeps/mach/hurd/pt-mutexattr-setprotocol.c | 9 +-- sysdeps/mach/hurd/pt-mutexattr-setpshared.c | 6 +- sysdeps/mach/hurd/pt-mutexattr-setrobust.c | 6 +- sysdeps/mach/hurd/pt-mutexattr-settype.c | 3 +- sysdeps/mach/hurd/pt-sigstate.c | 7 +- sysdeps/mach/hurd/pt-sysdep.c | 12 ++-- sysdeps/mach/hurd/pt-sysdep.h | 7 +- 30 files changed, 277 insertions(+), 256 deletions(-) diff --git a/sysdeps/mach/hurd/pt-attr-setstackaddr.c b/sysdeps/mach/hurd/pt-attr-setstackaddr.c index ed55331..711ae67 100644 --- a/sysdeps/mach/hurd/pt-attr-setstackaddr.c +++ b/sysdeps/mach/hurd/pt-attr-setstackaddr.c @@ -20,8 +20,7 @@ #include int -pthread_attr_setstackaddr (pthread_attr_t *attr, - void *stackaddr) +pthread_attr_setstackaddr (pthread_attr_t *attr, void *stackaddr) { attr->__stackaddr = stackaddr; return 0; diff --git a/sysdeps/mach/hurd/pt-attr-setstacksize.c b/sysdeps/mach/hurd/pt-attr-setstacksize.c index 101ec6a..6a96370 100644 --- a/sysdeps/mach/hurd/pt-attr-setstacksize.c +++ b/sysdeps/mach/hurd/pt-attr-setstacksize.c @@ -20,8 +20,7 @@ #include int -pthread_attr_setstacksize (pthread_attr_t *attr, - size_t stacksize) +pthread_attr_setstacksize (pthread_attr_t *attr, size_t stacksize) { attr->__stacksize = stacksize; return 0; diff --git a/sysdeps/mach/hurd/pt-docancel.c b/sysdeps/mach/hurd/pt-docancel.c index 767122d..a8bcb24 100644 --- a/sysdeps/mach/hurd/pt-docancel.c +++ b/sysdeps/mach/hurd/pt-docancel.c @@ -54,7 +54,7 @@ __pthread_do_cancel (struct __pthread *p) assert_perror (err); err = __thread_set_pcsptp (p->kernel_thread, - 1, (void *) call_exit, 0, 0, 0, 0); + 1, (void *) call_exit, 0, 0, 0, 0); assert_perror (err); err = __thread_resume (p->kernel_thread); diff --git a/sysdeps/mach/hurd/pt-hurd-cond-timedwait.c b/sysdeps/mach/hurd/pt-hurd-cond-timedwait.c index a4e8fe9..182a7e2 100644 --- a/sysdeps/mach/hurd/pt-hurd-cond-timedwait.c +++ b/sysdeps/mach/hurd/pt-hurd-cond-timedwait.c @@ -24,7 +24,8 @@ extern int __pthread_hurd_cond_timedwait_internal (pthread_cond_t *cond, pthread_mutex_t *mutex, - const struct timespec *abstime); + const struct timespec + *abstime); int __pthread_hurd_cond_timedwait_np (pthread_cond_t *cond, @@ -51,22 +52,22 @@ __pthread_hurd_cond_timedwait_internal (pthread_cond_t *cond, We wake up our thread if it's still blocking or about to block, so it will progress and notice the cancellation flag. */ void cancel_me (void) - { - int unblock; + { + int unblock; - __pthread_spin_lock (&cond->__lock); - /* The thread only needs to be awaken if it's blocking or about to block. - If it was already unblocked, it's not queued any more. */ - unblock = self->prevp != NULL; - if (unblock) - __pthread_dequeue (self); - __pthread_spin_unlock (&cond->__lock); + __pthread_spin_lock (&cond->__lock); + /* The thread only needs to be awaken if it's blocking or about to block. + If it was already unblocked, it's not queued any more. */ + unblock = self->prevp != NULL; + if (unblock) + __pthread_dequeue (self); + __pthread_spin_unlock (&cond->__lock); - if (unblock) - __pthread_wakeup (self); - } + if (unblock) + __pthread_wakeup (self); + } - assert (ss->intr_port == MACH_PORT_NULL); /* Sanity check for signal bugs. */ + assert (ss->intr_port == MACH_PORT_NULL); /* Sanity check for signal bugs. */ if (abstime && (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)) return EINVAL; @@ -119,7 +120,7 @@ __pthread_hurd_cond_timedwait_internal (pthread_cond_t *cond, } /* As it was done when enqueueing, prevent hurd_thread_cancel from - suspending us while the condition lock is held. */ + suspending us while the condition lock is held. */ __spin_lock (&ss->lock); __pthread_spin_lock (&cond->__lock); if (self->prevp == NULL) diff --git a/sysdeps/mach/hurd/pt-hurd-cond-wait.c b/sysdeps/mach/hurd/pt-hurd-cond-wait.c index fd3e0bd..1915b92 100644 --- a/sysdeps/mach/hurd/pt-hurd-cond-wait.c +++ b/sysdeps/mach/hurd/pt-hurd-cond-wait.c @@ -25,11 +25,11 @@ /* Implemented in pt-hurd-cond-timedwait.c. */ extern int __pthread_hurd_cond_timedwait_internal (pthread_cond_t *cond, pthread_mutex_t *mutex, - const struct timespec *abstime); + const struct timespec + *abstime); int -__pthread_hurd_cond_wait_np (pthread_cond_t *cond, - pthread_mutex_t *mutex) +__pthread_hurd_cond_wait_np (pthread_cond_t *cond, pthread_mutex_t *mutex) { error_t err; diff --git a/sysdeps/mach/hurd/pt-mutex-consistent.c b/sysdeps/mach/hurd/pt-mutex-consistent.c index 771a1ef..9111c12 100644 --- a/sysdeps/mach/hurd/pt-mutex-consistent.c +++ b/sysdeps/mach/hurd/pt-mutex-consistent.c @@ -23,7 +23,8 @@ #include "pt-mutex.h" #include -int pthread_mutex_consistent (pthread_mutex_t *mtxp) +int +pthread_mutex_consistent (pthread_mutex_t *mtxp) { int ret = EINVAL; unsigned int val = mtxp->__lock; @@ -31,10 +32,11 @@ int pthread_mutex_consistent (pthread_mutex_t *mtxp) if ((mtxp->__flags & PTHREAD_MUTEX_ROBUST) != 0 && (val & LLL_DEAD_OWNER) != 0 && atomic_compare_and_exchange_bool_acq (&mtxp->__lock, - __getpid () | LLL_WAITERS, val) == 0) + __getpid () | LLL_WAITERS, + val) == 0) { /* The mutex is now ours, and it's consistent. */ - mtxp->__owner_id = _pthread_self()->thread; + mtxp->__owner_id = _pthread_self ()->thread; mtxp->__cnt = 1; ret = 0; } diff --git a/sysdeps/mach/hurd/pt-mutex-destroy.c b/sysdeps/mach/hurd/pt-mutex-destroy.c index eee55fc..fbdfe4c 100644 --- a/sysdeps/mach/hurd/pt-mutex-destroy.c +++ b/sysdeps/mach/hurd/pt-mutex-destroy.c @@ -23,10 +23,11 @@ #include "pt-mutex.h" #include -int _pthread_mutex_destroy (pthread_mutex_t *mtxp) +int +_pthread_mutex_destroy (pthread_mutex_t *mtxp) { atomic_read_barrier (); - if (*(volatile unsigned int *)&mtxp->__lock != 0) + if (*(volatile unsigned int *) &mtxp->__lock != 0) return (EBUSY); mtxp->__type = -1; diff --git a/sysdeps/mach/hurd/pt-mutex-getprioceiling.c b/sysdeps/mach/hurd/pt-mutex-getprioceiling.c index 367db3a..61f1547 100644 --- a/sysdeps/mach/hurd/pt-mutex-getprioceiling.c +++ b/sysdeps/mach/hurd/pt-mutex-getprioceiling.c @@ -23,9 +23,11 @@ #include "pt-mutex.h" #include -int pthread_mutex_getprioceiling (const pthread_mutex_t *mtxp, int *clp) +int +pthread_mutex_getprioceiling (const pthread_mutex_t *mtxp, int *clp) { - (void)mtxp; (void)clp; + (void) mtxp; + (void) clp; return (ENOSYS); } diff --git a/sysdeps/mach/hurd/pt-mutex-init.c b/sysdeps/mach/hurd/pt-mutex-init.c index 4e9720e..ff614f6 100644 --- a/sysdeps/mach/hurd/pt-mutex-init.c +++ b/sysdeps/mach/hurd/pt-mutex-init.c @@ -23,26 +23,26 @@ #include "pt-mutex.h" #include -static const pthread_mutexattr_t dfl_attr = -{ +static const pthread_mutexattr_t dfl_attr = { .__prioceiling = 0, .__protocol = PTHREAD_PRIO_NONE, .__pshared = PTHREAD_PROCESS_PRIVATE, .__mutex_type = __PTHREAD_MUTEX_TIMED }; -int _pthread_mutex_init (pthread_mutex_t *mtxp, - const pthread_mutexattr_t *attrp) +int +_pthread_mutex_init (pthread_mutex_t *mtxp, const pthread_mutexattr_t *attrp) { if (attrp == NULL) attrp = &dfl_attr; mtxp->__flags = (attrp->__pshared == PTHREAD_PROCESS_SHARED ? - GSYNC_SHARED : 0) | ((attrp->__prioceiling & PTHREAD_MUTEX_ROBUST) ? - PTHREAD_MUTEX_ROBUST : 0); + GSYNC_SHARED : 0) | ((attrp-> + __prioceiling & PTHREAD_MUTEX_ROBUST) ? + PTHREAD_MUTEX_ROBUST : 0); mtxp->__type = attrp->__mutex_type + - (attrp->__mutex_type != __PTHREAD_MUTEX_TIMED); + (attrp->__mutex_type != __PTHREAD_MUTEX_TIMED); mtxp->__owner_id = 0; mtxp->__shpid = 0; diff --git a/sysdeps/mach/hurd/pt-mutex-lock.c b/sysdeps/mach/hurd/pt-mutex-lock.c index 642129f..8ebb4f6 100644 --- a/sysdeps/mach/hurd/pt-mutex-lock.c +++ b/sysdeps/mach/hurd/pt-mutex-lock.c @@ -23,7 +23,8 @@ #include "pt-mutex.h" #include -int __pthread_mutex_lock (pthread_mutex_t *mtxp) +int +__pthread_mutex_lock (pthread_mutex_t *mtxp) { struct __pthread *self; int flags = mtxp->__flags & GSYNC_SHARED; @@ -31,45 +32,45 @@ int __pthread_mutex_lock (pthread_mutex_t *mtxp) switch (MTX_TYPE (mtxp)) { - case PT_MTX_NORMAL: - lll_lock (&mtxp->__lock, flags); - break; + case PT_MTX_NORMAL: + lll_lock (&mtxp->__lock, flags); + break; - case PT_MTX_RECURSIVE: - self = _pthread_self (); - if (mtx_owned_p (mtxp, self, flags)) - { - if (__glibc_unlikely (mtxp->__cnt + 1 == 0)) - return (EAGAIN); + case PT_MTX_RECURSIVE: + self = _pthread_self (); + if (mtx_owned_p (mtxp, self, flags)) + { + if (__glibc_unlikely (mtxp->__cnt + 1 == 0)) + return (EAGAIN); - ++mtxp->__cnt; - return (ret); - } + ++mtxp->__cnt; + return (ret); + } - lll_lock (&mtxp->__lock, flags); - mtx_set_owner (mtxp, self, flags); - mtxp->__cnt = 1; - break; + lll_lock (&mtxp->__lock, flags); + mtx_set_owner (mtxp, self, flags); + mtxp->__cnt = 1; + break; - case PT_MTX_ERRORCHECK: - self = _pthread_self (); - if (mtx_owned_p (mtxp, self, flags)) - return (EDEADLK); + case PT_MTX_ERRORCHECK: + self = _pthread_self (); + if (mtx_owned_p (mtxp, self, flags)) + return (EDEADLK); - lll_lock (&mtxp->__lock, flags); - mtx_set_owner (mtxp, self, flags); - break; + lll_lock (&mtxp->__lock, flags); + mtx_set_owner (mtxp, self, flags); + break; - case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: - case PT_MTX_RECURSIVE | PTHREAD_MUTEX_ROBUST: - case PT_MTX_ERRORCHECK | PTHREAD_MUTEX_ROBUST: - self = _pthread_self (); - ROBUST_LOCK (self, mtxp, __lll_robust_lock, flags); - break; + case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: + case PT_MTX_RECURSIVE | PTHREAD_MUTEX_ROBUST: + case PT_MTX_ERRORCHECK | PTHREAD_MUTEX_ROBUST: + self = _pthread_self (); + ROBUST_LOCK (self, mtxp, __lll_robust_lock, flags); + break; - default: - ret = EINVAL; - break; + default: + ret = EINVAL; + break; } return (ret); diff --git a/sysdeps/mach/hurd/pt-mutex-setprioceiling.c b/sysdeps/mach/hurd/pt-mutex-setprioceiling.c index a983886..3d6504e 100644 --- a/sysdeps/mach/hurd/pt-mutex-setprioceiling.c +++ b/sysdeps/mach/hurd/pt-mutex-setprioceiling.c @@ -23,9 +23,12 @@ #include "pt-mutex.h" #include -int pthread_mutex_setprioceiling (pthread_mutex_t *mtxp, int cl, int *prp) +int +pthread_mutex_setprioceiling (pthread_mutex_t *mtxp, int cl, int *prp) { - (void)mtxp; (void)cl; (void)prp; + (void) mtxp; + (void) cl; + (void) prp; return (ENOSYS); } diff --git a/sysdeps/mach/hurd/pt-mutex-timedlock.c b/sysdeps/mach/hurd/pt-mutex-timedlock.c index 006a8d8..b6308f8 100644 --- a/sysdeps/mach/hurd/pt-mutex-timedlock.c +++ b/sysdeps/mach/hurd/pt-mutex-timedlock.c @@ -23,57 +23,55 @@ #include "pt-mutex.h" #include -int pthread_mutex_timedlock (pthread_mutex_t *mtxp, - const struct timespec *tsp) +int +pthread_mutex_timedlock (pthread_mutex_t *mtxp, const struct timespec *tsp) { struct __pthread *self; int ret, flags = mtxp->__flags & GSYNC_SHARED; switch (MTX_TYPE (mtxp)) { - case PT_MTX_NORMAL: - ret = lll_abstimed_lock (&mtxp->__lock, tsp, flags); - break; + case PT_MTX_NORMAL: + ret = lll_abstimed_lock (&mtxp->__lock, tsp, flags); + break; - case PT_MTX_RECURSIVE: - self = _pthread_self (); - if (mtx_owned_p (mtxp, self, flags)) - { - if (__glibc_unlikely (mtxp->__cnt + 1 == 0)) - return (EAGAIN); + case PT_MTX_RECURSIVE: + self = _pthread_self (); + if (mtx_owned_p (mtxp, self, flags)) + { + if (__glibc_unlikely (mtxp->__cnt + 1 == 0)) + return (EAGAIN); - ++mtxp->__cnt; - ret = 0; - } - else if ((ret = lll_abstimed_lock (&mtxp->__lock, - tsp, flags)) == 0) - { - mtx_set_owner (mtxp, self, flags); - mtxp->__cnt = 1; - } + ++mtxp->__cnt; + ret = 0; + } + else if ((ret = lll_abstimed_lock (&mtxp->__lock, tsp, flags)) == 0) + { + mtx_set_owner (mtxp, self, flags); + mtxp->__cnt = 1; + } - break; + break; - case PT_MTX_ERRORCHECK: - self = _pthread_self (); - if (mtx_owned_p (mtxp, self, flags)) - ret = EDEADLK; - else if ((ret = lll_abstimed_lock (&mtxp->__lock, - tsp, flags)) == 0) - mtx_set_owner (mtxp, self, flags); + case PT_MTX_ERRORCHECK: + self = _pthread_self (); + if (mtx_owned_p (mtxp, self, flags)) + ret = EDEADLK; + else if ((ret = lll_abstimed_lock (&mtxp->__lock, tsp, flags)) == 0) + mtx_set_owner (mtxp, self, flags); - break; + break; - case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: - case PT_MTX_RECURSIVE | PTHREAD_MUTEX_ROBUST: - case PT_MTX_ERRORCHECK | PTHREAD_MUTEX_ROBUST: - self = _pthread_self (); - ROBUST_LOCK (self, mtxp, lll_robust_abstimed_lock, tsp, flags); - break; + case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: + case PT_MTX_RECURSIVE | PTHREAD_MUTEX_ROBUST: + case PT_MTX_ERRORCHECK | PTHREAD_MUTEX_ROBUST: + self = _pthread_self (); + ROBUST_LOCK (self, mtxp, lll_robust_abstimed_lock, tsp, flags); + break; - default: - ret = EINVAL; - break; + default: + ret = EINVAL; + break; } return (ret); diff --git a/sysdeps/mach/hurd/pt-mutex-transfer-np.c b/sysdeps/mach/hurd/pt-mutex-transfer-np.c index dc70909..618ab5b 100644 --- a/sysdeps/mach/hurd/pt-mutex-transfer-np.c +++ b/sysdeps/mach/hurd/pt-mutex-transfer-np.c @@ -23,7 +23,8 @@ #include "pt-mutex.h" #include -int __pthread_mutex_transfer_np (pthread_mutex_t *mtxp, pthread_t th) +int +__pthread_mutex_transfer_np (pthread_mutex_t *mtxp, pthread_t th) { struct __pthread *self = _pthread_self (); struct __pthread *pt = __pthread_getid (th); @@ -38,34 +39,34 @@ int __pthread_mutex_transfer_np (pthread_mutex_t *mtxp, pthread_t th) switch (MTX_TYPE (mtxp)) { - case PT_MTX_NORMAL: - break; + case PT_MTX_NORMAL: + break; - case PT_MTX_RECURSIVE: - case PT_MTX_ERRORCHECK: - if (!mtx_owned_p (mtxp, self, flags)) - ret = EPERM; - else - mtx_set_owner (mtxp, pt, flags); + case PT_MTX_RECURSIVE: + case PT_MTX_ERRORCHECK: + if (!mtx_owned_p (mtxp, self, flags)) + ret = EPERM; + else + mtx_set_owner (mtxp, pt, flags); - break; + break; - case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: - case PT_MTX_RECURSIVE | PTHREAD_MUTEX_ROBUST: - case PT_MTX_ERRORCHECK | PTHREAD_MUTEX_ROBUST: - /* Note that this can be used to transfer an inconsistent - * mutex as well. The new owner will still have the same - * flags as the original. */ - if (mtxp->__owner_id != self->thread || - (int)(mtxp->__lock & LLL_OWNER_MASK) != __getpid ()) - ret = EPERM; - else - mtxp->__owner_id = pt->thread; + case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: + case PT_MTX_RECURSIVE | PTHREAD_MUTEX_ROBUST: + case PT_MTX_ERRORCHECK | PTHREAD_MUTEX_ROBUST: + /* Note that this can be used to transfer an inconsistent + * mutex as well. The new owner will still have the same + * flags as the original. */ + if (mtxp->__owner_id != self->thread || + (int) (mtxp->__lock & LLL_OWNER_MASK) != __getpid ()) + ret = EPERM; + else + mtxp->__owner_id = pt->thread; - break; + break; - default: - ret = EINVAL; + default: + ret = EINVAL; } return (ret); diff --git a/sysdeps/mach/hurd/pt-mutex-trylock.c b/sysdeps/mach/hurd/pt-mutex-trylock.c index 14144f5..11d65bd 100644 --- a/sysdeps/mach/hurd/pt-mutex-trylock.c +++ b/sysdeps/mach/hurd/pt-mutex-trylock.c @@ -23,57 +23,58 @@ #include "pt-mutex.h" #include -int __pthread_mutex_trylock (pthread_mutex_t *mtxp) +int +__pthread_mutex_trylock (pthread_mutex_t *mtxp) { struct __pthread *self; int ret; switch (MTX_TYPE (mtxp)) { - case PT_MTX_NORMAL: - ret = lll_trylock (&mtxp->__lock); - if (ret) - ret = EBUSY; - break; + case PT_MTX_NORMAL: + ret = lll_trylock (&mtxp->__lock); + if (ret) + ret = EBUSY; + break; - case PT_MTX_RECURSIVE: - self = _pthread_self (); - if (mtx_owned_p (mtxp, self, mtxp->__flags)) - { - if (__glibc_unlikely (mtxp->__cnt + 1 == 0)) - return (EAGAIN); + case PT_MTX_RECURSIVE: + self = _pthread_self (); + if (mtx_owned_p (mtxp, self, mtxp->__flags)) + { + if (__glibc_unlikely (mtxp->__cnt + 1 == 0)) + return (EAGAIN); - ++mtxp->__cnt; - ret = 0; - } - else if ((ret = lll_trylock (&mtxp->__lock)) == 0) - { - mtx_set_owner (mtxp, self, mtxp->__flags); - mtxp->__cnt = 1; - } - else - ret = EBUSY; + ++mtxp->__cnt; + ret = 0; + } + else if ((ret = lll_trylock (&mtxp->__lock)) == 0) + { + mtx_set_owner (mtxp, self, mtxp->__flags); + mtxp->__cnt = 1; + } + else + ret = EBUSY; - break; + break; - case PT_MTX_ERRORCHECK: - self = _pthread_self (); - if ((ret = lll_trylock (&mtxp->__lock)) == 0) - mtx_set_owner (mtxp, self, mtxp->__flags); - else - ret = EBUSY; - break; + case PT_MTX_ERRORCHECK: + self = _pthread_self (); + if ((ret = lll_trylock (&mtxp->__lock)) == 0) + mtx_set_owner (mtxp, self, mtxp->__flags); + else + ret = EBUSY; + break; - case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: - case PT_MTX_RECURSIVE | PTHREAD_MUTEX_ROBUST: - case PT_MTX_ERRORCHECK | PTHREAD_MUTEX_ROBUST: - self = _pthread_self (); - ROBUST_LOCK (self, mtxp, __lll_robust_trylock); - break; + case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: + case PT_MTX_RECURSIVE | PTHREAD_MUTEX_ROBUST: + case PT_MTX_ERRORCHECK | PTHREAD_MUTEX_ROBUST: + self = _pthread_self (); + ROBUST_LOCK (self, mtxp, __lll_robust_trylock); + break; - default: - ret = EINVAL; - break; + default: + ret = EINVAL; + break; } return (ret); diff --git a/sysdeps/mach/hurd/pt-mutex-unlock.c b/sysdeps/mach/hurd/pt-mutex-unlock.c index 80ca5b9..de3ae9d 100644 --- a/sysdeps/mach/hurd/pt-mutex-unlock.c +++ b/sysdeps/mach/hurd/pt-mutex-unlock.c @@ -23,64 +23,65 @@ #include "pt-mutex.h" #include -int __pthread_mutex_unlock (pthread_mutex_t *mtxp) +int +__pthread_mutex_unlock (pthread_mutex_t *mtxp) { struct __pthread *self; int ret = 0, flags = mtxp->__flags & GSYNC_SHARED; switch (MTX_TYPE (mtxp)) { - case PT_MTX_NORMAL: - lll_unlock (&mtxp->__lock, flags); - break; + case PT_MTX_NORMAL: + lll_unlock (&mtxp->__lock, flags); + break; - case PT_MTX_RECURSIVE: - self = _pthread_self (); - if (!mtx_owned_p (mtxp, self, flags)) - ret = EPERM; - else if (--mtxp->__cnt == 0) - { - mtxp->__owner_id = mtxp->__shpid = 0; - lll_unlock (&mtxp->__lock, flags); - } + case PT_MTX_RECURSIVE: + self = _pthread_self (); + if (!mtx_owned_p (mtxp, self, flags)) + ret = EPERM; + else if (--mtxp->__cnt == 0) + { + mtxp->__owner_id = mtxp->__shpid = 0; + lll_unlock (&mtxp->__lock, flags); + } - break; + break; - case PT_MTX_ERRORCHECK: - self = _pthread_self (); - if (!mtx_owned_p (mtxp, self, flags)) - ret = EPERM; - else - { - mtxp->__owner_id = mtxp->__shpid = 0; - lll_unlock (&mtxp->__lock, flags); - } + case PT_MTX_ERRORCHECK: + self = _pthread_self (); + if (!mtx_owned_p (mtxp, self, flags)) + ret = EPERM; + else + { + mtxp->__owner_id = mtxp->__shpid = 0; + lll_unlock (&mtxp->__lock, flags); + } - break; + break; - case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: - case PT_MTX_RECURSIVE | PTHREAD_MUTEX_ROBUST: - case PT_MTX_ERRORCHECK | PTHREAD_MUTEX_ROBUST: - self = _pthread_self (); - if (mtxp->__owner_id == NOTRECOVERABLE_ID) - ; /* Nothing to do. */ - else if (mtxp->__owner_id != self->thread || - (int)(mtxp->__lock & LLL_OWNER_MASK) != __getpid ()) - ret = EPERM; - else if (--mtxp->__cnt == 0) - { - /* Release the lock. If it's in an inconsistent - * state, mark it as irrecoverable. */ - mtxp->__owner_id = (mtxp->__lock & LLL_DEAD_OWNER) ? - NOTRECOVERABLE_ID : 0; - __lll_robust_unlock (&mtxp->__lock, flags); - } + case PT_MTX_NORMAL | PTHREAD_MUTEX_ROBUST: + case PT_MTX_RECURSIVE | PTHREAD_MUTEX_ROBUST: + case PT_MTX_ERRORCHECK | PTHREAD_MUTEX_ROBUST: + self = _pthread_self (); + if (mtxp->__owner_id == NOTRECOVERABLE_ID) + ; /* Nothing to do. */ + else if (mtxp->__owner_id != self->thread || + (int) (mtxp->__lock & LLL_OWNER_MASK) != __getpid ()) + ret = EPERM; + else if (--mtxp->__cnt == 0) + { + /* Release the lock. If it's in an inconsistent + * state, mark it as irrecoverable. */ + mtxp->__owner_id = (mtxp->__lock & LLL_DEAD_OWNER) ? + NOTRECOVERABLE_ID : 0; + __lll_robust_unlock (&mtxp->__lock, flags); + } - break; + break; - default: - ret = EINVAL; - break; + default: + ret = EINVAL; + break; } return (ret); diff --git a/sysdeps/mach/hurd/pt-mutexattr-destroy.c b/sysdeps/mach/hurd/pt-mutexattr-destroy.c index 7c9dab1..75c7678 100644 --- a/sysdeps/mach/hurd/pt-mutexattr-destroy.c +++ b/sysdeps/mach/hurd/pt-mutexattr-destroy.c @@ -23,9 +23,11 @@ #include "pt-mutex.h" #include -int __pthread_mutexattr_destroy (pthread_mutexattr_t *attrp) +int +__pthread_mutexattr_destroy (pthread_mutexattr_t *attrp) { - (void)attrp; + (void) attrp; return (0); } + weak_alias (__pthread_mutexattr_destroy, pthread_mutexattr_destroy) diff --git a/sysdeps/mach/hurd/pt-mutexattr-getprioceiling.c b/sysdeps/mach/hurd/pt-mutexattr-getprioceiling.c index 94a3b0c..64e5287 100644 --- a/sysdeps/mach/hurd/pt-mutexattr-getprioceiling.c +++ b/sysdeps/mach/hurd/pt-mutexattr-getprioceiling.c @@ -23,9 +23,11 @@ #include "pt-mutex.h" #include -int pthread_mutexattr_getprioceiling (const pthread_mutexattr_t *ap, int *clp) +int +pthread_mutexattr_getprioceiling (const pthread_mutexattr_t *ap, int *clp) { - (void)ap; (void)clp; + (void) ap; + (void) clp; return (ENOSYS); } diff --git a/sysdeps/mach/hurd/pt-mutexattr-getprotocol.c b/sysdeps/mach/hurd/pt-mutexattr-getprotocol.c index 3f7a4c9..4d30873 100644 --- a/sysdeps/mach/hurd/pt-mutexattr-getprotocol.c +++ b/sysdeps/mach/hurd/pt-mutexattr-getprotocol.c @@ -23,7 +23,8 @@ #include "pt-mutex.h" #include -int pthread_mutexattr_getprotocol (const pthread_mutexattr_t *attrp, int *ptp) +int +pthread_mutexattr_getprotocol (const pthread_mutexattr_t *attrp, int *ptp) { *ptp = attrp->__protocol; return (0); diff --git a/sysdeps/mach/hurd/pt-mutexattr-getpshared.c b/sysdeps/mach/hurd/pt-mutexattr-getpshared.c index 322c9c8..e97dd9a 100644 --- a/sysdeps/mach/hurd/pt-mutexattr-getpshared.c +++ b/sysdeps/mach/hurd/pt-mutexattr-getpshared.c @@ -23,7 +23,8 @@ #include "pt-mutex.h" #include -int pthread_mutexattr_getpshared (const pthread_mutexattr_t *attrp, int *outp) +int +pthread_mutexattr_getpshared (const pthread_mutexattr_t *attrp, int *outp) { *outp = attrp->__pshared; return (0); diff --git a/sysdeps/mach/hurd/pt-mutexattr-getrobust.c b/sysdeps/mach/hurd/pt-mutexattr-getrobust.c index 68adf41..d55a1b8 100644 --- a/sysdeps/mach/hurd/pt-mutexattr-getrobust.c +++ b/sysdeps/mach/hurd/pt-mutexattr-getrobust.c @@ -23,10 +23,11 @@ #include "pt-mutex.h" #include -int pthread_mutexattr_getrobust (const pthread_mutexattr_t *attrp, int *outp) +int +pthread_mutexattr_getrobust (const pthread_mutexattr_t *attrp, int *outp) { *outp = (attrp->__prioceiling & PTHREAD_MUTEX_ROBUST) ? - PTHREAD_MUTEX_ROBUST : PTHREAD_MUTEX_STALLED; + PTHREAD_MUTEX_ROBUST : PTHREAD_MUTEX_STALLED; return (0); } diff --git a/sysdeps/mach/hurd/pt-mutexattr-gettype.c b/sysdeps/mach/hurd/pt-mutexattr-gettype.c index e3f9bd6..8f9d882 100644 --- a/sysdeps/mach/hurd/pt-mutexattr-gettype.c +++ b/sysdeps/mach/hurd/pt-mutexattr-gettype.c @@ -23,7 +23,8 @@ #include "pt-mutex.h" #include -int pthread_mutexattr_gettype (const pthread_mutexattr_t *attrp, int *outp) +int +pthread_mutexattr_gettype (const pthread_mutexattr_t *attrp, int *outp) { *outp = attrp->__mutex_type; return (0); diff --git a/sysdeps/mach/hurd/pt-mutexattr-init.c b/sysdeps/mach/hurd/pt-mutexattr-init.c index b15cff6..0e371a0 100644 --- a/sysdeps/mach/hurd/pt-mutexattr-init.c +++ b/sysdeps/mach/hurd/pt-mutexattr-init.c @@ -23,15 +23,15 @@ #include "pt-mutex.h" #include -static const pthread_mutexattr_t dfl_attr = -{ +static const pthread_mutexattr_t dfl_attr = { .__prioceiling = 0, .__protocol = PTHREAD_PRIO_NONE, .__pshared = PTHREAD_PROCESS_PRIVATE, .__mutex_type = __PTHREAD_MUTEX_TIMED }; -int __pthread_mutexattr_init (pthread_mutexattr_t *attrp) +int +__pthread_mutexattr_init (pthread_mutexattr_t *attrp) { *attrp = dfl_attr; return (0); diff --git a/sysdeps/mach/hurd/pt-mutexattr-setprioceiling.c b/sysdeps/mach/hurd/pt-mutexattr-setprioceiling.c index c37e300..81d7493 100644 --- a/sysdeps/mach/hurd/pt-mutexattr-setprioceiling.c +++ b/sysdeps/mach/hurd/pt-mutexattr-setprioceiling.c @@ -23,9 +23,11 @@ #include "pt-mutex.h" #include -int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *attrp, int cl) +int +pthread_mutexattr_setprioceiling (pthread_mutexattr_t *attrp, int cl) { - (void)attrp; (void)cl; + (void) attrp; + (void) cl; return (ENOSYS); } diff --git a/sysdeps/mach/hurd/pt-mutexattr-setprotocol.c b/sysdeps/mach/hurd/pt-mutexattr-setprotocol.c index 6c45218..b472024 100644 --- a/sysdeps/mach/hurd/pt-mutexattr-setprotocol.c +++ b/sysdeps/mach/hurd/pt-mutexattr-setprotocol.c @@ -23,10 +23,11 @@ #include "pt-mutex.h" #include -int pthread_mutexattr_setprotocol (pthread_mutexattr_t *attrp, int proto) +int +pthread_mutexattr_setprotocol (pthread_mutexattr_t *attrp, int proto) { - (void)attrp; + (void) attrp; return (proto == PTHREAD_PRIO_NONE ? 0 : - proto != PTHREAD_PRIO_INHERIT && - proto != PTHREAD_PRIO_PROTECT ? EINVAL : ENOTSUP); + proto != PTHREAD_PRIO_INHERIT && + proto != PTHREAD_PRIO_PROTECT ? EINVAL : ENOTSUP); } diff --git a/sysdeps/mach/hurd/pt-mutexattr-setpshared.c b/sysdeps/mach/hurd/pt-mutexattr-setpshared.c index ceecbf0..c399e22 100644 --- a/sysdeps/mach/hurd/pt-mutexattr-setpshared.c +++ b/sysdeps/mach/hurd/pt-mutexattr-setpshared.c @@ -23,10 +23,10 @@ #include "pt-mutex.h" #include -int pthread_mutexattr_setpshared (pthread_mutexattr_t *attrp, int pshared) +int +pthread_mutexattr_setpshared (pthread_mutexattr_t *attrp, int pshared) { - if (pshared != PTHREAD_PROCESS_PRIVATE && - pshared != PTHREAD_PROCESS_SHARED) + if (pshared != PTHREAD_PROCESS_PRIVATE && pshared != PTHREAD_PROCESS_SHARED) return (EINVAL); attrp->__pshared = pshared; diff --git a/sysdeps/mach/hurd/pt-mutexattr-setrobust.c b/sysdeps/mach/hurd/pt-mutexattr-setrobust.c index e013d44..b61dea5 100644 --- a/sysdeps/mach/hurd/pt-mutexattr-setrobust.c +++ b/sysdeps/mach/hurd/pt-mutexattr-setrobust.c @@ -23,10 +23,10 @@ #include "pt-mutex.h" #include -int pthread_mutexattr_setrobust (pthread_mutexattr_t *attrp, int robust) +int +pthread_mutexattr_setrobust (pthread_mutexattr_t *attrp, int robust) { - if (robust != PTHREAD_MUTEX_ROBUST && - robust != PTHREAD_MUTEX_STALLED) + if (robust != PTHREAD_MUTEX_ROBUST && robust != PTHREAD_MUTEX_STALLED) return (EINVAL); attrp->__prioceiling |= robust; diff --git a/sysdeps/mach/hurd/pt-mutexattr-settype.c b/sysdeps/mach/hurd/pt-mutexattr-settype.c index 5bd890d..f945b78 100644 --- a/sysdeps/mach/hurd/pt-mutexattr-settype.c +++ b/sysdeps/mach/hurd/pt-mutexattr-settype.c @@ -23,7 +23,8 @@ #include "pt-mutex.h" #include -int __pthread_mutexattr_settype (pthread_mutexattr_t *attrp, int type) +int +__pthread_mutexattr_settype (pthread_mutexattr_t *attrp, int type) { if (type < 0 || type > __PTHREAD_MUTEX_RECURSIVE) return (EINVAL); diff --git a/sysdeps/mach/hurd/pt-sigstate.c b/sysdeps/mach/hurd/pt-sigstate.c index dc6322c..bdc71c9 100644 --- a/sysdeps/mach/hurd/pt-sigstate.c +++ b/sysdeps/mach/hurd/pt-sigstate.c @@ -26,8 +26,7 @@ error_t __pthread_sigstate (struct __pthread *thread, int how, - const sigset_t *set, sigset_t *oset, - int clear_pending) + const sigset_t *set, sigset_t *oset, int clear_pending) { error_t err = 0; struct hurd_sigstate *ss; @@ -64,13 +63,13 @@ __pthread_sigstate (struct __pthread *thread, int how, ss->blocked &= ~_SIG_CANT_MASK; } - if (! err && clear_pending) + if (!err && clear_pending) __sigemptyset (&ss->pending); pending = _hurd_sigstate_pending (ss) & ~ss->blocked; _hurd_sigstate_unlock (ss); - if (! err && pending) + if (!err && pending) /* Send a message to the signal thread so it will wake up and check for pending signals. */ __msg_sig_post (_hurd_msgport, 0, 0, __mach_task_self ()); diff --git a/sysdeps/mach/hurd/pt-sysdep.c b/sysdeps/mach/hurd/pt-sysdep.c index 1478738..118b264 100644 --- a/sysdeps/mach/hurd/pt-sysdep.c +++ b/sysdeps/mach/hurd/pt-sysdep.c @@ -32,7 +32,7 @@ static void *init_routine (void); /* OK, the name of this variable isn't really appropriate, but I don't want to change it yet. */ -void *(*_cthread_init_routine)(void) = &init_routine; +void *(*_cthread_init_routine) (void) = &init_routine; /* This function is called from the Hurd-specific startup code. It should return a new stack pointer for the main thread. The caller @@ -54,11 +54,11 @@ _init_routine (void *stack) if (stack) { /* We are getting initialized due to dlopening a library using libpthread - while the main program was not linked against libpthread. */ + while the main program was not linked against libpthread. */ /* Avoid allocating another stack */ attrp = &attr; - pthread_attr_init(attrp); - pthread_attr_setstack(attrp, stack, __vm_page_size); + pthread_attr_init (attrp); + pthread_attr_setstack (attrp, stack, __vm_page_size); } /* Create the pthread structure for the main thread (i.e. us). */ @@ -90,7 +90,9 @@ init_routine (void) } #ifdef SHARED -__attribute__ ((constructor)) static void dynamic_init_routine(void) +__attribute__ ((constructor)) +static void +dynamic_init_routine (void) { _init_routine (__libc_stack_end); } diff --git a/sysdeps/mach/hurd/pt-sysdep.h b/sysdeps/mach/hurd/pt-sysdep.h index e44da17..88b087c 100644 --- a/sysdeps/mach/hurd/pt-sysdep.h +++ b/sysdeps/mach/hurd/pt-sysdep.h @@ -48,7 +48,7 @@ extern __thread struct __pthread *___pthread_self; }) extern inline void -__attribute__((__always_inline__)) +__attribute__ ((__always_inline__)) __pthread_stack_dealloc (void *stackaddr, size_t stacksize) { __vm_deallocate (__mach_task_self (), (vm_offset_t) stackaddr, stacksize); @@ -58,9 +58,8 @@ __pthread_stack_dealloc (void *stackaddr, size_t stacksize) its stack pointer to SP if SET_IP is true, and its thread pointer to TP if SET_TP is true. */ extern int __thread_set_pcsptp (thread_t thread, - int set_pc, void *pc, - int set_sp, void *sp, - int set_tp, void *tp); + int set_pc, void *pc, + int set_sp, void *sp, int set_tp, void *tp); #endif /* pt-sysdep.h */ -- cgit v1.2.3