summaryrefslogtreecommitdiff
path: root/sysdeps/mach/hurd/pt-mutex-trylock.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/mach/hurd/pt-mutex-trylock.c')
-rw-r--r--sysdeps/mach/hurd/pt-mutex-trylock.c79
1 files changed, 40 insertions, 39 deletions
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 <hurdlock.h>
-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);