From: Nathan Froyd <froydnj@codesourcery.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 7/7] linux-user: make FUTEX_* calls honor timeout parameter
Date: Mon, 3 Aug 2009 08:43:29 -0700 [thread overview]
Message-ID: <1249314209-10230-8-git-send-email-froydnj@codesourcery.com> (raw)
In-Reply-To: <1249314209-10230-1-git-send-email-froydnj@codesourcery.com>
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
---
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
next prev parent reply other threads:[~2009-08-03 15:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-03 15:43 [Qemu-devel] [PATCH 0/7] NPTL support for PPC, v2 Nathan Froyd
2009-08-03 15:43 ` [Qemu-devel] [PATCH 1/7] target-ppc: fix cpu_clone_regs Nathan Froyd
2009-08-03 15:43 ` [Qemu-devel] [PATCH 2/7] target-ppc: add cpu_set_tls Nathan Froyd
2009-08-03 15:43 ` [Qemu-devel] [PATCH 3/7] target-ppc: retain l{w,d}arx loaded value Nathan Froyd
2009-08-03 15:43 ` [Qemu-devel] [PATCH 4/7] target-ppc: add exceptions for conditional stores Nathan Froyd
2009-08-03 15:43 ` [Qemu-devel] [PATCH 5/7] linux-user: handle POWERPC_EXCP_STCX Nathan Froyd
2009-08-03 15:43 ` [Qemu-devel] [PATCH 6/7] enable NPTL for ppc-linux-user targets in configure Nathan Froyd
2009-08-03 15:43 ` Nathan Froyd [this message]
2009-08-04 16:19 ` [Qemu-devel] [PATCH 0/7] NPTL support for PPC, v2 Martin Mohring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1249314209-10230-8-git-send-email-froydnj@codesourcery.com \
--to=froydnj@codesourcery.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).