Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/netbsd32 Add timerfd system calls to COMPAT_NETBS...



details:   https://anonhg.NetBSD.org/src/rev/09eb4ee0834c
branches:  trunk
changeset: 986332:09eb4ee0834c
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon Sep 20 01:00:55 2021 +0000

description:
Add timerfd system calls to COMPAT_NETBSD32.

diffstat:

 sys/compat/netbsd32/netbsd32_time.c |  83 ++++++++++++++++++++++++++++++++++++-
 sys/compat/netbsd32/syscalls.master |  13 ++++-
 2 files changed, 90 insertions(+), 6 deletions(-)

diffs (138 lines):

diff -r c15d15139459 -r 09eb4ee0834c sys/compat/netbsd32/netbsd32_time.c
--- a/sys/compat/netbsd32/netbsd32_time.c       Mon Sep 20 00:09:33 2021 +0000
+++ b/sys/compat/netbsd32/netbsd32_time.c       Mon Sep 20 01:00:55 2021 +0000
@@ -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 @@
 #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 @@
 }
 
 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)
diff -r c15d15139459 -r 09eb4ee0834c sys/compat/netbsd32/syscalls.master
--- a/sys/compat/netbsd32/syscalls.master       Mon Sep 20 00:09:33 2021 +0000
+++ b/sys/compat/netbsd32/syscalls.master       Mon Sep 20 01:00:55 2021 +0000
@@ -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



Home | Main Index | Thread Index | Old Index