diff options
author | Dmitry Chagin <dchagin@FreeBSD.org> | 2022-05-04 10:06:48 +0000 |
---|---|---|
committer | Dmitry Chagin <dchagin@FreeBSD.org> | 2022-06-17 19:34:21 +0000 |
commit | da266f693ccc7ce7fe2da97866a031982ee5581a (patch) | |
tree | a8d5f027194676f0b0d6f9a02dad1d56e2b39152 /sys/compat/linux | |
parent | ff95f72deece477ab31e0ec59cd1ca846d26afdc (diff) | |
download | src-da266f693ccc7ce7fe2da97866a031982ee5581a.tar.gz src-da266f693ccc7ce7fe2da97866a031982ee5581a.zip |
linux(4): Implement timer_gettime64 syscall.
MFC after: 2 weeks
(cherry picked from commit 783c1bd8cb0cf02f2cfb95418b0a115ed975086a)
Diffstat (limited to 'sys/compat/linux')
-rw-r--r-- | sys/compat/linux/linux_time.c | 24 | ||||
-rw-r--r-- | sys/compat/linux/linux_timer.c | 23 | ||||
-rw-r--r-- | sys/compat/linux/linux_timer.h | 14 |
3 files changed, 58 insertions, 3 deletions
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 */ |