[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 11/38] linux-user/syscall: Add support for clock_gettime64/clock_s
From: |
Laurent Vivier |
Subject: |
[PULL 11/38] linux-user/syscall: Add support for clock_gettime64/clock_settime64 |
Date: |
Mon, 16 Mar 2020 17:15:23 +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 479db1940ee9..aaf62d48992a 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)
{
@@ -11491,6 +11507,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:
{
@@ -11502,6 +11530,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 36/38] linux-user, aarch64: sync syscall numbers with kernel v5.5, (continued)
- [PULL 36/38] linux-user, aarch64: sync syscall numbers with kernel v5.5, Laurent Vivier, 2020/03/16
- [PULL 15/38] linux-user, alpha: add syscall table generation support, Laurent Vivier, 2020/03/16
- [PULL 32/38] linux-user: update syscall.tbl from linux 0bf999f9c5e7, Laurent Vivier, 2020/03/16
- [PULL 31/38] linux-user, scripts: add a script to update syscall.tbl, Laurent Vivier, 2020/03/16
- [PULL 27/38] linux-user, i386: add syscall table generation support, Laurent Vivier, 2020/03/16
- [PULL 06/38] linux-user: Add AT_EXECFN auxval, Laurent Vivier, 2020/03/16
- [PULL 12/38] linux-user: Support futex_time64, Laurent Vivier, 2020/03/16
- [PULL 20/38] linux-user, microblaze: add syscall table generation support, Laurent Vivier, 2020/03/16
- [PULL 14/38] linux-user: introduce parameters to generate syscall_nr.h, Laurent Vivier, 2020/03/16
- [PULL 37/38] linux-user, nios2: sync syscall numbers with kernel v5.5, Laurent Vivier, 2020/03/16
- [PULL 11/38] linux-user/syscall: Add support for clock_gettime64/clock_settime64,
Laurent Vivier <=
- [PULL 13/38] linux-user/riscv: Update the syscall_nr's to the 5.5 kernel, Laurent Vivier, 2020/03/16
- [PULL 18/38] linux-user, xtensa: add syscall table generation support, Laurent Vivier, 2020/03/16
- [PULL 30/38] linux-user, mips64: add syscall table generation support, Laurent Vivier, 2020/03/16
- [PULL 33/38] linux-user,mips: move content of mips_syscall_args, Laurent Vivier, 2020/03/16
- [PULL 04/38] linux-user: Add x86_64 vsyscall page to /proc/self/maps, Laurent Vivier, 2020/03/16
- [PULL 08/38] linux-user: fix socket() strace, Laurent Vivier, 2020/03/16
- [PULL 01/38] target/i386: Renumber EXCP_SYSCALL, Laurent Vivier, 2020/03/16
- [PULL 17/38] linux-user, m68k: add syscall table generation support, Laurent Vivier, 2020/03/16
- [PULL 26/38] linux-user, x86_64, i386: cleanup TARGET_NR_arch_prctl, Laurent Vivier, 2020/03/16
- [PULL 34/38] linux-user,mips: update syscall-args-o32.c.inc, Laurent Vivier, 2020/03/16