From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MXznn-0007L4-GL for qemu-devel@nongnu.org; Mon, 03 Aug 2009 11:50:19 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MXznh-0007KM-Hb for qemu-devel@nongnu.org; Mon, 03 Aug 2009 11:50:18 -0400 Received: from [199.232.76.173] (port=44675 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MXznh-0007KF-5f for qemu-devel@nongnu.org; Mon, 03 Aug 2009 11:50:13 -0400 Received: from mx20.gnu.org ([199.232.41.8]:50850) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MXzng-0006mZ-RN for qemu-devel@nongnu.org; Mon, 03 Aug 2009 11:50:12 -0400 Received: from mail.codesourcery.com ([65.74.133.4]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MXzng-0004tG-3k for qemu-devel@nongnu.org; Mon, 03 Aug 2009 11:50:12 -0400 From: Nathan Froyd Date: Mon, 3 Aug 2009 08:43:29 -0700 Message-Id: <1249314209-10230-8-git-send-email-froydnj@codesourcery.com> In-Reply-To: <1249314209-10230-1-git-send-email-froydnj@codesourcery.com> References: <1249314209-10230-1-git-send-email-froydnj@codesourcery.com> Subject: [Qemu-devel] [PATCH 7/7] linux-user: make FUTEX_* calls honor timeout parameter List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Signed-off-by: Nathan Froyd --- linux-user/syscall.c | 24 ++++++++++++++++-------- 1 files changed, 16 insertions(+), 8 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b5f669e..673eed4 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4026,14 +4026,16 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout, target_ulong uaddr2, int val3) { struct timespec ts, *pts; + int base_op; /* ??? We assume FUTEX_* constants are the same on both host and target. */ #ifdef FUTEX_CMD_MASK - switch ((op&FUTEX_CMD_MASK)) { + base_op = op & FUTEX_CMD_MASK; #else - switch (op) { + base_op = op; #endif + switch (base_op) { case FUTEX_WAIT: if (timeout) { pts = &ts; @@ -4045,16 +4047,22 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout, pts, NULL, 0)); case FUTEX_WAKE: 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: return get_errno(sys_futex(g2h(uaddr), op, val, NULL, NULL, 0)); case FUTEX_REQUEUE: - return get_errno(sys_futex(g2h(uaddr), op, val, - NULL, g2h(uaddr2), 0)); case FUTEX_CMP_REQUEUE: - return get_errno(sys_futex(g2h(uaddr), op, val, - NULL, g2h(uaddr2), tswap32(val3))); + case FUTEX_WAKE_OP: + /* 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: return -TARGET_ENOSYS; } -- 1.6.3.2