X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=compat_futex.c;h=9e918fe8e2aac035dc39e6e23868410348d02627;hp=a3571343ca37d086e77620da1ed0dd5e9fd71778;hb=b2633d211b186cb201be327ded53ecf523ecf0bd;hpb=b0a841b4ff807dd29fe0cdbfe24900312f0e627b diff --git a/compat_futex.c b/compat_futex.c index a357134..9e918fe 100644 --- a/compat_futex.c +++ b/compat_futex.c @@ -54,11 +54,11 @@ pthread_cond_t __urcu_compat_futex_cond = PTHREAD_COND_INITIALIZER; int compat_futex_noasync(int32_t *uaddr, int op, int32_t val, const struct timespec *timeout, int32_t *uaddr2, int32_t val3) { - int ret; + int ret = 0, lockret; /* * Check if NULL. Don't let users expect that they are taken into - * account. + * account. */ assert(!timeout); assert(!uaddr2); @@ -69,9 +69,9 @@ int compat_futex_noasync(int32_t *uaddr, int op, int32_t val, */ cmm_smp_mb(); - ret = pthread_mutex_lock(&__urcu_compat_futex_lock); - if (ret) { - errno = ret; + lockret = pthread_mutex_lock(&__urcu_compat_futex_lock); + if (lockret) { + errno = lockret; ret = -1; goto end; } @@ -98,9 +98,9 @@ int compat_futex_noasync(int32_t *uaddr, int op, int32_t val, errno = EINVAL; ret = -1; } - ret = pthread_mutex_unlock(&__urcu_compat_futex_lock); - if (ret) { - errno = ret; + lockret = pthread_mutex_unlock(&__urcu_compat_futex_lock); + if (lockret) { + errno = lockret; ret = -1; } end: @@ -111,6 +111,8 @@ end: * _ASYNC SIGNAL-SAFE_. * For now, timeout, uaddr2 and val3 are unused. * Waiter will busy-loop trying to read the condition. + * It is OK to use compat_futex_async() on a futex address on which + * futex() WAKE operations are also performed. */ int compat_futex_async(int32_t *uaddr, int op, int32_t val, @@ -120,7 +122,7 @@ int compat_futex_async(int32_t *uaddr, int op, int32_t val, /* * Check if NULL. Don't let users expect that they are taken into - * account. + * account. */ assert(!timeout); assert(!uaddr2);