linux-user: make FUTEX_* calls honor timeout parameter
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com> Signed-off-by: malc <av1474@comtv.ru>
This commit is contained in:
parent
d6630708bd
commit
a16aae0ca4
|
@ -4026,14 +4026,16 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout,
|
||||||
target_ulong uaddr2, int val3)
|
target_ulong uaddr2, int val3)
|
||||||
{
|
{
|
||||||
struct timespec ts, *pts;
|
struct timespec ts, *pts;
|
||||||
|
int base_op;
|
||||||
|
|
||||||
/* ??? We assume FUTEX_* constants are the same on both host
|
/* ??? We assume FUTEX_* constants are the same on both host
|
||||||
and target. */
|
and target. */
|
||||||
#ifdef FUTEX_CMD_MASK
|
#ifdef FUTEX_CMD_MASK
|
||||||
switch ((op&FUTEX_CMD_MASK)) {
|
base_op = op & FUTEX_CMD_MASK;
|
||||||
#else
|
#else
|
||||||
switch (op) {
|
base_op = op;
|
||||||
#endif
|
#endif
|
||||||
|
switch (base_op) {
|
||||||
case FUTEX_WAIT:
|
case FUTEX_WAIT:
|
||||||
if (timeout) {
|
if (timeout) {
|
||||||
pts = &ts;
|
pts = &ts;
|
||||||
|
@ -4045,16 +4047,22 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout,
|
||||||
pts, NULL, 0));
|
pts, NULL, 0));
|
||||||
case FUTEX_WAKE:
|
case FUTEX_WAKE:
|
||||||
return get_errno(sys_futex(g2h(uaddr), op, val, NULL, NULL, 0));
|
return get_errno(sys_futex(g2h(uaddr), op, val, NULL, NULL, 0));
|
||||||
case FUTEX_WAKE_OP:
|
|
||||||
return get_errno(sys_futex(g2h(uaddr), op, val, NULL, g2h(uaddr2), val3 ));
|
|
||||||
case FUTEX_FD:
|
case FUTEX_FD:
|
||||||
return get_errno(sys_futex(g2h(uaddr), op, val, NULL, NULL, 0));
|
return get_errno(sys_futex(g2h(uaddr), op, val, NULL, NULL, 0));
|
||||||
case FUTEX_REQUEUE:
|
case FUTEX_REQUEUE:
|
||||||
return get_errno(sys_futex(g2h(uaddr), op, val,
|
|
||||||
NULL, g2h(uaddr2), 0));
|
|
||||||
case FUTEX_CMP_REQUEUE:
|
case FUTEX_CMP_REQUEUE:
|
||||||
return get_errno(sys_futex(g2h(uaddr), op, val,
|
case FUTEX_WAKE_OP:
|
||||||
NULL, g2h(uaddr2), tswap32(val3)));
|
/* For FUTEX_REQUEUE, FUTEX_CMP_REQUEUE, and FUTEX_WAKE_OP, the
|
||||||
|
TIMEOUT parameter is interpreted as a uint32_t by the kernel.
|
||||||
|
But the prototype takes a `struct timespec *'; insert casts
|
||||||
|
to satisfy the compiler. We do not need to tswap TIMEOUT
|
||||||
|
since it's not compared to guest memory. */
|
||||||
|
pts = (struct timespec *)(uintptr_t) timeout;
|
||||||
|
return get_errno(sys_futex(g2h(uaddr), op, val, pts,
|
||||||
|
g2h(uaddr2),
|
||||||
|
(base_op == FUTEX_CMP_REQUEUE
|
||||||
|
? tswap32(val3)
|
||||||
|
: val3)));
|
||||||
default:
|
default:
|
||||||
return -TARGET_ENOSYS;
|
return -TARGET_ENOSYS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue