Ticket #2342: resource.h

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