git: 783c1bd8cb0c - main - linux(4): Implement timer_gettime64 syscall.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 04 May 2022 10:08:09 UTC
The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=783c1bd8cb0cf02f2cfb95418b0a115ed975086a commit 783c1bd8cb0cf02f2cfb95418b0a115ed975086a Author: Dmitry Chagin <dchagin@FreeBSD.org> AuthorDate: 2022-05-04 10:06:48 +0000 Commit: Dmitry Chagin <dchagin@FreeBSD.org> CommitDate: 2022-05-04 10:06:48 +0000 linux(4): Implement timer_gettime64 syscall. MFC after: 2 weeks --- sys/amd64/linux32/linux32_dummy_machdep.c | 1 - sys/compat/linux/linux_time.c | 24 ++++++++++++++++++++++++ sys/compat/linux/linux_timer.c | 23 ++++++++++++++++++++--- sys/compat/linux/linux_timer.h | 14 ++++++++++++++ sys/i386/linux/linux_dummy_machdep.c | 1 - 5 files changed, 58 insertions(+), 5 deletions(-) diff --git a/sys/amd64/linux32/linux32_dummy_machdep.c b/sys/amd64/linux32/linux32_dummy_machdep.c index e14da5b74733..d6e4d89d573a 100644 --- a/sys/amd64/linux32/linux32_dummy_machdep.c +++ b/sys/amd64/linux32/linux32_dummy_machdep.c @@ -68,7 +68,6 @@ DUMMY(mq_getsetattr); DUMMY(arch_prctl); /* Linux 5.0: */ DUMMY(clock_adjtime64); -DUMMY(timer_gettime64); DUMMY(timer_settime64); DUMMY(timerfd_gettime64); DUMMY(timerfd_settime64); diff --git a/sys/compat/linux/linux_time.c b/sys/compat/linux/linux_time.c index 739480342ad9..447319a7edc9 100644 --- a/sys/compat/linux/linux_time.c +++ b/sys/compat/linux/linux_time.c @@ -196,6 +196,30 @@ linux_to_native_itimerspec(struct itimerspec *ntp, struct l_itimerspec *ltp) return (error); } +#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) +int +linux_to_native_itimerspec64(struct itimerspec *ntp, struct l_itimerspec64 *ltp) +{ + int error; + + error = linux_to_native_timespec64(&ntp->it_interval, <p->it_interval); + if (error == 0) + error = linux_to_native_timespec64(&ntp->it_value, <p->it_value); + return (error); +} + +int +native_to_linux_itimerspec64(struct l_itimerspec64 *ltp, struct itimerspec *ntp) +{ + int error; + + error = native_to_linux_timespec64(<p->it_interval, &ntp->it_interval); + if (error == 0) + error = native_to_linux_timespec64(<p->it_value, &ntp->it_value); + return (error); +} +#endif + int linux_to_native_clockid(clockid_t *n, clockid_t l) { diff --git a/sys/compat/linux/linux_timer.c b/sys/compat/linux/linux_timer.c index 4e1b56d4b2e2..83c099fbc800 100644 --- a/sys/compat/linux/linux_timer.c +++ b/sys/compat/linux/linux_timer.c @@ -146,13 +146,30 @@ linux_timer_gettime(struct thread *td, struct linux_timer_gettime_args *uap) int error; error = kern_ktimer_gettime(td, uap->timerid, &val); - if (error == 0) { - ITS_CP(val, l_val); + if (error == 0) + error = native_to_linux_itimerspec(&l_val, &val); + if (error == 0) error = copyout(&l_val, uap->setting, sizeof(l_val)); - } return (error); } +#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) +int +linux_timer_gettime64(struct thread *td, struct linux_timer_gettime64_args *uap) +{ + struct l_itimerspec64 l_val; + struct itimerspec val; + int error; + + error = kern_ktimer_gettime(td, uap->timerid, &val); + if (error == 0) + error = native_to_linux_itimerspec64(&l_val, &val); + if (error == 0) + error = copyout(&l_val, uap->setting, sizeof(l_val)); + return (error); +} +#endif + int linux_timer_getoverrun(struct thread *td, struct linux_timer_getoverrun_args *uap) { diff --git a/sys/compat/linux/linux_timer.h b/sys/compat/linux/linux_timer.h index 6b5cf346049e..7617316b09c6 100644 --- a/sys/compat/linux/linux_timer.h +++ b/sys/compat/linux/linux_timer.h @@ -104,6 +104,13 @@ struct l_itimerspec { struct l_timespec it_value; }; +#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) +struct l_itimerspec64 { + struct l_timespec64 it_interval; + struct l_timespec64 it_value; +}; +#endif + int native_to_linux_timespec(struct l_timespec *, struct timespec *); int linux_to_native_timespec(struct timespec *, @@ -119,6 +126,13 @@ int native_to_linux_itimerspec(struct l_itimerspec *, struct itimerspec *); int linux_to_native_itimerspec(struct itimerspec *, struct l_itimerspec *); +#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32)) +int native_to_linux_itimerspec64(struct l_itimerspec64 *, + struct itimerspec *); +int linux_to_native_itimerspec64(struct itimerspec *, + struct l_itimerspec64 *); +#endif + int linux_to_native_timerflags(int *, int); #endif /* _LINUX_TIMER_H */ diff --git a/sys/i386/linux/linux_dummy_machdep.c b/sys/i386/linux/linux_dummy_machdep.c index cbe945e00635..57edba56004f 100644 --- a/sys/i386/linux/linux_dummy_machdep.c +++ b/sys/i386/linux/linux_dummy_machdep.c @@ -70,7 +70,6 @@ DUMMY(vm86old); DUMMY(arch_prctl); /* Linux 5.0: */ DUMMY(clock_adjtime64); -DUMMY(timer_gettime64); DUMMY(timer_settime64); DUMMY(timerfd_gettime64); DUMMY(timerfd_settime64);