linux(4): Implement timer_gettime64 syscall.

MFC after:		2 weeks
This commit is contained in:
Dmitry Chagin 2022-05-04 13:06:48 +03:00
parent 1cccef6dff
commit 783c1bd8cb
5 changed files with 58 additions and 5 deletions

View file

@ -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);

View file

@ -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, &ltp->it_interval);
if (error == 0)
error = linux_to_native_timespec64(&ntp->it_value, &ltp->it_value);
return (error);
}
int
native_to_linux_itimerspec64(struct l_itimerspec64 *ltp, struct itimerspec *ntp)
{
int error;
error = native_to_linux_timespec64(&ltp->it_interval, &ntp->it_interval);
if (error == 0)
error = native_to_linux_timespec64(&ltp->it_value, &ntp->it_value);
return (error);
}
#endif
int
linux_to_native_clockid(clockid_t *n, clockid_t l)
{

View file

@ -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)
{

View file

@ -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 */

View file

@ -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);