Module Name: src Committed By: skrll Date: Fri Sep 23 14:09:39 UTC 2016
Modified Files: src/sys/compat/netbsd32: netbsd32_time.c netbsd32_wait.c src/sys/kern: kern_exit.c src/sys/sys: proc.h Log Message: Add netbsd32_clock_getcpuclockid2 and netbsd32_wait6 functions To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/compat/netbsd32/netbsd32_time.c cvs rdiff -u -r1.22 -r1.23 src/sys/compat/netbsd32/netbsd32_wait.c cvs rdiff -u -r1.258 -r1.259 src/sys/kern/kern_exit.c cvs rdiff -u -r1.332 -r1.333 src/sys/sys/proc.h 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.46 src/sys/compat/netbsd32/netbsd32_time.c:1.47 --- src/sys/compat/netbsd32/netbsd32_time.c:1.46 Sat Oct 31 17:04:39 2015 +++ src/sys/compat/netbsd32/netbsd32_time.c Fri Sep 23 14:09:39 2016 @@ -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 @@ netbsd32_timer_getoverrun(struct lwp *l, 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)); +} + Index: src/sys/compat/netbsd32/netbsd32_wait.c diff -u src/sys/compat/netbsd32/netbsd32_wait.c:1.22 src/sys/compat/netbsd32/netbsd32_wait.c:1.23 --- src/sys/compat/netbsd32/netbsd32_wait.c:1.22 Sat Nov 3 23:22:22 2012 +++ src/sys/compat/netbsd32/netbsd32_wait.c Fri Sep 23 14:09:39 2016 @@ -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 @@ netbsd32___wait450(struct lwp *l, const 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, Index: src/sys/kern/kern_exit.c diff -u src/sys/kern/kern_exit.c:1.258 src/sys/kern/kern_exit.c:1.259 --- src/sys/kern/kern_exit.c:1.258 Wed Apr 27 21:15:40 2016 +++ src/sys/kern/kern_exit.c Fri Sep 23 14:09:39 2016 @@ -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 @@ retry: 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) { Index: src/sys/sys/proc.h diff -u src/sys/sys/proc.h:1.332 src/sys/sys/proc.h:1.333 --- src/sys/sys/proc.h:1.332 Tue Sep 13 07:39:45 2016 +++ src/sys/sys/proc.h Fri Sep 23 14:09:39 2016 @@ -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 @@ int kpause(const char *, bool, int, kmut 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 *);