y2038: cobalt/posix/clock: Adding clock_gettime64
PATCH v5 1/5 y2038: cobalt/posix/clock: Adding clock_gettime64
From: chensong <[email protected]>
Add a syscall specific for clock_gettime with 64bit time_t.
---
v5:
1, new helper __cobalt_clock_gettime64
--- include/cobalt/kernel/time.h | 11 +++++++++++ include/cobalt/uapi/syscall.h | 1 + kernel/cobalt/posix/clock.c | 23 ++++++++++++++++++++++- kernel/cobalt/posix/clock.h | 6 ++++++ kernel/cobalt/posix/syscall32.c | 8 ++++++++ kernel/cobalt/posix/syscall32.h | 4 ++++ kernel/cobalt/time.c | 11 +++++++++++ 7 files changed, 63 insertions(+), 1 deletion(-)
include/cobalt/kernel/time.h +11 -0
@@ -19,4 +19,15 @@int cobalt_get_timespec64 (struct timespec64 *ts,const struct __kernel_timespec __user *uts); +/** +* Covert struct timespec64 to struct __kernel_timespec +* and copy to userspace +* +* @param ts The source, provided by kernel +* @param uts The destination, will be filled +* @return 0 on success, -EFAULT otherwise +*/ +int cobalt_put_timespec64 (const struct timespec64 *ts, +struct __kernel_timespec __user *uts); +#endif //_COBALT_KERNEL_TIME_H
include/cobalt/uapi/syscall.h +1 -0
@@ -123,6 +123,7 @@#define sc_cobalt_clock_adjtime 100#define sc_cobalt_thread_setschedprio 101#define sc_cobalt_sem_timedwait64 102 +#define sc_cobalt_clock_gettime64 103#define __NR_COBALT_SYSCALLS 128/* Power of 2 */
kernel/cobalt/posix/clock.c +22 -1
@@ -23,6 +23,7 @@#include "thread.h" #include "clock.h" #include <trace/events/cobalt-posix.h> +#include <cobalt/kernel/time.h> static struct xnclock *external_clocks[COBALT_MAX_EXTCLOCKS ];
@@ -134,11 +135,31 @@ COBALT_SYSCALL(clock_gettime, current,if (cobalt_put_u_timespec (u_ts, &ts))return -EFAULT ; -trace_cobalt_clock_gettime (clock_id, &ts); +return 0 ; +} + +int __cobalt_clock_gettime64 (clockid_t clock_id, +struct __kernel_timespec __user *u_ts) +{ +struct timespec64 ts; +int ret; + + ret =__cobalt_clock_gettime (clock_id, &ts); +if (ret) +return ret; + +if (cobalt_put_timespec64 (&ts, u_ts)) +return -EFAULT ;return 0 ; } +COBALT_SYSCALL (clock_gettime64, current, + (clockid_t clock_id, struct __kernel_timespec __user *u_ts)) +{ +return __cobalt_clock_gettime64 (clock_id, u_ts); +} +int __cobalt_clock_settime (clockid_t clock_id,const struct timespec64 *ts) {int _ret, ret =0 ;
kernel/cobalt/posix/clock.h +6 -0
@@ -100,6 +100,9 @@ int __cobalt_clock_getres(clockid_t clock_id,int __cobalt_clock_gettime (clockid_t clock_id,struct timespec64 *ts); +int __cobalt_clock_gettime64 (clockid_t clock_id, +struct __kernel_timespec __user *u_ts); +int __cobalt_clock_settime (clockid_t clock_id,const struct timespec64 *ts);
@@ -116,6 +119,9 @@ COBALT_SYSCALL_DECL(clock_getres,COBALT_SYSCALL_DECL (clock_gettime, (clockid_t clock_id, struct __user_old_timespec __user *u_ts)); +COBALT_SYSCALL_DECL (clock_gettime64, + (clockid_t clock_id, struct __kernel_timespec __user *u_ts)); +COBALT_SYSCALL_DECL (clock_settime, (clockid_t clock_id, const struct __user_old_timespec __user *u_ts));
kernel/cobalt/posix/syscall32.c +8 -0
@@ -35,6 +35,7 @@#include "mqueue.h" #include "io.h" #include "../debug.h" +#include <cobalt/kernel/time.h> COBALT_SYSCALL32emu(thread_create, init, (compat_ulong_t pth,
@@ -170,6 +171,13 @@ COBALT_SYSCALL32emu(clock_gettime, current,return sys32_put_timespec (u_ts, &ts); } +COBALT_SYSCALL32emu (clock_gettime64, current, + (clockid_t clock_id, + struct __kernel_timespec __user *u_ts)) +{ +return __cobalt_clock_gettime64 (clock_id, u_ts); +} +COBALT_SYSCALL32emu (clock_settime, current, (clockid_t clock_id, const struct old_timespec32 __user *u_ts))
kernel/cobalt/posix/syscall32.h +4 -0
@@ -59,6 +59,10 @@ COBALT_SYSCALL32emu_DECL(clock_gettime, (clockid_t clock_id, struct old_timespec32 __user *u_ts)); +COBALT_SYSCALL32emu_DECL (clock_gettime64, + (clockid_t clock_id, + struct __kernel_timespec __user *u_ts)); +COBALT_SYSCALL32emu_DECL (clock_settime, (clockid_t clock_id, const struct old_timespec32 __user *u_ts));
kernel/cobalt/time.c +11 -0
@@ -27,3 +27,14 @@ int cobalt_get_timespec64(struct timespec64 *ts,return 0 ; } + +int cobalt_put_timespec64 (const struct timespec64 *ts, +struct __kernel_timespec __user *uts) +{ +struct __kernel_timespec kts = { + .tv_sec = ts->tv_sec, + .tv_nsec = ts->tv_nsec + }; + +return cobalt_copy_to_user (uts, &kts,sizeof (kts)) ? -EFAULT :0 ; +}
Signature · 1 line
2.7.4
Quoted 20 lines · Song Chen
From: chensong <[email protected]>
Add a syscall specific for
clock_gettimewith 64bittime_t.Signed-off-by chensong <[email protected]>---
v5:
1, new helper__cobalt_clock_gettime64
---include/cobalt/kernel/time.h | 11 +++++++++++ include/cobalt/uapi/syscall.h | 1 + kernel/cobalt/posix/clock.c | 23 ++++++++++++++++++++++- kernel/cobalt/posix/clock.h | 6 ++++++ kernel/cobalt/posix/syscall32.c | 8 ++++++++ kernel/cobalt/posix/syscall32.h | 4 ++++ kernel/cobalt/time.c | 11 +++++++++++ 7 files changed, 63 insertions(+), 1 deletion(-)
kernel/cobalt/posix/clock.c COBALT_SYSCALL(clock_gettime, current, · line 160
Quoted 4 lines
kernel/cobalt/posix/clock.c +4
-0+COBALT_SYSCALL (clock_gettime64, current, + (clockid_t clock_id, struct __kernel_timespec __user *u_ts)) +{ +return __cobalt_clock_gettime64 (clock_id, u_ts);
Whitespace at end of line! Will fix it up in my tree.
kernel/cobalt/posix/syscall32.c COBALT_SYSCALL32emu(clock_gettime, current, · line 178
Quoted 6 lines
kernel/cobalt/posix/syscall32.c +5
-0+COBALT_SYSCALL32emu (clock_gettime64, current, + (clockid_t clock_id, + struct __kernel_timespec __user *u_ts)) +{ +return __cobalt_clock_gettime64 (clock_id, u_ts);
WS at EOL again. Will fix it up in my tree.
Quoted 2 lines
+}
Quoted 21 lines · Florian
Quoted 20 lines · Song Chen
From: chensong <[email protected]>
Add a syscall specific for
clock_gettimewith 64bittime_t.Signed-off-by chensong <[email protected]>---
v5:
1, new helper__cobalt_clock_gettime64--- include/cobalt/kernel/time.h | 11 +++++++++++ include/cobalt/uapi/syscall.h | 1 + kernel/cobalt/posix/clock.c | 23 ++++++++++++++++++++++- kernel/cobalt/posix/clock.h | 6 ++++++ kernel/cobalt/posix/syscall32.c | 8 ++++++++ kernel/cobalt/posix/syscall32.h | 4 ++++ kernel/cobalt/time.c | 11 +++++++++++ 7 files changed, 63 insertions(+), 1 deletion(-)
Quoted 6 lines
kernel/cobalt/posix/clock.c COBALT_SYSCALL(clock_gettime, current, · line 160
Quoted 4 lines
kernel/cobalt/posix/clock.c +4
-0+COBALT_SYSCALL (clock_gettime64, current, + (clockid_t clock_id, struct __kernel_timespec __user *u_ts)) +{ +return __cobalt_clock_gettime64 (clock_id, u_ts);Whitespace at end of line! Will fix it up in my tree.
sorry, i did checkpatch each time, probably missed it this time. thanks for fixing it up.
Song
Quoted 14 lines
kernel/cobalt/posix/syscall32.c COBALT_SYSCALL32emu(clock_gettime, current, · line 178
Quoted 7 lines
kernel/cobalt/posix/syscall32.c +5
-0+COBALT_SYSCALL32emu (clock_gettime64, current, + (clockid_t clock_id, + struct __kernel_timespec __user *u_ts)) +{ +return __cobalt_clock_gettime64 (clock_id, u_ts);WS at EOL again. Will fix it up in my tree.
Quoted 2 lines
+}
Quoted 17 lines · Song Chen
From: chensong <[email protected]>
Add a syscall specific for
clock_gettimewith 64bittime_t.Signed-off-by chensong <[email protected]>include/cobalt/uapi/syscall.h +1
-0@@ -123,6 +123,7 @@ #define sc_cobalt_clock_adjtime 100 #define sc_cobalt_thread_setschedprio 101 #define sc_cobalt_sem_timedwait64 102 +#define sc_cobalt_clock_gettime64 103
Quoted 1 line
My fault didn't notice that during review but now while preparing the wiki stuff for being available inside the Xenomai hacker space:
The next syscall would be clock_getres64 instead of clock_gettime64