Module Name: src Committed By: thorpej Date: Mon Sep 20 01:00:55 UTC 2021
Modified Files: src/sys/compat/netbsd32: netbsd32_time.c syscalls.master Log Message: Add timerfd system calls to COMPAT_NETBSD32. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/sys/compat/netbsd32/netbsd32_time.c cvs rdiff -u -r1.139 -r1.140 src/sys/compat/netbsd32/syscalls.master Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/compat/netbsd32/netbsd32_time.c diff -u src/sys/compat/netbsd32/netbsd32_time.c:1.56 src/sys/compat/netbsd32/netbsd32_time.c:1.57 --- src/sys/compat/netbsd32/netbsd32_time.c:1.56 Tue Sep 7 11:43:05 2021 +++ src/sys/compat/netbsd32/netbsd32_time.c Mon Sep 20 01:00:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_time.c,v 1.56 2021/09/07 11:43:05 riastradh Exp $ */ +/* $NetBSD: netbsd32_time.c,v 1.57 2021/09/20 01:00:55 thorpej Exp $ */ /* * Copyright (c) 1998, 2001 Matthew R. Green @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: netbsd32_time.c,v 1.56 2021/09/07 11:43:05 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netbsd32_time.c,v 1.57 2021/09/20 01:00:55 thorpej Exp $"); #if defined(_KERNEL_OPT) #include "opt_ntp.h" @@ -38,6 +38,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_tim #include <sys/systm.h> #include <sys/mount.h> #include <sys/time.h> +#include <sys/timerfd.h> #include <sys/timex.h> #include <sys/timevar.h> #include <sys/proc.h> @@ -524,6 +525,84 @@ netbsd32_timer_getoverrun(struct lwp *l, } int +netbsd32_timerfd_create(struct lwp *l, + const struct netbsd32_timerfd_create_args *uap, register_t *retval) +{ + /* { + syscallarg(netbsd32_clockid_t) clock_id; + syscallarg(int) flags; + } */ + struct sys_timerfd_create_args ua; + + NETBSD32TO64_UAP(clock_id); + NETBSD32TO64_UAP(flags); + return sys_timerfd_create(l, (void *)&ua, retval); +} + +int +netbsd32_timerfd_settime(struct lwp *l, + const struct netbsd32_timerfd_settime_args *uap, register_t *retval) +{ + /* { + syscallarg(int) fd; + syscallarg(int) flags; + syscallarg(const netbsd32_itimerspecp_t) new_value; + syscallarg(netbsd32_itimerspecp_t) old_value; + } */ + struct itimerspec its, oits, *oitsp = NULL; + struct netbsd32_itimerspec its32; + int error; + + if ((error = copyin(SCARG_P32(uap, new_value), &its32, + sizeof(its32))) != 0) { + return error; + } + netbsd32_to_timespec(&its32.it_interval, &its.it_interval); + netbsd32_to_timespec(&its32.it_value, &its.it_value); + + if (SCARG_P32(uap, old_value)) { + oitsp = &oits; + } + + error = do_timerfd_settime(l, SCARG(uap, fd), SCARG(uap, flags), + &its, oitsp, retval); + if (error == 0 && oitsp != NULL) { + memset(&its32, 0, sizeof(its32)); + netbsd32_from_timespec(&oitsp->it_interval, &its32.it_interval); + netbsd32_from_timespec(&oitsp->it_value, &its32.it_value); + error = copyout(&its32, SCARG_P32(uap, old_value), + sizeof(its32)); + } + + return error; +} + +int +netbsd32_timerfd_gettime(struct lwp *l, + const struct netbsd32_timerfd_gettime_args *uap, register_t *retval) +{ + /* { + syscallarg(int) fd; + syscallarg(int) flags; + syscallarg(netbsd32_itimerspecp_t) curr_value; + } */ + int error; + struct itimerspec its; + struct netbsd32_itimerspec its32; + + error = do_timerfd_gettime(l, SCARG(uap, fd), &its, retval); + if (error == 0) { + memset(&its32, 0, sizeof(its32)); + netbsd32_from_timespec(&its.it_interval, &its32.it_interval); + netbsd32_from_timespec(&its.it_value, &its32.it_value); + error = copyout(&its32, SCARG_P32(uap, curr_value), + sizeof(its32)); + } + + return error; +} + +int netbsd32_clock_getcpuclockid2(struct lwp *l, const struct netbsd32_clock_getcpuclockid2_args *uap, register_t *retval) Index: src/sys/compat/netbsd32/syscalls.master diff -u src/sys/compat/netbsd32/syscalls.master:1.139 src/sys/compat/netbsd32/syscalls.master:1.140 --- src/sys/compat/netbsd32/syscalls.master:1.139 Sat Oct 10 00:00:54 2020 +++ src/sys/compat/netbsd32/syscalls.master Mon Sep 20 01:00:55 2021 @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.139 2020/10/10 00:00:54 rin Exp $ + $NetBSD: syscalls.master,v 1.140 2021/09/20 01:00:55 thorpej Exp $ ; from: NetBSD: syscalls.master,v 1.81 1998/07/05 08:49:50 jonathan Exp ; @(#)syscalls.master 8.2 (Berkeley) 1/13/94 @@ -431,9 +431,14 @@ #else 176 EXCL ntp_adjtime #endif -177 UNIMPL -178 UNIMPL -179 UNIMPL +177 STD { int|netbsd32||timerfd_create( \ + netbsd32_clockid_t clock_id, \ + int flags); } +178 STD { int|netbsd32||timerfd_settime(int fd, int flags, \ + const netbsd32_itimerspecp_t new_value, \ + netbsd32_itimerspecp_t old_value); } +179 STD { int|netbsd32||timerfd_gettime(int fd, \ + netbsd32_itimerspecp_t curr_value); } 180 UNIMPL ; Syscalls 180-199 are used by/reserved for BSD