[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 11/18] linux-user: Use safe_syscall wrapper for semo
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PATCH 11/18] linux-user: Use safe_syscall wrapper for semop |
Date: |
Mon, 6 Jun 2016 19:58:12 +0100 |
Use the safe_syscall wrapper for the semop syscall or IPC operation.
(We implement via the semtimedop syscall to make it easier to
implement the guest semtimedop syscall later.)
Signed-off-by: Peter Maydell <address@hidden>
---
linux-user/syscall.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index d40d1a7..8682ab0 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -719,6 +719,8 @@ safe_syscall4(int, msgsnd, int, msgid, const void *, msgp,
size_t, sz,
int, flags)
safe_syscall5(int, msgrcv, int, msgid, void *, msgp, size_t, sz,
long, msgtype, int, flags)
+safe_syscall4(int, semtimedop, int, semid, struct sembuf *, tsops,
+ unsigned, nsops, const struct timespec *, timeout)
#else
/* This host kernel architecture uses a single ipc syscall; fake up
* wrappers for the sub-operations to hide this implementation detail.
@@ -727,6 +729,7 @@ safe_syscall5(int, msgrcv, int, msgid, void *, msgp,
size_t, sz,
* sys/ipc.h ones. So we just define them here, and rely on them being
* the same for all host architectures.
*/
+#define Q_SEMTIMEDOP 4
#define Q_MSGSND 11
#define Q_MSGRCV 12
#define Q_IPCCALL(VERSION, OP) ((VERSION) << 16 | (OP))
@@ -741,6 +744,12 @@ static int safe_msgrcv(int msgid, void *msgp, size_t sz,
long type, int flags)
{
return safe_ipc(Q_IPCCALL(1, Q_MSGRCV), msgid, sz, flags, msgp, type);
}
+static int safe_semtimedop(int semid, struct sembuf *tsops, unsigned nsops,
+ const struct timespec *timeout)
+{
+ return safe_ipc(Q_IPCCALL(0, Q_SEMTIMEDOP), semid, nsops, 0, tsops,
+ (long)timeout);
+}
#endif
#if defined(TARGET_NR_mq_open) && defined(__NR_mq_open)
safe_syscall5(int, mq_timedsend, int, mqdes, const char *, msg_ptr,
@@ -3039,7 +3048,7 @@ static inline abi_long do_semop(int semid, abi_long ptr,
unsigned nsops)
if (target_to_host_sembuf(sops, ptr, nsops))
return -TARGET_EFAULT;
- return get_errno(semop(semid, sops, nsops));
+ return get_errno(safe_semtimedop(semid, sops, nsops, NULL));
}
struct target_msqid_ds
--
1.9.1
- [Qemu-devel] [PATCH 00/18] linux-user: Extend safe_syscall wrapper use, Peter Maydell, 2016/06/06
- [Qemu-devel] [PATCH 02/18] linux-user: Use safe_syscall wrapper for connect syscall, Peter Maydell, 2016/06/06
- [Qemu-devel] [PATCH 04/18] linux-user: Use safe_syscall wrapper for msgsnd and msgrcv, Peter Maydell, 2016/06/06
- [Qemu-devel] [PATCH 06/18] linux-user: Use safe_syscall wrapper for flock, Peter Maydell, 2016/06/06
- [Qemu-devel] [PATCH 07/18] linux-user: Use safe_syscall wrapper for rt_sigtimedwait syscall, Peter Maydell, 2016/06/06
- [Qemu-devel] [PATCH 09/18] linux-user: Use safe_syscall wrapper for poll and ppoll syscalls, Peter Maydell, 2016/06/06
- [Qemu-devel] [PATCH 13/18] linux-user: Use safe_syscall wrapper for ioctl, Peter Maydell, 2016/06/06
- [Qemu-devel] [PATCH 15/18] linux-user: Correct signedness of target_flock l_start and l_len fields, Peter Maydell, 2016/06/06
- [Qemu-devel] [PATCH 11/18] linux-user: Use safe_syscall wrapper for semop,
Peter Maydell <=
- [Qemu-devel] [PATCH 17/18] linux-user: Make target_strerror() return 'const char *', Peter Maydell, 2016/06/06
- [Qemu-devel] [PATCH 01/18] linux-user: Use safe_syscall wrapper for readv and writev syscalls, Peter Maydell, 2016/06/06
- [Qemu-devel] [PATCH 16/18] linux-user: Use safe_syscall wrapper for fcntl, Peter Maydell, 2016/06/06
- [Qemu-devel] [PATCH 12/18] linux-user: Use safe_syscall wrapper for accept and accept4 syscalls, Peter Maydell, 2016/06/06
- [Qemu-devel] [PATCH 10/18] linux-user: Use safe_syscall wrapper for epoll_wait syscalls, Peter Maydell, 2016/06/06
- [Qemu-devel] [PATCH 14/18] linux-user: Use __get_user() and __put_user() to handle structs in do_fcntl(), Peter Maydell, 2016/06/06