From a7dacef5abe44a69d8f8d3f79d753a984e59c17c Mon Sep 17 00:00:00 2001 From: kib Date: Sun, 21 Jul 2013 19:43:52 +0000 Subject: Implement compat32 wrappers for the ktimer_* syscalls. Reported, reviewed and tested by: Petr Salinger Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/compat/freebsd32/freebsd32.h | 9 +++++ sys/compat/freebsd32/freebsd32_misc.c | 64 +++++++++++++++++++++++++++++++++++ sys/compat/freebsd32/syscalls.master | 16 ++++++--- 3 files changed, 84 insertions(+), 5 deletions(-) (limited to 'sys/compat/freebsd32') diff --git a/sys/compat/freebsd32/freebsd32.h b/sys/compat/freebsd32/freebsd32.h index a95b0e5..9b04965 100644 --- a/sys/compat/freebsd32/freebsd32.h +++ b/sys/compat/freebsd32/freebsd32.h @@ -69,6 +69,15 @@ struct timespec32 { CP((src).fld,(dst).fld,tv_nsec); \ } while (0) +struct itimerspec32 { + struct timespec32 it_interval; + struct timespec32 it_value; +}; +#define ITS_CP(src, dst) do { \ + TS_CP((src), (dst), it_interval); \ + TS_CP((src), (dst), it_value); \ +} while (0) + struct rusage32 { struct timeval32 ru_utime; struct timeval32 ru_stime; diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c index 13d2bcb..4899e03 100644 --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -2331,6 +2331,70 @@ freebsd32_clock_getres(struct thread *td, return (error); } +int freebsd32_ktimer_create(struct thread *td, + struct freebsd32_ktimer_create_args *uap) +{ + struct sigevent32 ev32; + struct sigevent ev, *evp; + int error, id; + + if (uap->evp == NULL) { + evp = NULL; + } else { + evp = &ev; + error = copyin(uap->evp, &ev32, sizeof(ev32)); + if (error != 0) + return (error); + error = convert_sigevent32(&ev32, &ev); + if (error != 0) + return (error); + } + error = kern_ktimer_create(td, uap->clock_id, evp, &id, -1); + if (error == 0) { + error = copyout(&id, uap->timerid, sizeof(int)); + if (error != 0) + kern_ktimer_delete(td, id); + } + return (error); +} + +int +freebsd32_ktimer_settime(struct thread *td, + struct freebsd32_ktimer_settime_args *uap) +{ + struct itimerspec32 val32, oval32; + struct itimerspec val, oval, *ovalp; + int error; + + error = copyin(uap->value, &val32, sizeof(val32)); + if (error != 0) + return (error); + ITS_CP(val32, val); + ovalp = uap->ovalue != NULL ? &oval : NULL; + error = kern_ktimer_settime(td, uap->timerid, uap->flags, &val, ovalp); + if (error == 0 && uap->ovalue != NULL) { + ITS_CP(oval, oval32); + error = copyout(&oval32, uap->ovalue, sizeof(oval32)); + } + return (error); +} + +int +freebsd32_ktimer_gettime(struct thread *td, + struct freebsd32_ktimer_gettime_args *uap) +{ + struct itimerspec32 val32; + struct itimerspec val; + int error; + + error = kern_ktimer_gettime(td, uap->timerid, &val); + if (error == 0) { + ITS_CP(val, val32); + error = copyout(&val32, uap->value, sizeof(val32)); + } + return (error); +} + int freebsd32_clock_getcpuclockid2(struct thread *td, struct freebsd32_clock_getcpuclockid2_args *uap) diff --git a/sys/compat/freebsd32/syscalls.master b/sys/compat/freebsd32/syscalls.master index e058f6a..daee72c 100644 --- a/sys/compat/freebsd32/syscalls.master +++ b/sys/compat/freebsd32/syscalls.master @@ -441,11 +441,17 @@ const struct timespec32 *tp); } 234 AUE_NULL STD { int freebsd32_clock_getres(clockid_t clock_id, \ struct timespec32 *tp); } -235 AUE_NULL UNIMPL timer_create -236 AUE_NULL UNIMPL timer_delete -237 AUE_NULL UNIMPL timer_settime -238 AUE_NULL UNIMPL timer_gettime -239 AUE_NULL UNIMPL timer_getoverrun +235 AUE_NULL STD { int freebsd32_ktimer_create(\ + clockid_t clock_id, \ + struct sigevent32 *evp, int *timerid); } +236 AUE_NULL NOPROTO { int ktimer_delete(int timerid); } +237 AUE_NULL STD { int freebsd32_ktimer_settime(int timerid,\ + int flags, \ + const struct itimerspec32 *value, \ + struct itimerspec32 *ovalue); } +238 AUE_NULL STD { int freebsd32_ktimer_gettime(int timerid,\ + struct itimerspec32 *value); } +239 AUE_NULL NOPROTO { int ktimer_getoverrun(int timerid); } 240 AUE_NULL STD { int freebsd32_nanosleep( \ const struct timespec32 *rqtp, \ struct timespec32 *rmtp); } -- cgit v1.1