1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate /* 30*7c478bd9Sstevel@tonic-gate * Implement fast getrusage call 31*7c478bd9Sstevel@tonic-gate */ 32*7c478bd9Sstevel@tonic-gate 33*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 34*7c478bd9Sstevel@tonic-gate #include <sys/systm.h> 35*7c478bd9Sstevel@tonic-gate #include <sys/time.h> 36*7c478bd9Sstevel@tonic-gate #include <sys/errno.h> 37*7c478bd9Sstevel@tonic-gate #include <sys/resource.h> 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate static int 40*7c478bd9Sstevel@tonic-gate getrusage(void *user_rusage) 41*7c478bd9Sstevel@tonic-gate { 42*7c478bd9Sstevel@tonic-gate struct rusage r; 43*7c478bd9Sstevel@tonic-gate kthread_t *t = curthread; 44*7c478bd9Sstevel@tonic-gate proc_t *p = ttoproc(t); 45*7c478bd9Sstevel@tonic-gate hrtime_t snsecs, unsecs; 46*7c478bd9Sstevel@tonic-gate klwp_t *lwp; 47*7c478bd9Sstevel@tonic-gate 48*7c478bd9Sstevel@tonic-gate r.ru_maxrss = 0; /* always 0 */ 49*7c478bd9Sstevel@tonic-gate r.ru_ixrss = 0; /* always 0 */ 50*7c478bd9Sstevel@tonic-gate r.ru_idrss = 0; /* always 0 */ 51*7c478bd9Sstevel@tonic-gate r.ru_isrss = 0; /* always 0 */ 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate r.ru_utime.tv_sec = 0; 54*7c478bd9Sstevel@tonic-gate r.ru_utime.tv_usec = 0; 55*7c478bd9Sstevel@tonic-gate r.ru_stime.tv_sec = 0; 56*7c478bd9Sstevel@tonic-gate r.ru_stime.tv_usec = 0; 57*7c478bd9Sstevel@tonic-gate 58*7c478bd9Sstevel@tonic-gate mutex_enter(&p->p_lock); 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate if (p->p_defunct > 0) { 61*7c478bd9Sstevel@tonic-gate r.ru_majflt = p->p_ru.majflt; 62*7c478bd9Sstevel@tonic-gate r.ru_minflt = p->p_ru.minflt; 63*7c478bd9Sstevel@tonic-gate r.ru_nswap = p->p_ru.nswap; 64*7c478bd9Sstevel@tonic-gate r.ru_inblock = p->p_ru.inblock; 65*7c478bd9Sstevel@tonic-gate r.ru_oublock = p->p_ru.oublock; 66*7c478bd9Sstevel@tonic-gate r.ru_msgsnd = p->p_ru.msgsnd; 67*7c478bd9Sstevel@tonic-gate r.ru_msgrcv = p->p_ru.msgrcv; 68*7c478bd9Sstevel@tonic-gate r.ru_nsignals = p->p_ru.nsignals; 69*7c478bd9Sstevel@tonic-gate r.ru_nvcsw = p->p_ru.nvcsw; 70*7c478bd9Sstevel@tonic-gate r.ru_nivcsw = p->p_ru.nivcsw; 71*7c478bd9Sstevel@tonic-gate } 72*7c478bd9Sstevel@tonic-gate 73*7c478bd9Sstevel@tonic-gate unsecs = mstate_aggr_state(p, LMS_USER); 74*7c478bd9Sstevel@tonic-gate snsecs = mstate_aggr_state(p, LMS_SYSTEM); 75*7c478bd9Sstevel@tonic-gate 76*7c478bd9Sstevel@tonic-gate do { 77*7c478bd9Sstevel@tonic-gate if (t->t_proc_flag & TP_LWPEXIT) 78*7c478bd9Sstevel@tonic-gate continue; 79*7c478bd9Sstevel@tonic-gate 80*7c478bd9Sstevel@tonic-gate lwp = ttolwp(t); 81*7c478bd9Sstevel@tonic-gate 82*7c478bd9Sstevel@tonic-gate r.ru_majflt += lwp->lwp_ru.majflt; 83*7c478bd9Sstevel@tonic-gate r.ru_minflt += lwp->lwp_ru.minflt; 84*7c478bd9Sstevel@tonic-gate r.ru_nswap += lwp->lwp_ru.nswap; 85*7c478bd9Sstevel@tonic-gate r.ru_inblock += lwp->lwp_ru.inblock; 86*7c478bd9Sstevel@tonic-gate r.ru_oublock += lwp->lwp_ru.oublock; 87*7c478bd9Sstevel@tonic-gate r.ru_msgsnd += lwp->lwp_ru.msgsnd; 88*7c478bd9Sstevel@tonic-gate r.ru_msgrcv += lwp->lwp_ru.msgrcv; 89*7c478bd9Sstevel@tonic-gate r.ru_nsignals += lwp->lwp_ru.nsignals; 90*7c478bd9Sstevel@tonic-gate r.ru_nvcsw += lwp->lwp_ru.nvcsw; 91*7c478bd9Sstevel@tonic-gate r.ru_nivcsw += lwp->lwp_ru.nivcsw; 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate } while ((t = t->t_forw) != curthread); 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate mutex_exit(&p->p_lock); 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate hrt2tv(unsecs, &r.ru_utime); 98*7c478bd9Sstevel@tonic-gate hrt2tv(snsecs, &r.ru_stime); 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL 101*7c478bd9Sstevel@tonic-gate if (get_udatamodel() == DATAMODEL_ILP32) { 102*7c478bd9Sstevel@tonic-gate struct rusage32 r32; 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate r32.ru_maxrss = 0; /* always 0 */ 105*7c478bd9Sstevel@tonic-gate r32.ru_ixrss = 0; /* always 0 */ 106*7c478bd9Sstevel@tonic-gate r32.ru_idrss = 0; /* always 0 */ 107*7c478bd9Sstevel@tonic-gate r32.ru_isrss = 0; /* always 0 */ 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gate r32.ru_utime.tv_sec = r.ru_utime.tv_sec; 110*7c478bd9Sstevel@tonic-gate r32.ru_utime.tv_usec = r.ru_utime.tv_usec; 111*7c478bd9Sstevel@tonic-gate r32.ru_stime.tv_sec = r.ru_stime.tv_sec; 112*7c478bd9Sstevel@tonic-gate r32.ru_stime.tv_usec = r.ru_stime.tv_usec; 113*7c478bd9Sstevel@tonic-gate 114*7c478bd9Sstevel@tonic-gate r32.ru_majflt = (int32_t)r.ru_majflt; 115*7c478bd9Sstevel@tonic-gate r32.ru_minflt = (int32_t)r.ru_minflt; 116*7c478bd9Sstevel@tonic-gate r32.ru_nswap = (int32_t)r.ru_nswap; 117*7c478bd9Sstevel@tonic-gate r32.ru_inblock = (int32_t)r.ru_inblock; 118*7c478bd9Sstevel@tonic-gate r32.ru_oublock = (int32_t)r.ru_oublock; 119*7c478bd9Sstevel@tonic-gate r32.ru_msgsnd = (int32_t)r.ru_msgsnd; 120*7c478bd9Sstevel@tonic-gate r32.ru_msgrcv = (int32_t)r.ru_msgrcv; 121*7c478bd9Sstevel@tonic-gate r32.ru_nsignals = (int32_t)r.ru_nsignals; 122*7c478bd9Sstevel@tonic-gate r32.ru_nvcsw = (int32_t)r.ru_nvcsw; 123*7c478bd9Sstevel@tonic-gate r32.ru_nivcsw = (int32_t)r.ru_nivcsw; 124*7c478bd9Sstevel@tonic-gate if (copyout(&r32, user_rusage, sizeof (r32)) != 0) 125*7c478bd9Sstevel@tonic-gate return (set_errno(EFAULT)); 126*7c478bd9Sstevel@tonic-gate } else 127*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32_IMPL */ 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate if (copyout(&r, user_rusage, sizeof (r)) != 0) 130*7c478bd9Sstevel@tonic-gate return (set_errno(EFAULT)); 131*7c478bd9Sstevel@tonic-gate 132*7c478bd9Sstevel@tonic-gate return (0); 133*7c478bd9Sstevel@tonic-gate } 134*7c478bd9Sstevel@tonic-gate 135*7c478bd9Sstevel@tonic-gate static int 136*7c478bd9Sstevel@tonic-gate getrusage_chld(void *user_rusage) 137*7c478bd9Sstevel@tonic-gate { 138*7c478bd9Sstevel@tonic-gate struct rusage r; 139*7c478bd9Sstevel@tonic-gate kthread_t *t = curthread; 140*7c478bd9Sstevel@tonic-gate proc_t *p = ttoproc(t); 141*7c478bd9Sstevel@tonic-gate 142*7c478bd9Sstevel@tonic-gate hrtime_t snsecs, unsecs; 143*7c478bd9Sstevel@tonic-gate 144*7c478bd9Sstevel@tonic-gate r.ru_maxrss = 0; /* always 0 */ 145*7c478bd9Sstevel@tonic-gate r.ru_ixrss = 0; /* always 0 */ 146*7c478bd9Sstevel@tonic-gate r.ru_idrss = 0; /* always 0 */ 147*7c478bd9Sstevel@tonic-gate r.ru_isrss = 0; /* always 0 */ 148*7c478bd9Sstevel@tonic-gate 149*7c478bd9Sstevel@tonic-gate mutex_enter(&p->p_lock); 150*7c478bd9Sstevel@tonic-gate 151*7c478bd9Sstevel@tonic-gate unsecs = p->p_cacct[LMS_USER]; 152*7c478bd9Sstevel@tonic-gate snsecs = p->p_cacct[LMS_SYSTEM] + p->p_cacct[LMS_TRAP]; 153*7c478bd9Sstevel@tonic-gate r.ru_utime.tv_sec = 0; 154*7c478bd9Sstevel@tonic-gate r.ru_utime.tv_usec = 0; 155*7c478bd9Sstevel@tonic-gate r.ru_stime.tv_sec = 0; 156*7c478bd9Sstevel@tonic-gate r.ru_stime.tv_usec = 0; 157*7c478bd9Sstevel@tonic-gate 158*7c478bd9Sstevel@tonic-gate r.ru_majflt = p->p_cru.majflt; 159*7c478bd9Sstevel@tonic-gate r.ru_minflt = p->p_cru.minflt; 160*7c478bd9Sstevel@tonic-gate r.ru_nswap = p->p_cru.nswap; 161*7c478bd9Sstevel@tonic-gate r.ru_inblock = p->p_cru.inblock; 162*7c478bd9Sstevel@tonic-gate r.ru_oublock = p->p_cru.oublock; 163*7c478bd9Sstevel@tonic-gate r.ru_msgsnd = p->p_cru.msgsnd; 164*7c478bd9Sstevel@tonic-gate r.ru_msgrcv = p->p_cru.msgrcv; 165*7c478bd9Sstevel@tonic-gate r.ru_nsignals = p->p_cru.nsignals; 166*7c478bd9Sstevel@tonic-gate r.ru_nvcsw = p->p_cru.nvcsw; 167*7c478bd9Sstevel@tonic-gate r.ru_nivcsw = p->p_cru.nivcsw; 168*7c478bd9Sstevel@tonic-gate 169*7c478bd9Sstevel@tonic-gate mutex_exit(&p->p_lock); 170*7c478bd9Sstevel@tonic-gate 171*7c478bd9Sstevel@tonic-gate hrt2tv(unsecs, &r.ru_utime); 172*7c478bd9Sstevel@tonic-gate hrt2tv(snsecs, &r.ru_stime); 173*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL 174*7c478bd9Sstevel@tonic-gate if (get_udatamodel() == DATAMODEL_ILP32) { 175*7c478bd9Sstevel@tonic-gate struct rusage32 r32; 176*7c478bd9Sstevel@tonic-gate 177*7c478bd9Sstevel@tonic-gate r32.ru_maxrss = 0; /* always 0 */ 178*7c478bd9Sstevel@tonic-gate r32.ru_ixrss = 0; /* always 0 */ 179*7c478bd9Sstevel@tonic-gate r32.ru_idrss = 0; /* always 0 */ 180*7c478bd9Sstevel@tonic-gate r32.ru_isrss = 0; /* always 0 */ 181*7c478bd9Sstevel@tonic-gate 182*7c478bd9Sstevel@tonic-gate r32.ru_utime.tv_sec = r.ru_utime.tv_sec; 183*7c478bd9Sstevel@tonic-gate r32.ru_utime.tv_usec = r.ru_utime.tv_usec; 184*7c478bd9Sstevel@tonic-gate r32.ru_stime.tv_sec = r.ru_stime.tv_sec; 185*7c478bd9Sstevel@tonic-gate r32.ru_stime.tv_usec = r.ru_stime.tv_usec; 186*7c478bd9Sstevel@tonic-gate 187*7c478bd9Sstevel@tonic-gate r32.ru_majflt = (int32_t)r.ru_majflt; 188*7c478bd9Sstevel@tonic-gate r32.ru_minflt = (int32_t)r.ru_minflt; 189*7c478bd9Sstevel@tonic-gate r32.ru_nswap = (int32_t)r.ru_nswap; 190*7c478bd9Sstevel@tonic-gate r32.ru_inblock = (int32_t)r.ru_inblock; 191*7c478bd9Sstevel@tonic-gate r32.ru_oublock = (int32_t)r.ru_oublock; 192*7c478bd9Sstevel@tonic-gate r32.ru_msgsnd = (int32_t)r.ru_msgsnd; 193*7c478bd9Sstevel@tonic-gate r32.ru_msgrcv = (int32_t)r.ru_msgrcv; 194*7c478bd9Sstevel@tonic-gate r32.ru_nsignals = (int32_t)r.ru_nsignals; 195*7c478bd9Sstevel@tonic-gate r32.ru_nvcsw = (int32_t)r.ru_nvcsw; 196*7c478bd9Sstevel@tonic-gate r32.ru_nivcsw = (int32_t)r.ru_nivcsw; 197*7c478bd9Sstevel@tonic-gate if (copyout(&r32, user_rusage, sizeof (r32)) != 0) 198*7c478bd9Sstevel@tonic-gate return (set_errno(EFAULT)); 199*7c478bd9Sstevel@tonic-gate } else 200*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32_IMPL */ 201*7c478bd9Sstevel@tonic-gate 202*7c478bd9Sstevel@tonic-gate if (copyout(&r, user_rusage, sizeof (r)) != 0) 203*7c478bd9Sstevel@tonic-gate return (set_errno(EFAULT)); 204*7c478bd9Sstevel@tonic-gate 205*7c478bd9Sstevel@tonic-gate return (0); 206*7c478bd9Sstevel@tonic-gate } 207*7c478bd9Sstevel@tonic-gate 208*7c478bd9Sstevel@tonic-gate static int 209*7c478bd9Sstevel@tonic-gate getrusage_lwp(void *user_rusage) 210*7c478bd9Sstevel@tonic-gate { 211*7c478bd9Sstevel@tonic-gate struct rusage r; 212*7c478bd9Sstevel@tonic-gate kthread_t *t = curthread; 213*7c478bd9Sstevel@tonic-gate klwp_t *lwp; 214*7c478bd9Sstevel@tonic-gate hrtime_t snsecs, unsecs; 215*7c478bd9Sstevel@tonic-gate struct mstate *ms; 216*7c478bd9Sstevel@tonic-gate 217*7c478bd9Sstevel@tonic-gate r.ru_maxrss = 0; /* always 0 */ 218*7c478bd9Sstevel@tonic-gate r.ru_ixrss = 0; /* always 0 */ 219*7c478bd9Sstevel@tonic-gate r.ru_idrss = 0; /* always 0 */ 220*7c478bd9Sstevel@tonic-gate r.ru_isrss = 0; /* always 0 */ 221*7c478bd9Sstevel@tonic-gate r.ru_utime.tv_sec = 0; 222*7c478bd9Sstevel@tonic-gate r.ru_utime.tv_usec = 0; 223*7c478bd9Sstevel@tonic-gate r.ru_stime.tv_sec = 0; 224*7c478bd9Sstevel@tonic-gate r.ru_stime.tv_usec = 0; 225*7c478bd9Sstevel@tonic-gate 226*7c478bd9Sstevel@tonic-gate lwp = ttolwp(t); 227*7c478bd9Sstevel@tonic-gate ms = &lwp->lwp_mstate; 228*7c478bd9Sstevel@tonic-gate unsecs = ms->ms_acct[LMS_USER]; 229*7c478bd9Sstevel@tonic-gate snsecs = ms->ms_acct[LMS_SYSTEM] + ms->ms_acct[LMS_TRAP]; 230*7c478bd9Sstevel@tonic-gate scalehrtime(&unsecs); 231*7c478bd9Sstevel@tonic-gate scalehrtime(&snsecs); 232*7c478bd9Sstevel@tonic-gate r.ru_majflt = lwp->lwp_ru.majflt; 233*7c478bd9Sstevel@tonic-gate r.ru_minflt = lwp->lwp_ru.minflt; 234*7c478bd9Sstevel@tonic-gate r.ru_nswap = lwp->lwp_ru.nswap; 235*7c478bd9Sstevel@tonic-gate r.ru_inblock = lwp->lwp_ru.inblock; 236*7c478bd9Sstevel@tonic-gate r.ru_oublock = lwp->lwp_ru.oublock; 237*7c478bd9Sstevel@tonic-gate r.ru_msgsnd = lwp->lwp_ru.msgsnd; 238*7c478bd9Sstevel@tonic-gate r.ru_msgrcv = lwp->lwp_ru.msgrcv; 239*7c478bd9Sstevel@tonic-gate r.ru_nsignals = lwp->lwp_ru.nsignals; 240*7c478bd9Sstevel@tonic-gate r.ru_nvcsw = lwp->lwp_ru.nvcsw; 241*7c478bd9Sstevel@tonic-gate r.ru_nivcsw = lwp->lwp_ru.nivcsw; 242*7c478bd9Sstevel@tonic-gate 243*7c478bd9Sstevel@tonic-gate hrt2tv(unsecs, &r.ru_utime); 244*7c478bd9Sstevel@tonic-gate hrt2tv(snsecs, &r.ru_stime); 245*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32_IMPL 246*7c478bd9Sstevel@tonic-gate if (get_udatamodel() == DATAMODEL_ILP32) { 247*7c478bd9Sstevel@tonic-gate struct rusage32 r32; 248*7c478bd9Sstevel@tonic-gate 249*7c478bd9Sstevel@tonic-gate r32.ru_maxrss = 0; /* always 0 */ 250*7c478bd9Sstevel@tonic-gate r32.ru_ixrss = 0; /* always 0 */ 251*7c478bd9Sstevel@tonic-gate r32.ru_idrss = 0; /* always 0 */ 252*7c478bd9Sstevel@tonic-gate r32.ru_isrss = 0; /* always 0 */ 253*7c478bd9Sstevel@tonic-gate 254*7c478bd9Sstevel@tonic-gate r32.ru_utime.tv_sec = r.ru_utime.tv_sec; 255*7c478bd9Sstevel@tonic-gate r32.ru_utime.tv_usec = r.ru_utime.tv_usec; 256*7c478bd9Sstevel@tonic-gate r32.ru_stime.tv_sec = r.ru_stime.tv_sec; 257*7c478bd9Sstevel@tonic-gate r32.ru_stime.tv_usec = r.ru_stime.tv_usec; 258*7c478bd9Sstevel@tonic-gate 259*7c478bd9Sstevel@tonic-gate r32.ru_majflt = (int32_t)r.ru_majflt; 260*7c478bd9Sstevel@tonic-gate r32.ru_minflt = (int32_t)r.ru_minflt; 261*7c478bd9Sstevel@tonic-gate r32.ru_nswap = (int32_t)r.ru_nswap; 262*7c478bd9Sstevel@tonic-gate r32.ru_inblock = (int32_t)r.ru_inblock; 263*7c478bd9Sstevel@tonic-gate r32.ru_oublock = (int32_t)r.ru_oublock; 264*7c478bd9Sstevel@tonic-gate r32.ru_msgsnd = (int32_t)r.ru_msgsnd; 265*7c478bd9Sstevel@tonic-gate r32.ru_msgrcv = (int32_t)r.ru_msgrcv; 266*7c478bd9Sstevel@tonic-gate r32.ru_nsignals = (int32_t)r.ru_nsignals; 267*7c478bd9Sstevel@tonic-gate r32.ru_nvcsw = (int32_t)r.ru_nvcsw; 268*7c478bd9Sstevel@tonic-gate r32.ru_nivcsw = (int32_t)r.ru_nivcsw; 269*7c478bd9Sstevel@tonic-gate if (copyout(&r32, user_rusage, sizeof (r32)) != 0) 270*7c478bd9Sstevel@tonic-gate return (set_errno(EFAULT)); 271*7c478bd9Sstevel@tonic-gate } else 272*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32_IMPL */ 273*7c478bd9Sstevel@tonic-gate 274*7c478bd9Sstevel@tonic-gate if (copyout(&r, user_rusage, sizeof (r)) != 0) 275*7c478bd9Sstevel@tonic-gate return (set_errno(EFAULT)); 276*7c478bd9Sstevel@tonic-gate 277*7c478bd9Sstevel@tonic-gate return (0); 278*7c478bd9Sstevel@tonic-gate } 279*7c478bd9Sstevel@tonic-gate 280*7c478bd9Sstevel@tonic-gate int 281*7c478bd9Sstevel@tonic-gate rusagesys(int code, void * arg) 282*7c478bd9Sstevel@tonic-gate { 283*7c478bd9Sstevel@tonic-gate switch (code) { 284*7c478bd9Sstevel@tonic-gate 285*7c478bd9Sstevel@tonic-gate case _RUSAGESYS_GETRUSAGE: 286*7c478bd9Sstevel@tonic-gate return (getrusage(arg)); 287*7c478bd9Sstevel@tonic-gate case _RUSAGESYS_GETRUSAGE_CHLD: 288*7c478bd9Sstevel@tonic-gate return (getrusage_chld(arg)); 289*7c478bd9Sstevel@tonic-gate case _RUSAGESYS_GETRUSAGE_LWP: 290*7c478bd9Sstevel@tonic-gate return (getrusage_lwp(arg)); 291*7c478bd9Sstevel@tonic-gate default: 292*7c478bd9Sstevel@tonic-gate return (set_errno(EINVAL)); 293*7c478bd9Sstevel@tonic-gate } 294*7c478bd9Sstevel@tonic-gate } 295