[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 11/37] linux-user/syscall: Add support for clock_gettime64/cloc
From: |
Laurent Vivier |
Subject: |
[PULL v2 11/37] linux-user/syscall: Add support for clock_gettime64/clock_settime64 |
Date: |
Tue, 17 Mar 2020 16:50:50 +0100 |
From: Alistair Francis <address@hidden>
Add support for the clock_gettime64/clock_settime64 syscalls.
If your host is 64-bit or is 32-bit with the *_time64 syscall then the
timespec will correctly be a 64-bit time_t. Otherwise the host will
return a 32-bit time_t which will be rounded to 64-bits. This will be
incorrect after y2038.
Signed-off-by: Alistair Francis <address@hidden>
Reviewed-by: Laurent Vivier <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Laurent Vivier <address@hidden>
---
linux-user/syscall.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index ea1c84dc5de5..661404687080 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1229,6 +1229,22 @@ static inline abi_long target_to_host_timespec(struct
timespec *host_ts,
}
#endif
+#if defined(TARGET_NR_clock_settime64)
+static inline abi_long target_to_host_timespec64(struct timespec *host_ts,
+ abi_ulong target_addr)
+{
+ struct target__kernel_timespec *target_ts;
+
+ if (!lock_user_struct(VERIFY_READ, target_ts, target_addr, 1)) {
+ return -TARGET_EFAULT;
+ }
+ __get_user(host_ts->tv_sec, &target_ts->tv_sec);
+ __get_user(host_ts->tv_nsec, &target_ts->tv_nsec);
+ unlock_user_struct(target_ts, target_addr, 0);
+ return 0;
+}
+#endif
+
static inline abi_long host_to_target_timespec(abi_ulong target_addr,
struct timespec *host_ts)
{
@@ -11493,6 +11509,18 @@ static abi_long do_syscall1(void *cpu_env, int num,
abi_long arg1,
return ret;
}
#endif
+#ifdef TARGET_NR_clock_settime64
+ case TARGET_NR_clock_settime64:
+ {
+ struct timespec ts;
+
+ ret = target_to_host_timespec64(&ts, arg2);
+ if (!is_error(ret)) {
+ ret = get_errno(clock_settime(arg1, &ts));
+ }
+ return ret;
+ }
+#endif
#ifdef TARGET_NR_clock_gettime
case TARGET_NR_clock_gettime:
{
@@ -11504,6 +11532,17 @@ static abi_long do_syscall1(void *cpu_env, int num,
abi_long arg1,
return ret;
}
#endif
+#ifdef TARGET_NR_clock_gettime64
+ case TARGET_NR_clock_gettime64:
+ {
+ struct timespec ts;
+ ret = get_errno(clock_gettime(arg1, &ts));
+ if (!is_error(ret)) {
+ ret = host_to_target_timespec64(arg2, &ts);
+ }
+ return ret;
+ }
+#endif
#ifdef TARGET_NR_clock_getres
case TARGET_NR_clock_getres:
{
--
2.24.1
- [PULL v2 00/37] Linux user for 5.0 patches, Laurent Vivier, 2020/03/17
- [PULL v2 02/37] linux-user/i386: Split out gen_signal, Laurent Vivier, 2020/03/17
- [PULL v2 01/37] target/i386: Renumber EXCP_SYSCALL, Laurent Vivier, 2020/03/17
- [PULL v2 09/37] linux-user: Update TASK_UNMAPPED_BASE for aarch64, Laurent Vivier, 2020/03/17
- [PULL v2 06/37] linux-user: Add AT_EXECFN auxval, Laurent Vivier, 2020/03/17
- [PULL v2 05/37] linux-user: Flush out implementation of gettimeofday, Laurent Vivier, 2020/03/17
- [PULL v2 08/37] linux-user: fix socket() strace, Laurent Vivier, 2020/03/17
- [PULL v2 11/37] linux-user/syscall: Add support for clock_gettime64/clock_settime64,
Laurent Vivier <=
- [PULL v2 04/37] linux-user: Add x86_64 vsyscall page to /proc/self/maps, Laurent Vivier, 2020/03/17
- [PULL v2 07/37] linux-user: do prlimit selectively, Laurent Vivier, 2020/03/17
- [PULL v2 13/37] linux-user: introduce parameters to generate syscall_nr.h, Laurent Vivier, 2020/03/17
- [PULL v2 10/37] linux-user: Protect more syscalls, Laurent Vivier, 2020/03/17
- [PULL v2 16/37] linux-user, m68k: add syscall table generation support, Laurent Vivier, 2020/03/17
- [PULL v2 03/37] linux-user/i386: Emulate x86_64 vsyscalls, Laurent Vivier, 2020/03/17
- [PULL v2 12/37] linux-user/riscv: Update the syscall_nr's to the 5.5 kernel, Laurent Vivier, 2020/03/17
- [PULL v2 15/37] linux-user, hppa: add syscall table generation support, Laurent Vivier, 2020/03/17
- [PULL v2 14/37] linux-user, alpha: add syscall table generation support, Laurent Vivier, 2020/03/17