* [PATCH 1/3] y2038: cobalt/posix/clock: Adding clock_nanosleep64
@ 2021-03-31 3:26 chensong
2021-04-07 10:25 ` florian.bezdeka
0 siblings, 1 reply; 2+ messages in thread
From: chensong @ 2021-03-31 3:26 UTC (permalink / raw)
To: florian.bezdeka, xenomai, rpm
Add a syscall specific for clock_nanosleep with 64bit
time_t.
Signed-off-by: chensong <chensong@tj.kylinos.cn>
---
include/cobalt/uapi/syscall.h | 1 +
kernel/cobalt/posix/clock.c | 23 +++++++++++++++++++++++
kernel/cobalt/posix/clock.h | 5 +++++
kernel/cobalt/posix/syscall32.c | 23 +++++++++++++++++++++++
kernel/cobalt/posix/syscall32.h | 6 ++++++
5 files changed, 58 insertions(+)
diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
index 438af30..acb8260 100644
--- a/include/cobalt/uapi/syscall.h
+++ b/include/cobalt/uapi/syscall.h
@@ -125,6 +125,7 @@
#define sc_cobalt_sem_timedwait64 102
#define sc_cobalt_clock_gettime64 103
#define sc_cobalt_clock_settime64 104
+#define sc_cobalt_clock_nanosleep64 105
#define __NR_COBALT_SYSCALLS 128 /* Power of 2 */
diff --git a/kernel/cobalt/posix/clock.c b/kernel/cobalt/posix/clock.c
index f0f9fb4..5be89ad 100644
--- a/kernel/cobalt/posix/clock.c
+++ b/kernel/cobalt/posix/clock.c
@@ -338,6 +338,29 @@ COBALT_SYSCALL(clock_nanosleep, primary,
return ret;
}
+COBALT_SYSCALL(clock_nanosleep64, primary,
+ (clockid_t clock_id, int flags,
+ const struct __kernel_timespec __user *u_rqt,
+ struct __kernel_timespec __user *u_rmt))
+{
+ struct timespec64 rqt, rmt, *rmtp = NULL;
+ int ret;
+
+ if (u_rmt)
+ rmtp = &rmt;
+
+ if (cobalt_get_timespec64(&rqt, u_rqt))
+ return -EFAULT;
+
+ ret = __cobalt_clock_nanosleep(clock_id, flags, &rqt, rmtp);
+ if (ret == -EINTR && flags == 0 && rmtp) {
+ if (cobalt_put_timespec64(rmtp, u_rmt))
+ return -EFAULT;
+ }
+
+ return ret;
+}
+
int cobalt_clock_register(struct xnclock *clock, const cpumask_t *affinity,
clockid_t *clk_id)
{
diff --git a/kernel/cobalt/posix/clock.h b/kernel/cobalt/posix/clock.h
index fa07c56..f248578 100644
--- a/kernel/cobalt/posix/clock.h
+++ b/kernel/cobalt/posix/clock.h
@@ -134,6 +134,11 @@ COBALT_SYSCALL_DECL(clock_nanosleep,
const struct __user_old_timespec __user *u_rqt,
struct __user_old_timespec __user *u_rmt));
+COBALT_SYSCALL_DECL(clock_nanosleep64,
+ (clockid_t clock_id, int flags,
+ const struct __kernel_timespec __user *u_rqt,
+ struct __kernel_timespec __user *u_rmt));
+
int cobalt_clock_register(struct xnclock *clock,
const cpumask_t *affinity,
clockid_t *clk_id);
diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c
index 1a1b830..eb83c57 100644
--- a/kernel/cobalt/posix/syscall32.c
+++ b/kernel/cobalt/posix/syscall32.c
@@ -250,6 +250,29 @@ COBALT_SYSCALL32emu(clock_nanosleep, nonrestartable,
return ret;
}
+COBALT_SYSCALL32emu(clock_nanosleep64, nonrestartable,
+ (clockid_t clock_id, int flags,
+ const struct __kernel_timespec __user *u_rqt,
+ struct __kernel_timespec __user *u_rmt))
+{
+ struct timespec64 rqt, rmt, *rmtp = NULL;
+ int ret;
+
+ if (u_rmt)
+ rmtp = &rmt;
+
+ ret = cobalt_get_timespec64(&rqt, u_rqt);
+ if (ret)
+ return ret;
+
+ ret = __cobalt_clock_nanosleep(clock_id, flags, &rqt, rmtp);
+ if (ret == -EINTR && flags == 0 && rmtp)
+ ret = cobalt_put_timespec64(rmtp, u_rmt);
+
+ return ret;
+}
+
+
COBALT_SYSCALL32emu(mutex_timedlock, primary,
(struct cobalt_mutex_shadow __user *u_mx,
const struct old_timespec32 __user *u_ts))
diff --git a/kernel/cobalt/posix/syscall32.h b/kernel/cobalt/posix/syscall32.h
index 9095ebd..6c20da1 100644
--- a/kernel/cobalt/posix/syscall32.h
+++ b/kernel/cobalt/posix/syscall32.h
@@ -80,6 +80,12 @@ COBALT_SYSCALL32emu_DECL(clock_nanosleep,
const struct old_timespec32 __user *u_rqt,
struct old_timespec32 __user *u_rmt));
+COBALT_SYSCALL32emu_DECL(clock_nanosleep64,
+ (clockid_t clock_id, int flags,
+ const struct __kernel_timespec __user *u_rqt,
+ struct __kernel_timespec __user *u_rmt));
+
+
COBALT_SYSCALL32emu_DECL(mutex_timedlock,
(struct cobalt_mutex_shadow __user *u_mx,
const struct old_timespec32 __user *u_ts));
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/3] y2038: cobalt/posix/clock: Adding clock_nanosleep64
2021-03-31 3:26 [PATCH 1/3] y2038: cobalt/posix/clock: Adding clock_nanosleep64 chensong
@ 2021-04-07 10:25 ` florian.bezdeka
0 siblings, 0 replies; 2+ messages in thread
From: florian.bezdeka @ 2021-04-07 10:25 UTC (permalink / raw)
To: rpm, xenomai, chensong
On Wed, 2021-03-31 at 11:26 +0800, chensong wrote:
> Add a syscall specific for clock_nanosleep with 64bit
> time_t.
>
> Signed-off-by: chensong <chensong@tj.kylinos.cn>
> ---
> include/cobalt/uapi/syscall.h | 1 +
> kernel/cobalt/posix/clock.c | 23 +++++++++++++++++++++++
> kernel/cobalt/posix/clock.h | 5 +++++
> kernel/cobalt/posix/syscall32.c | 23 +++++++++++++++++++++++
> kernel/cobalt/posix/syscall32.h | 6 ++++++
> 5 files changed, 58 insertions(+)
>
> diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
> index 438af30..acb8260 100644
> --- a/include/cobalt/uapi/syscall.h
> +++ b/include/cobalt/uapi/syscall.h
> @@ -125,6 +125,7 @@
> #define sc_cobalt_sem_timedwait64 102
> #define sc_cobalt_clock_gettime64 103
> #define sc_cobalt_clock_settime64 104
> +#define sc_cobalt_clock_nanosleep64 105
>
>
> #define __NR_COBALT_SYSCALLS 128 /* Power of 2 */
>
> diff --git a/kernel/cobalt/posix/clock.c b/kernel/cobalt/posix/clock.c
> index f0f9fb4..5be89ad 100644
> --- a/kernel/cobalt/posix/clock.c
> +++ b/kernel/cobalt/posix/clock.c
> @@ -338,6 +338,29 @@ COBALT_SYSCALL(clock_nanosleep, primary,
> return ret;
> }
>
> +COBALT_SYSCALL(clock_nanosleep64, primary,
> + (clockid_t clock_id, int flags,
> + const struct __kernel_timespec __user *u_rqt,
> + struct __kernel_timespec __user *u_rmt))
> +{
> + struct timespec64 rqt, rmt, *rmtp = NULL;
> + int ret;
> +
> + if (u_rmt)
> + rmtp = &rmt;
> +
> + if (cobalt_get_timespec64(&rqt, u_rqt))
> + return -EFAULT;
> +
> + ret = __cobalt_clock_nanosleep(clock_id, flags, &rqt, rmtp);
> + if (ret == -EINTR && flags == 0 && rmtp) {
> + if (cobalt_put_timespec64(rmtp, u_rmt))
> + return -EFAULT;
> + }
> +
> + return ret;
> +}
The compat syscall looks exactly the same. So I would vote for moving
the code into a separate function (maybe called
__cobalt_clock_nanosleep64) which holds the code above and calling it
from both syscall handlers (this one + the compat one below).
> +
> int cobalt_clock_register(struct xnclock *clock, const cpumask_t *affinity,
> clockid_t *clk_id)
> {
> diff --git a/kernel/cobalt/posix/clock.h b/kernel/cobalt/posix/clock.h
> index fa07c56..f248578 100644
> --- a/kernel/cobalt/posix/clock.h
> +++ b/kernel/cobalt/posix/clock.h
> @@ -134,6 +134,11 @@ COBALT_SYSCALL_DECL(clock_nanosleep,
> const struct __user_old_timespec __user *u_rqt,
> struct __user_old_timespec __user *u_rmt));
> +COBALT_SYSCALL_DECL(clock_nanosleep64,
> + (clockid_t clock_id, int flags,
> + const struct __kernel_timespec __user *u_rqt,
> + struct __kernel_timespec __user *u_rmt));
> +
> int cobalt_clock_register(struct xnclock *clock,
> const cpumask_t *affinity,
> clockid_t *clk_id);
> diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c
> index 1a1b830..eb83c57 100644
> --- a/kernel/cobalt/posix/syscall32.c
> +++ b/kernel/cobalt/posix/syscall32.c
> @@ -250,6 +250,29 @@ COBALT_SYSCALL32emu(clock_nanosleep, nonrestartable,
> return ret;
> }
>
> +COBALT_SYSCALL32emu(clock_nanosleep64, nonrestartable,
> + (clockid_t clock_id, int flags,
> + const struct __kernel_timespec __user *u_rqt,
> + struct __kernel_timespec __user *u_rmt))
> +{
> + struct timespec64 rqt, rmt, *rmtp = NULL;
> + int ret;
> +
> + if (u_rmt)
> + rmtp = &rmt;
> +
> + ret = cobalt_get_timespec64(&rqt, u_rqt);
> + if (ret)
> + return ret;
> +
> + ret = __cobalt_clock_nanosleep(clock_id, flags, &rqt, rmtp);
> + if (ret == -EINTR && flags == 0 && rmtp)
> + ret = cobalt_put_timespec64(rmtp, u_rmt);
> +
> + return ret;
> +}
> +
> +
> COBALT_SYSCALL32emu(mutex_timedlock, primary,
> (struct cobalt_mutex_shadow __user *u_mx,
> const struct old_timespec32 __user *u_ts))
> diff --git a/kernel/cobalt/posix/syscall32.h b/kernel/cobalt/posix/syscall32.h
> index 9095ebd..6c20da1 100644
> --- a/kernel/cobalt/posix/syscall32.h
> +++ b/kernel/cobalt/posix/syscall32.h
> @@ -80,6 +80,12 @@ COBALT_SYSCALL32emu_DECL(clock_nanosleep,
> const struct old_timespec32 __user *u_rqt,
> struct old_timespec32 __user *u_rmt));
> +COBALT_SYSCALL32emu_DECL(clock_nanosleep64,
> + (clockid_t clock_id, int flags,
> + const struct __kernel_timespec __user *u_rqt,
> + struct __kernel_timespec __user *u_rmt));
> +
> +
> COBALT_SYSCALL32emu_DECL(mutex_timedlock,
> (struct cobalt_mutex_shadow __user *u_mx,
> const struct old_timespec32 __user *u_ts));
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-07 10:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31 3:26 [PATCH 1/3] y2038: cobalt/posix/clock: Adding clock_nanosleep64 chensong
2021-04-07 10:25 ` florian.bezdeka
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.