Print this page
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/sys/resource.h
+++ new/usr/src/uts/common/sys/resource.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2014 Garrrett D'Amore <garrett@damore.org>
23 23 *
24 24 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
25 25 * Use is subject to license terms.
26 26 * Copyright 2014 Joyent, Inc. All rights reserved.
27 27 */
28 28
29 29 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
30 30 /* All Rights Reserved */
31 31
32 32 /*
33 33 * University Copyright- Copyright (c) 1982, 1986, 1988
34 34 * The Regents of the University of California
35 35 * All Rights Reserved
36 36 *
37 37 * University Acknowledgment- Portions of this document are derived from
38 38 * software developed by the University of California, Berkeley, and its
39 39 * contributors.
40 40 */
41 41
42 42 #ifndef _SYS_RESOURCE_H
43 43 #define _SYS_RESOURCE_H
44 44
45 45 #include <sys/feature_tests.h>
46 46
47 47 #include <sys/types.h>
48 48 #include <sys/time.h>
49 49
50 50 #ifdef __cplusplus
51 51 extern "C" {
52 52 #endif
53 53
54 54 /*
55 55 * Process priority specifications
56 56 */
57 57 #define PRIO_PROCESS 0
58 58 #define PRIO_PGRP 1
59 59 #define PRIO_USER 2
60 60 #define PRIO_GROUP 3
61 61 #define PRIO_SESSION 4
62 62 #define PRIO_LWP 5
63 63 #define PRIO_TASK 6
64 64 #define PRIO_PROJECT 7
65 65 #define PRIO_ZONE 8
66 66 #define PRIO_CONTRACT 9
67 67
68 68 /*
69 69 * Resource limits
70 70 */
71 71 #define RLIMIT_CPU 0 /* cpu time in seconds */
72 72 #define RLIMIT_FSIZE 1 /* maximum file size */
73 73 #define RLIMIT_DATA 2 /* data size */
74 74 #define RLIMIT_STACK 3 /* stack size */
75 75 #define RLIMIT_CORE 4 /* core file size */
76 76 #define RLIMIT_NOFILE 5 /* file descriptors */
77 77 #define RLIMIT_VMEM 6 /* maximum mapped memory */
78 78 #define RLIMIT_AS RLIMIT_VMEM
79 79
80 80 #define RLIM_NLIMITS 7 /* number of resource limits */
81 81
82 82 #if defined(_LP64)
83 83
84 84 typedef unsigned long rlim_t;
85 85
86 86 #define RLIM_INFINITY ((rlim_t)-3)
87 87 #define RLIM_SAVED_MAX ((rlim_t)-2)
88 88 #define RLIM_SAVED_CUR ((rlim_t)-1)
89 89
90 90 #else /* _LP64 */
91 91
92 92 /*
93 93 * The definitions of the following types and constants differ between the
94 94 * regular and large file compilation environments.
95 95 */
96 96 #if _FILE_OFFSET_BITS == 32
97 97
98 98 typedef unsigned long rlim_t;
99 99
100 100 #define RLIM_INFINITY 0x7fffffff
101 101 #define RLIM_SAVED_MAX 0x7ffffffe
102 102 #define RLIM_SAVED_CUR 0x7ffffffd
103 103
104 104 #else /* _FILE_OFFSET_BITS == 32 */
105 105
106 106 typedef u_longlong_t rlim_t;
107 107
108 108 #define RLIM_INFINITY ((rlim_t)-3)
109 109 #define RLIM_SAVED_MAX ((rlim_t)-2)
110 110 #define RLIM_SAVED_CUR ((rlim_t)-1)
111 111
112 112 #endif /* _FILE_OFFSET_BITS == 32 */
113 113
114 114 #endif /* _LP64 */
115 115
116 116 #if defined(_SYSCALL32)
117 117
118 118 /* Kernel's view of user ILP32 rlimits */
119 119
120 120 typedef uint32_t rlim32_t;
121 121
122 122 #define RLIM32_INFINITY 0x7fffffff
123 123 #define RLIM32_SAVED_MAX 0x7ffffffe
124 124 #define RLIM32_SAVED_CUR 0x7ffffffd
125 125
126 126 struct rlimit32 {
127 127 rlim32_t rlim_cur; /* current limit */
128 128 rlim32_t rlim_max; /* maximum value for rlim_cur */
129 129 };
130 130
131 131 #endif /* _SYSCALL32 */
132 132
133 133 struct rlimit {
134 134 rlim_t rlim_cur; /* current limit */
135 135 rlim_t rlim_max; /* maximum value for rlim_cur */
136 136 };
137 137
138 138 /* transitional large file interface versions */
139 139 #ifdef _LARGEFILE64_SOURCE
140 140
141 141 typedef u_longlong_t rlim64_t;
142 142
143 143 #define RLIM64_INFINITY ((rlim64_t)-3)
144 144 #define RLIM64_SAVED_MAX ((rlim64_t)-2)
145 145 #define RLIM64_SAVED_CUR ((rlim64_t)-1)
146 146
147 147 struct rlimit64 {
148 148 rlim64_t rlim_cur; /* current limit */
149 149 rlim64_t rlim_max; /* maximum value for rlim_cur */
150 150 };
151 151
152 152 #endif
153 153
154 154 /*
155 155 * Although the saved rlimits were initially introduced by the large file API,
156 156 * they are now available for all resource limits on the 64-bit kernel and for
157 157 * cpu time and file size limits on the 32-bit kernel.
158 158 */
159 159 #if defined(_LP64)
160 160
161 161 #define RLIM_SAVED(x) (1) /* save all resource limits */
162 162 #define RLIM_NSAVED RLIM_NLIMITS /* size of u_saved_rlimits[] */
163 163
164 164 #else /* _LP64 */
165 165
166 166 #define RLIM_SAVED(x) (x <= RLIMIT_FSIZE) /* cpu time and file size */
167 167 #define RLIM_NSAVED (RLIMIT_FSIZE + 1) /* size of u_saved_rlimits[] */
168 168
169 169 #endif /* _LP64 */
170 170
171 171
172 172 struct rusage {
173 173 struct timeval ru_utime; /* user time used */
174 174 struct timeval ru_stime; /* system time used */
175 175 long ru_maxrss; /* <unimp> */
176 176 long ru_ixrss; /* <unimp> */
177 177 long ru_idrss; /* <unimp> */
178 178 long ru_isrss; /* <unimp> */
179 179 long ru_minflt; /* any page faults not requiring I/O */
180 180 long ru_majflt; /* any page faults requiring I/O */
181 181 long ru_nswap; /* swaps */
182 182 long ru_inblock; /* block input operations */
183 183 long ru_oublock; /* block output operations */
184 184 long ru_msgsnd; /* streams messsages sent */
185 185 long ru_msgrcv; /* streams messages received */
186 186 long ru_nsignals; /* signals received */
187 187 long ru_nvcsw; /* voluntary context switches */
188 188 long ru_nivcsw; /* involuntary " */
189 189 };
190 190
191 191 #define _RUSAGESYS_GETRUSAGE 0 /* rusage process */
192 192 #define _RUSAGESYS_GETRUSAGE_CHLD 1 /* rusage child process */
193 193 #define _RUSAGESYS_GETRUSAGE_LWP 2 /* rusage lwp */
194 194 #define _RUSAGESYS_GETVMUSAGE 3 /* getvmusage */
195 195 #define _RUSAGESYS_INVALMAP 4 /* vm_map_inval */
196 196
197 197 #if defined(_SYSCALL32)
198 198
199 199 struct rusage32 {
200 200 struct timeval32 ru_utime; /* user time used */
201 201 struct timeval32 ru_stime; /* system time used */
202 202 int ru_maxrss; /* <unimp> */
203 203 int ru_ixrss; /* <unimp> */
204 204 int ru_idrss; /* <unimp> */
205 205 int ru_isrss; /* <unimp> */
206 206 int ru_minflt; /* any page faults not requiring I/O */
207 207 int ru_majflt; /* any page faults requiring I/O */
208 208 int ru_nswap; /* swaps */
209 209 int ru_inblock; /* block input operations */
210 210 int ru_oublock; /* block output operations */
211 211 int ru_msgsnd; /* streams messages sent */
212 212 int ru_msgrcv; /* streams messages received */
213 213 int ru_nsignals; /* signals received */
214 214 int ru_nvcsw; /* voluntary context switches */
215 215 int ru_nivcsw; /* involuntary " */
216 216 };
217 217
218 218 #endif /* _SYSCALL32 */
219 219
220 220
221 221 #ifdef _KERNEL
222 222
223 223 #include <sys/model.h>
224 224
225 225 struct proc;
226 226
227 227 #else
228 228
229 229 #define RUSAGE_SELF 0
230 230 #define RUSAGE_LWP 1
231 231 #define RUSAGE_CHILDREN -1
232 232
233 233
234 234 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
235 235 /*
236 236 * large file compilation environment setup
237 237 */
238 238 #ifdef __PRAGMA_REDEFINE_EXTNAME
239 239 #pragma redefine_extname setrlimit setrlimit64
240 240 #pragma redefine_extname getrlimit getrlimit64
241 241 #else
242 242 #define setrlimit setrlimit64
243 243 #define getrlimit getrlimit64
244 244 #define rlimit rlimit64
245 245 #endif
246 246 #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */
247 247
248 248 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
249 249 /*
250 250 * In the LP64 compilation environment, map large file interfaces
251 251 * back to native versions where possible.
252 252 */
253 253 #ifdef __PRAGMA_REDEFINE_EXTNAME
254 254 #pragma redefine_extname setrlimit64 setrlimit
255 255 #pragma redefine_extname getrlimit64 getrlimit
256 256 #else
257 257 #define setrlimit64 setrlimit
258 258 #define getrlimit64 getrlimit
259 259 #define rlimit64 rlimit
260 260 #endif
261 261 #endif /* _LP64 && _LARGEFILE64_SOURCE */
262 262
263 263 extern int setrlimit(int, const struct rlimit *);
264 264 extern int getrlimit(int, struct rlimit *);
265 265
266 266 /* transitional large file interfaces */
267 267 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
268 268 !defined(__PRAGMA_REDEFINE_EXTNAME))
269 269 extern int setrlimit64(int, const struct rlimit64 *);
270 270 extern int getrlimit64(int, struct rlimit64 *);
271 271 #endif /* _LARGEFILE64_SOURCE... */
272 272
273 273 extern int getpriority(int, id_t);
274 274 extern int setpriority(int, id_t, int);
275 275 extern int getrusage(int, struct rusage *);
276 276
277 277 #endif /* _KERNEL */
278 278
279 279 #ifdef __cplusplus
280 280 }
281 281 #endif
282 282
283 283 #endif /* _SYS_RESOURCE_H */
|
↓ open down ↓ |
283 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX