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 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate /* 31*7c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 32*7c478bd9Sstevel@tonic-gate * The Regents of the University of California 33*7c478bd9Sstevel@tonic-gate * All Rights Reserved 34*7c478bd9Sstevel@tonic-gate * 35*7c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 36*7c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 37*7c478bd9Sstevel@tonic-gate * contributors. 38*7c478bd9Sstevel@tonic-gate */ 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #ifndef _SYS_RESOURCE_H 41*7c478bd9Sstevel@tonic-gate #define _SYS_RESOURCE_H 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h> 46*7c478bd9Sstevel@tonic-gate 47*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 48*7c478bd9Sstevel@tonic-gate #include <sys/time.h> 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 51*7c478bd9Sstevel@tonic-gate extern "C" { 52*7c478bd9Sstevel@tonic-gate #endif 53*7c478bd9Sstevel@tonic-gate 54*7c478bd9Sstevel@tonic-gate /* 55*7c478bd9Sstevel@tonic-gate * Process priority specifications 56*7c478bd9Sstevel@tonic-gate */ 57*7c478bd9Sstevel@tonic-gate #define PRIO_PROCESS 0 58*7c478bd9Sstevel@tonic-gate #define PRIO_PGRP 1 59*7c478bd9Sstevel@tonic-gate #define PRIO_USER 2 60*7c478bd9Sstevel@tonic-gate #define PRIO_GROUP 3 61*7c478bd9Sstevel@tonic-gate #define PRIO_SESSION 4 62*7c478bd9Sstevel@tonic-gate #define PRIO_LWP 5 63*7c478bd9Sstevel@tonic-gate #define PRIO_TASK 6 64*7c478bd9Sstevel@tonic-gate #define PRIO_PROJECT 7 65*7c478bd9Sstevel@tonic-gate #define PRIO_ZONE 8 66*7c478bd9Sstevel@tonic-gate #define PRIO_CONTRACT 9 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate /* 69*7c478bd9Sstevel@tonic-gate * Resource limits 70*7c478bd9Sstevel@tonic-gate */ 71*7c478bd9Sstevel@tonic-gate #define RLIMIT_CPU 0 /* cpu time in seconds */ 72*7c478bd9Sstevel@tonic-gate #define RLIMIT_FSIZE 1 /* maximum file size */ 73*7c478bd9Sstevel@tonic-gate #define RLIMIT_DATA 2 /* data size */ 74*7c478bd9Sstevel@tonic-gate #define RLIMIT_STACK 3 /* stack size */ 75*7c478bd9Sstevel@tonic-gate #define RLIMIT_CORE 4 /* core file size */ 76*7c478bd9Sstevel@tonic-gate #define RLIMIT_NOFILE 5 /* file descriptors */ 77*7c478bd9Sstevel@tonic-gate #define RLIMIT_VMEM 6 /* maximum mapped memory */ 78*7c478bd9Sstevel@tonic-gate #define RLIMIT_AS RLIMIT_VMEM 79*7c478bd9Sstevel@tonic-gate 80*7c478bd9Sstevel@tonic-gate #define RLIM_NLIMITS 7 /* number of resource limits */ 81*7c478bd9Sstevel@tonic-gate 82*7c478bd9Sstevel@tonic-gate #if defined(_LP64) 83*7c478bd9Sstevel@tonic-gate 84*7c478bd9Sstevel@tonic-gate typedef unsigned long rlim_t; 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate #define RLIM_INFINITY (-3l) 87*7c478bd9Sstevel@tonic-gate #define RLIM_SAVED_MAX (-2l) 88*7c478bd9Sstevel@tonic-gate #define RLIM_SAVED_CUR (-1l) 89*7c478bd9Sstevel@tonic-gate 90*7c478bd9Sstevel@tonic-gate #else /* _LP64 */ 91*7c478bd9Sstevel@tonic-gate 92*7c478bd9Sstevel@tonic-gate /* 93*7c478bd9Sstevel@tonic-gate * The definitions of the following types and constants differ between the 94*7c478bd9Sstevel@tonic-gate * regular and large file compilation environments. 95*7c478bd9Sstevel@tonic-gate */ 96*7c478bd9Sstevel@tonic-gate #if _FILE_OFFSET_BITS == 32 97*7c478bd9Sstevel@tonic-gate 98*7c478bd9Sstevel@tonic-gate typedef unsigned long rlim_t; 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gate #define RLIM_INFINITY 0x7fffffff 101*7c478bd9Sstevel@tonic-gate #define RLIM_SAVED_MAX 0x7ffffffe 102*7c478bd9Sstevel@tonic-gate #define RLIM_SAVED_CUR 0x7ffffffd 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate #else /* _FILE_OFFSET_BITS == 32 */ 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate typedef u_longlong_t rlim_t; 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate #define RLIM_INFINITY ((rlim_t)-3) 109*7c478bd9Sstevel@tonic-gate #define RLIM_SAVED_MAX ((rlim_t)-2) 110*7c478bd9Sstevel@tonic-gate #define RLIM_SAVED_CUR ((rlim_t)-1) 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate #endif /* _FILE_OFFSET_BITS == 32 */ 113*7c478bd9Sstevel@tonic-gate 114*7c478bd9Sstevel@tonic-gate #endif /* _LP64 */ 115*7c478bd9Sstevel@tonic-gate 116*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 117*7c478bd9Sstevel@tonic-gate 118*7c478bd9Sstevel@tonic-gate /* Kernel's view of user ILP32 rlimits */ 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate typedef uint32_t rlim32_t; 121*7c478bd9Sstevel@tonic-gate 122*7c478bd9Sstevel@tonic-gate #define RLIM32_INFINITY 0x7fffffff 123*7c478bd9Sstevel@tonic-gate #define RLIM32_SAVED_MAX 0x7ffffffe 124*7c478bd9Sstevel@tonic-gate #define RLIM32_SAVED_CUR 0x7ffffffd 125*7c478bd9Sstevel@tonic-gate 126*7c478bd9Sstevel@tonic-gate struct rlimit32 { 127*7c478bd9Sstevel@tonic-gate rlim32_t rlim_cur; /* current limit */ 128*7c478bd9Sstevel@tonic-gate rlim32_t rlim_max; /* maximum value for rlim_cur */ 129*7c478bd9Sstevel@tonic-gate }; 130*7c478bd9Sstevel@tonic-gate 131*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 132*7c478bd9Sstevel@tonic-gate 133*7c478bd9Sstevel@tonic-gate struct rlimit { 134*7c478bd9Sstevel@tonic-gate rlim_t rlim_cur; /* current limit */ 135*7c478bd9Sstevel@tonic-gate rlim_t rlim_max; /* maximum value for rlim_cur */ 136*7c478bd9Sstevel@tonic-gate }; 137*7c478bd9Sstevel@tonic-gate 138*7c478bd9Sstevel@tonic-gate /* transitional large file interface versions */ 139*7c478bd9Sstevel@tonic-gate #ifdef _LARGEFILE64_SOURCE 140*7c478bd9Sstevel@tonic-gate 141*7c478bd9Sstevel@tonic-gate typedef u_longlong_t rlim64_t; 142*7c478bd9Sstevel@tonic-gate 143*7c478bd9Sstevel@tonic-gate #define RLIM64_INFINITY ((rlim64_t)-3) 144*7c478bd9Sstevel@tonic-gate #define RLIM64_SAVED_MAX ((rlim64_t)-2) 145*7c478bd9Sstevel@tonic-gate #define RLIM64_SAVED_CUR ((rlim64_t)-1) 146*7c478bd9Sstevel@tonic-gate 147*7c478bd9Sstevel@tonic-gate struct rlimit64 { 148*7c478bd9Sstevel@tonic-gate rlim64_t rlim_cur; /* current limit */ 149*7c478bd9Sstevel@tonic-gate rlim64_t rlim_max; /* maximum value for rlim_cur */ 150*7c478bd9Sstevel@tonic-gate }; 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate #endif 153*7c478bd9Sstevel@tonic-gate 154*7c478bd9Sstevel@tonic-gate /* 155*7c478bd9Sstevel@tonic-gate * Although the saved rlimits were initially introduced by the large file API, 156*7c478bd9Sstevel@tonic-gate * they are now available for all resource limits on the 64-bit kernel and for 157*7c478bd9Sstevel@tonic-gate * cpu time and file size limits on the 32-bit kernel. 158*7c478bd9Sstevel@tonic-gate */ 159*7c478bd9Sstevel@tonic-gate #if defined(_LP64) 160*7c478bd9Sstevel@tonic-gate 161*7c478bd9Sstevel@tonic-gate #define RLIM_SAVED(x) (1) /* save all resource limits */ 162*7c478bd9Sstevel@tonic-gate #define RLIM_NSAVED RLIM_NLIMITS /* size of u_saved_rlimits[] */ 163*7c478bd9Sstevel@tonic-gate 164*7c478bd9Sstevel@tonic-gate #else /* _LP64 */ 165*7c478bd9Sstevel@tonic-gate 166*7c478bd9Sstevel@tonic-gate #define RLIM_SAVED(x) (x <= RLIMIT_FSIZE) /* cpu time and file size */ 167*7c478bd9Sstevel@tonic-gate #define RLIM_NSAVED (RLIMIT_FSIZE + 1) /* size of u_saved_rlimits[] */ 168*7c478bd9Sstevel@tonic-gate 169*7c478bd9Sstevel@tonic-gate #endif /* _LP64 */ 170*7c478bd9Sstevel@tonic-gate 171*7c478bd9Sstevel@tonic-gate 172*7c478bd9Sstevel@tonic-gate struct rusage { 173*7c478bd9Sstevel@tonic-gate struct timeval ru_utime; /* user time used */ 174*7c478bd9Sstevel@tonic-gate struct timeval ru_stime; /* system time used */ 175*7c478bd9Sstevel@tonic-gate long ru_maxrss; /* <unimp> */ 176*7c478bd9Sstevel@tonic-gate long ru_ixrss; /* <unimp> */ 177*7c478bd9Sstevel@tonic-gate long ru_idrss; /* <unimp> */ 178*7c478bd9Sstevel@tonic-gate long ru_isrss; /* <unimp> */ 179*7c478bd9Sstevel@tonic-gate long ru_minflt; /* any page faults not requiring I/O */ 180*7c478bd9Sstevel@tonic-gate long ru_majflt; /* any page faults requiring I/O */ 181*7c478bd9Sstevel@tonic-gate long ru_nswap; /* swaps */ 182*7c478bd9Sstevel@tonic-gate long ru_inblock; /* block input operations */ 183*7c478bd9Sstevel@tonic-gate long ru_oublock; /* block output operations */ 184*7c478bd9Sstevel@tonic-gate long ru_msgsnd; /* streams messsages sent */ 185*7c478bd9Sstevel@tonic-gate long ru_msgrcv; /* streams messages received */ 186*7c478bd9Sstevel@tonic-gate long ru_nsignals; /* signals received */ 187*7c478bd9Sstevel@tonic-gate long ru_nvcsw; /* voluntary context switches */ 188*7c478bd9Sstevel@tonic-gate long ru_nivcsw; /* involuntary " */ 189*7c478bd9Sstevel@tonic-gate }; 190*7c478bd9Sstevel@tonic-gate 191*7c478bd9Sstevel@tonic-gate #define _RUSAGESYS_GETRUSAGE 0 /* rusage process */ 192*7c478bd9Sstevel@tonic-gate #define _RUSAGESYS_GETRUSAGE_CHLD 1 /* rusage child process */ 193*7c478bd9Sstevel@tonic-gate #define _RUSAGESYS_GETRUSAGE_LWP 2 /* rusage lwp */ 194*7c478bd9Sstevel@tonic-gate 195*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 196*7c478bd9Sstevel@tonic-gate 197*7c478bd9Sstevel@tonic-gate struct rusage32 { 198*7c478bd9Sstevel@tonic-gate struct timeval32 ru_utime; /* user time used */ 199*7c478bd9Sstevel@tonic-gate struct timeval32 ru_stime; /* system time used */ 200*7c478bd9Sstevel@tonic-gate int ru_maxrss; /* <unimp> */ 201*7c478bd9Sstevel@tonic-gate int ru_ixrss; /* <unimp> */ 202*7c478bd9Sstevel@tonic-gate int ru_idrss; /* <unimp> */ 203*7c478bd9Sstevel@tonic-gate int ru_isrss; /* <unimp> */ 204*7c478bd9Sstevel@tonic-gate int ru_minflt; /* any page faults not requiring I/O */ 205*7c478bd9Sstevel@tonic-gate int ru_majflt; /* any page faults requiring I/O */ 206*7c478bd9Sstevel@tonic-gate int ru_nswap; /* swaps */ 207*7c478bd9Sstevel@tonic-gate int ru_inblock; /* block input operations */ 208*7c478bd9Sstevel@tonic-gate int ru_oublock; /* block output operations */ 209*7c478bd9Sstevel@tonic-gate int ru_msgsnd; /* streams messages sent */ 210*7c478bd9Sstevel@tonic-gate int ru_msgrcv; /* streams messages received */ 211*7c478bd9Sstevel@tonic-gate int ru_nsignals; /* signals received */ 212*7c478bd9Sstevel@tonic-gate int ru_nvcsw; /* voluntary context switches */ 213*7c478bd9Sstevel@tonic-gate int ru_nivcsw; /* involuntary " */ 214*7c478bd9Sstevel@tonic-gate }; 215*7c478bd9Sstevel@tonic-gate 216*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 217*7c478bd9Sstevel@tonic-gate 218*7c478bd9Sstevel@tonic-gate 219*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 220*7c478bd9Sstevel@tonic-gate 221*7c478bd9Sstevel@tonic-gate #include <sys/model.h> 222*7c478bd9Sstevel@tonic-gate 223*7c478bd9Sstevel@tonic-gate struct proc; 224*7c478bd9Sstevel@tonic-gate 225*7c478bd9Sstevel@tonic-gate #else 226*7c478bd9Sstevel@tonic-gate 227*7c478bd9Sstevel@tonic-gate #define RUSAGE_SELF 0 228*7c478bd9Sstevel@tonic-gate #define RUSAGE_LWP 1 229*7c478bd9Sstevel@tonic-gate #define RUSAGE_CHILDREN -1 230*7c478bd9Sstevel@tonic-gate 231*7c478bd9Sstevel@tonic-gate 232*7c478bd9Sstevel@tonic-gate #if !defined(_LP64) && _FILE_OFFSET_BITS == 64 233*7c478bd9Sstevel@tonic-gate /* 234*7c478bd9Sstevel@tonic-gate * large file compilation environment setup 235*7c478bd9Sstevel@tonic-gate */ 236*7c478bd9Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME 237*7c478bd9Sstevel@tonic-gate #pragma redefine_extname setrlimit setrlimit64 238*7c478bd9Sstevel@tonic-gate #pragma redefine_extname getrlimit getrlimit64 239*7c478bd9Sstevel@tonic-gate #else 240*7c478bd9Sstevel@tonic-gate #define setrlimit setrlimit64 241*7c478bd9Sstevel@tonic-gate #define getrlimit getrlimit64 242*7c478bd9Sstevel@tonic-gate #define rlimit rlimit64 243*7c478bd9Sstevel@tonic-gate #endif 244*7c478bd9Sstevel@tonic-gate #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ 245*7c478bd9Sstevel@tonic-gate 246*7c478bd9Sstevel@tonic-gate #if defined(_LP64) && defined(_LARGEFILE64_SOURCE) 247*7c478bd9Sstevel@tonic-gate /* 248*7c478bd9Sstevel@tonic-gate * In the LP64 compilation environment, map large file interfaces 249*7c478bd9Sstevel@tonic-gate * back to native versions where possible. 250*7c478bd9Sstevel@tonic-gate */ 251*7c478bd9Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME 252*7c478bd9Sstevel@tonic-gate #pragma redefine_extname setrlimit64 setrlimit 253*7c478bd9Sstevel@tonic-gate #pragma redefine_extname getrlimit64 getrlimit 254*7c478bd9Sstevel@tonic-gate #else 255*7c478bd9Sstevel@tonic-gate #define setrlimit64 setrlimit 256*7c478bd9Sstevel@tonic-gate #define getrlimit64 getrlimit 257*7c478bd9Sstevel@tonic-gate #define rlimit64 rlimit 258*7c478bd9Sstevel@tonic-gate #endif 259*7c478bd9Sstevel@tonic-gate #endif /* _LP64 && _LARGEFILE64_SOURCE */ 260*7c478bd9Sstevel@tonic-gate 261*7c478bd9Sstevel@tonic-gate #if defined(__STDC__) 262*7c478bd9Sstevel@tonic-gate 263*7c478bd9Sstevel@tonic-gate extern int setrlimit(int, const struct rlimit *); 264*7c478bd9Sstevel@tonic-gate extern int getrlimit(int, struct rlimit *); 265*7c478bd9Sstevel@tonic-gate 266*7c478bd9Sstevel@tonic-gate /* transitional large file interfaces */ 267*7c478bd9Sstevel@tonic-gate #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ 268*7c478bd9Sstevel@tonic-gate !defined(__PRAGMA_REDEFINE_EXTNAME)) 269*7c478bd9Sstevel@tonic-gate extern int setrlimit64(int, const struct rlimit64 *); 270*7c478bd9Sstevel@tonic-gate extern int getrlimit64(int, struct rlimit64 *); 271*7c478bd9Sstevel@tonic-gate #endif /* _LARGEFILE64_SOURCE... */ 272*7c478bd9Sstevel@tonic-gate 273*7c478bd9Sstevel@tonic-gate extern int getpriority(int, id_t); 274*7c478bd9Sstevel@tonic-gate extern int setpriority(int, id_t, int); 275*7c478bd9Sstevel@tonic-gate extern int getrusage(int, struct rusage *); 276*7c478bd9Sstevel@tonic-gate 277*7c478bd9Sstevel@tonic-gate #else /* __STDC__ */ 278*7c478bd9Sstevel@tonic-gate 279*7c478bd9Sstevel@tonic-gate extern int getrlimit(); 280*7c478bd9Sstevel@tonic-gate extern int setrlimit(); 281*7c478bd9Sstevel@tonic-gate 282*7c478bd9Sstevel@tonic-gate /* transitional large file interfaces */ 283*7c478bd9Sstevel@tonic-gate #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ 284*7c478bd9Sstevel@tonic-gate !defined(__PRAGMA_REDEFINE_EXTNAME)) 285*7c478bd9Sstevel@tonic-gate extern int setrlimit64(); 286*7c478bd9Sstevel@tonic-gate extern int getrlimit64(); 287*7c478bd9Sstevel@tonic-gate #endif /* _LARGEFILE64_SOURCE... */ 288*7c478bd9Sstevel@tonic-gate 289*7c478bd9Sstevel@tonic-gate extern int getpriority(); 290*7c478bd9Sstevel@tonic-gate extern int setpriority(); 291*7c478bd9Sstevel@tonic-gate extern int getrusage(); 292*7c478bd9Sstevel@tonic-gate 293*7c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 294*7c478bd9Sstevel@tonic-gate 295*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 296*7c478bd9Sstevel@tonic-gate 297*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 298*7c478bd9Sstevel@tonic-gate } 299*7c478bd9Sstevel@tonic-gate #endif 300*7c478bd9Sstevel@tonic-gate 301*7c478bd9Sstevel@tonic-gate #endif /* _SYS_RESOURCE_H */ 302