int compat_futex_noasync(int32_t *uaddr, int op, int32_t val,
const struct timespec *timeout, int32_t *uaddr2, int32_t val3)
{
- int ret, gret = 0;
+ int ret;
/*
* Check if NULL. Don't let users expect that they are taken into
cmm_smp_mb();
ret = pthread_mutex_lock(&__urcu_compat_futex_lock);
- assert(!ret);
+ if (ret) {
+ errno = ret;
+ ret = -1;
+ goto end;
+ }
switch (op) {
case FUTEX_WAIT:
/*
pthread_cond_broadcast(&__urcu_compat_futex_cond);
break;
default:
- gret = -EINVAL;
+ errno = EINVAL;
+ ret = -1;
}
ret = pthread_mutex_unlock(&__urcu_compat_futex_lock);
- assert(!ret);
- return gret;
+ if (ret) {
+ errno = ret;
+ ret = -1;
+ }
+end:
+ return ret;
}
/*
int compat_futex_async(int32_t *uaddr, int op, int32_t val,
const struct timespec *timeout, int32_t *uaddr2, int32_t val3)
{
+ int ret = 0;
+
/*
* Check if NULL. Don't let users expect that they are taken into
* account.
switch (op) {
case FUTEX_WAIT:
- while (CMM_LOAD_SHARED(*uaddr) == val)
- poll(NULL, 0, 10);
+ while (CMM_LOAD_SHARED(*uaddr) == val) {
+ if (poll(NULL, 0, 10) < 0) {
+ ret = -1;
+ /* Keep poll errno. Caller handles EINTR. */
+ goto end;
+ }
+ }
break;
case FUTEX_WAKE:
break;
default:
- return -EINVAL;
+ errno = EINVAL;
+ ret = -1;
}
- return 0;
+end:
+ return ret;
}