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