Source-Changes-HG archive

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

[src/trunk]: src/sys Add netbsd32_clock_getcpuclockid2 and netbsd32_wait6 fun...



details:   https://anonhg.NetBSD.org/src/rev/5cdcf11df2e9
branches:  trunk
changeset: 347923:5cdcf11df2e9
user:      skrll <skrll%NetBSD.org@localhost>
date:      Fri Sep 23 14:09:39 2016 +0000

description:
Add netbsd32_clock_getcpuclockid2 and netbsd32_wait6 functions

diffstat:

 sys/compat/netbsd32/netbsd32_time.c |  35 ++++++++++++++++-
 sys/compat/netbsd32/netbsd32_wait.c |  72 +++++++++++++++++++++++++++++++++++-
 sys/kern/kern_exit.c                |   6 +-
 sys/sys/proc.h                      |   6 ++-
 4 files changed, 111 insertions(+), 8 deletions(-)

diffs (200 lines):

diff -r b2375b757dc9 -r 5cdcf11df2e9 sys/compat/netbsd32/netbsd32_time.c
--- a/sys/compat/netbsd32/netbsd32_time.c       Fri Sep 23 13:31:33 2016 +0000
+++ b/sys/compat/netbsd32/netbsd32_time.c       Fri Sep 23 14:09:39 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_time.c,v 1.46 2015/10/31 17:04:39 njoly Exp $ */
+/*     $NetBSD: netbsd32_time.c,v 1.47 2016/09/23 14:09:39 skrll 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.46 2015/10/31 17:04:39 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_time.c,v 1.47 2016/09/23 14:09:39 skrll Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ntp.h"
@@ -566,3 +566,34 @@
        NETBSD32TO64_UAP(timerid);
        return sys_timer_getoverrun(l, (void *)&ua, retval);
 }
+
+int
+netbsd32_clock_getcpuclockid2(struct lwp *l,
+    const struct netbsd32_clock_getcpuclockid2_args *uap,
+    register_t *retval)
+{
+       /* {
+               syscallarg(idtype_t) idtype;
+               syscallarg(id_t) id;
+               syscallarg(netbsd32_clockidp_t) clock_id;
+       } */
+       pid_t pid;
+       lwpid_t lid;
+       clockid_t clock_id;
+       id_t id = SCARG(uap, id);
+
+       switch (SCARG(uap, idtype)) {
+       case P_PID:
+               pid = id == 0 ? l->l_proc->p_pid : id;
+               clock_id = CLOCK_PROCESS_CPUTIME_ID | pid;
+               break;
+       case P_LWPID:
+               lid = id == 0 ? l->l_lid : id;
+               clock_id = CLOCK_THREAD_CPUTIME_ID | lid;
+               break;
+       default:
+               return EINVAL;
+       }
+       return copyout(&clock_id, SCARG_P32(uap, clock_id), sizeof(clock_id));
+}
+
diff -r b2375b757dc9 -r 5cdcf11df2e9 sys/compat/netbsd32/netbsd32_wait.c
--- a/sys/compat/netbsd32/netbsd32_wait.c       Fri Sep 23 13:31:33 2016 +0000
+++ b/sys/compat/netbsd32/netbsd32_wait.c       Fri Sep 23 14:09:39 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_wait.c,v 1.22 2012/11/03 23:22:22 njoly Exp $ */
+/*     $NetBSD: netbsd32_wait.c,v 1.23 2016/09/23 14:09:39 skrll Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_wait.c,v 1.22 2012/11/03 23:22:22 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_wait.c,v 1.23 2016/09/23 14:09:39 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -77,6 +77,74 @@
        return error;
 }
 
+int
+netbsd32_wait6(struct lwp *l, const struct netbsd32_wait6_args *uap,
+    register_t *retval)
+{
+       /* {
+               syscallarg(idtype_t) idtype;
+               syscallarg(id_t) id;
+               syscallarg(netbsd32_intp) status;
+               syscallarg(int) options;
+               syscallarg(netbsd32_wrusagep_t) wru;
+               syscallarg(netbsd32_siginfop_t) info;
+       } */
+       idtype_t idtype = SCARG(uap, idtype);
+       id_t id = SCARG(uap, id);
+       struct wrusage wru, *wrup;
+       siginfo_t si, *sip;
+       int status;
+       int pid;
+
+       if (SCARG_P32(uap, wru) != NULL)
+               wrup = &wru;
+       else
+               wrup = NULL;
+
+       if (SCARG_P32(uap, info) != NULL)
+               sip = &si;
+       else
+               sip = NULL;
+
+       /*
+        *  We expect all callers of wait6() to know about WEXITED and
+        *  WTRAPPED.
+        */
+       int error = do_sys_waitid(idtype, id, &pid, &status,
+           SCARG(uap, options), wrup, sip);
+
+       retval[0] = pid;        /* tell userland who it was */
+
+#if 0
+       /*
+        * should we copyout if there was no process, hence no useful data?
+        * We don't for an old sytle wait4() (etc) but I believe
+        * FreeBSD does for wait6(), so a tossup...  Go with FreeBSD for now.
+        */
+       if (pid == 0)
+               return error;
+#endif
+
+
+       if (error == 0 && SCARG_P32(uap, status))
+               error = copyout(&status, SCARG_P32(uap, status),
+                   sizeof(status));
+       if (wrup != NULL && error == 0) {
+               struct netbsd32_wrusage wru32;
+
+               netbsd32_from_rusage(&wrup->wru_self, &wru32.wru_self);
+               netbsd32_from_rusage(&wrup->wru_children, &wru32.wru_children);
+               error = copyout(&wru32, SCARG_P32(uap, wru), sizeof(wru32));
+       }
+       if (sip != NULL && error == 0) {
+               siginfo32_t si32;
+
+               netbsd32_si_to_si32(&si32, sip);
+               error = copyout(&si32, SCARG_P32(uap, info), sizeof(si32));
+       }
+
+       return error;
+}
 
 int
 netbsd32___getrusage50(struct lwp *l,
diff -r b2375b757dc9 -r 5cdcf11df2e9 sys/kern/kern_exit.c
--- a/sys/kern/kern_exit.c      Fri Sep 23 13:31:33 2016 +0000
+++ b/sys/kern/kern_exit.c      Fri Sep 23 14:09:39 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_exit.c,v 1.258 2016/04/27 21:15:40 christos Exp $ */
+/*     $NetBSD: kern_exit.c,v 1.259 2016/09/23 14:09:39 skrll Exp $    */
 
 /*-
  * Copyright (c) 1998, 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.258 2016/04/27 21:15:40 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.259 2016/09/23 14:09:39 skrll Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_dtrace.h"
@@ -651,7 +651,7 @@
        KASSERT(p->p_nlwps == 1);
 }
 
-static int
+int
 do_sys_waitid(idtype_t idtype, id_t id, int *pid, int *status, int options,
     struct wrusage *wru, siginfo_t *si)
 {
diff -r b2375b757dc9 -r 5cdcf11df2e9 sys/sys/proc.h
--- a/sys/sys/proc.h    Fri Sep 23 13:31:33 2016 +0000
+++ b/sys/sys/proc.h    Fri Sep 23 14:09:39 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: proc.h,v 1.332 2016/09/13 07:39:45 martin Exp $        */
+/*     $NetBSD: proc.h,v 1.333 2016/09/23 14:09:39 skrll Exp $ */
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -81,6 +81,7 @@
 #include <machine/proc.h>              /* Machine-dependent proc substruct */
 #include <machine/pcb.h>
 #include <sys/aio.h>
+#include <sys/idtype.h>
 #include <sys/rwlock.h>
 #include <sys/mqueue.h>
 #include <sys/mutex.h>
@@ -500,6 +501,9 @@
 void   exit1(struct lwp *, int, int) __dead;
 int    kill1(struct lwp *l, pid_t pid, ksiginfo_t *ksi, register_t *retval);
 int    do_sys_wait(int *, int *, int, struct rusage *);
+int    do_sys_waitid(idtype_t, id_t, int *, int *, int, struct wrusage *,
+           siginfo_t *);
+
 struct proc *proc_alloc(void);
 void   proc0_init(void);
 pid_t  proc_alloc_pid(struct proc *);



Home | Main Index | Thread Index | Old Index