Commit 7e0bef54 authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Pavel Emelyanov

zdtm/lib: Check EWOULDBLOCK in errno instead of -EWOULDBLOCK

Syscalls do return negative value in case of an error.
But errno contains the error code itself.

Add uint32_t to sys_futex() definition.
sizeof(unsigned int) might be not 4 bytes.
Signed-off-by: 's avatarDmitry Safonov <dima@arista.com>
Signed-off-by: 's avatarAdrian Reber <areber@redhat.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent a7cc23c0
......@@ -23,8 +23,8 @@ typedef struct {
#define FUTEX_ABORT_FLAG (0x80000000)
#define FUTEX_ABORT_RAW (-1U)
static inline int sys_futex(unsigned int *uaddr, int op, unsigned int val, const struct timespec *timeout,
int *uaddr2, unsigned int val3)
static inline int sys_futex(uint32_t *uaddr, int op, uint32_t val, const struct timespec *timeout,
uint32_t *uaddr2, uint32_t val3)
{
return syscall(__NR_futex, uaddr, op, val, timeout, uaddr2, val3);
}
......@@ -142,11 +142,11 @@ static void inline mutex_lock(mutex_t *m)
uint32_t c;
int ret;
while ((c = atomic_inc(&m->raw))) {
while ((c = atomic_inc(&m->raw)) != 0) {
ret = sys_futex(&m->raw, FUTEX_WAIT, c + 1, NULL, NULL, 0);
if (ret < 0)
pr_perror("futex");
BUG_ON(ret < 0 && errno != -EWOULDBLOCK);
BUG_ON(ret < 0 && errno != EWOULDBLOCK);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment