mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-21 18:27:22 +00:00
timerfd: Relocate 32-bit compat code
32-bit compatibility code is conventionally stored in sys/compat/freebsd32. Move freebsd32_timerfd_gettime() and freebsd32_timerfd_settime() from sys/kern/sys_timerfd.c to sys/compat/freebsd32/freebsd32_misc.c. MFC After: 3 days Reviewed by: imp, markj Differential Revision; https://reviews.freebsd.org/D41640
This commit is contained in:
parent
fb5daae920
commit
918966a274
|
@ -82,6 +82,7 @@
|
|||
#include <sys/sysproto.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/thr.h>
|
||||
#include <sys/timerfd.h>
|
||||
#include <sys/timex.h>
|
||||
#include <sys/unistd.h>
|
||||
#include <sys/ucontext.h>
|
||||
|
@ -3138,6 +3139,60 @@ freebsd32_ktimer_gettime(struct thread *td,
|
|||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
freebsd32_timerfd_gettime(struct thread *td,
|
||||
struct freebsd32_timerfd_gettime_args *uap)
|
||||
{
|
||||
struct itimerspec curr_value;
|
||||
struct itimerspec32 curr_value32;
|
||||
int error;
|
||||
|
||||
error = kern_timerfd_gettime(td, uap->fd, &curr_value);
|
||||
if (error == 0) {
|
||||
CP(curr_value, curr_value32, it_value.tv_sec);
|
||||
CP(curr_value, curr_value32, it_value.tv_nsec);
|
||||
CP(curr_value, curr_value32, it_interval.tv_sec);
|
||||
CP(curr_value, curr_value32, it_interval.tv_nsec);
|
||||
error = copyout(&curr_value32, uap->curr_value,
|
||||
sizeof(curr_value32));
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
freebsd32_timerfd_settime(struct thread *td,
|
||||
struct freebsd32_timerfd_settime_args *uap)
|
||||
{
|
||||
struct itimerspec new_value, old_value;
|
||||
struct itimerspec32 new_value32, old_value32;
|
||||
int error;
|
||||
|
||||
error = copyin(uap->new_value, &new_value32, sizeof(new_value32));
|
||||
if (error != 0)
|
||||
return (error);
|
||||
CP(new_value32, new_value, it_value.tv_sec);
|
||||
CP(new_value32, new_value, it_value.tv_nsec);
|
||||
CP(new_value32, new_value, it_interval.tv_sec);
|
||||
CP(new_value32, new_value, it_interval.tv_nsec);
|
||||
if (uap->old_value == NULL) {
|
||||
error = kern_timerfd_settime(td, uap->fd, uap->flags,
|
||||
&new_value, NULL);
|
||||
} else {
|
||||
error = kern_timerfd_settime(td, uap->fd, uap->flags,
|
||||
&new_value, &old_value);
|
||||
if (error == 0) {
|
||||
CP(old_value, old_value32, it_value.tv_sec);
|
||||
CP(old_value, old_value32, it_value.tv_nsec);
|
||||
CP(old_value, old_value32, it_interval.tv_sec);
|
||||
CP(old_value, old_value32, it_interval.tv_nsec);
|
||||
error = copyout(&old_value32, uap->old_value,
|
||||
sizeof(old_value32));
|
||||
}
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
freebsd32_clock_getcpuclockid2(struct thread *td,
|
||||
struct freebsd32_clock_getcpuclockid2_args *uap)
|
||||
|
|
|
@ -54,11 +54,6 @@
|
|||
|
||||
#include <security/audit/audit.h>
|
||||
|
||||
#ifdef COMPAT_FREEBSD32
|
||||
#include <compat/freebsd32/freebsd32.h>
|
||||
#include <compat/freebsd32/freebsd32_proto.h>
|
||||
#endif
|
||||
|
||||
static MALLOC_DEFINE(M_TIMERFD, "timerfd", "timerfd structures");
|
||||
|
||||
static struct mtx timerfd_list_lock;
|
||||
|
@ -598,59 +593,3 @@ sys_timerfd_settime(struct thread *td, struct timerfd_settime_args *uap)
|
|||
}
|
||||
return (error);
|
||||
}
|
||||
|
||||
#ifdef COMPAT_FREEBSD32
|
||||
int
|
||||
freebsd32_timerfd_gettime(struct thread *td,
|
||||
struct freebsd32_timerfd_gettime_args *uap)
|
||||
{
|
||||
struct itimerspec curr_value;
|
||||
struct itimerspec32 curr_value32;
|
||||
int error;
|
||||
|
||||
error = kern_timerfd_gettime(td, uap->fd, &curr_value);
|
||||
if (error == 0) {
|
||||
CP(curr_value, curr_value32, it_value.tv_sec);
|
||||
CP(curr_value, curr_value32, it_value.tv_nsec);
|
||||
CP(curr_value, curr_value32, it_interval.tv_sec);
|
||||
CP(curr_value, curr_value32, it_interval.tv_nsec);
|
||||
error = copyout(&curr_value32, uap->curr_value,
|
||||
sizeof(curr_value32));
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
freebsd32_timerfd_settime(struct thread *td,
|
||||
struct freebsd32_timerfd_settime_args *uap)
|
||||
{
|
||||
struct itimerspec new_value, old_value;
|
||||
struct itimerspec32 new_value32, old_value32;
|
||||
int error;
|
||||
|
||||
error = copyin(uap->new_value, &new_value32, sizeof(new_value32));
|
||||
if (error != 0)
|
||||
return (error);
|
||||
CP(new_value32, new_value, it_value.tv_sec);
|
||||
CP(new_value32, new_value, it_value.tv_nsec);
|
||||
CP(new_value32, new_value, it_interval.tv_sec);
|
||||
CP(new_value32, new_value, it_interval.tv_nsec);
|
||||
if (uap->old_value == NULL) {
|
||||
error = kern_timerfd_settime(td, uap->fd, uap->flags,
|
||||
&new_value, NULL);
|
||||
} else {
|
||||
error = kern_timerfd_settime(td, uap->fd, uap->flags,
|
||||
&new_value, &old_value);
|
||||
if (error == 0) {
|
||||
CP(old_value, old_value32, it_value.tv_sec);
|
||||
CP(old_value, old_value32, it_value.tv_nsec);
|
||||
CP(old_value, old_value32, it_interval.tv_sec);
|
||||
CP(old_value, old_value32, it_interval.tv_nsec);
|
||||
error = copyout(&old_value32, uap->old_value,
|
||||
sizeof(old_value32));
|
||||
}
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue