initial commit
[glibc.git] / sysdeps / unix / bsd / bsd4.4 / kfreebsd / bits / resource.h
1 /* Bit values & structures for resource limits. FreeBSD version.
2 Copyright (C) 1994, 1996-1998, 2002 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
19
20 #ifndef _SYS_RESOURCE_H
21 # error "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
22 #endif
23
24 #include <bits/types.h>
25 #include <sys/_types.h>
26
27 /* Transmute defines to enumerations. The macro re-definitions are
28 necessary because some programs want to test for operating system
29 features with #ifdef RUSAGE_SELF. In ISO C the reflexive
30 definition is a no-op.
31
32 These are the values for FreeBSD. Earlier BSD systems have a subset of
33 these kinds of resource limit. */
34
35 /* Kinds of resource limit. */
36 enum __rlimit_resource
37 {
38 /* Per-process CPU limit, in seconds. */
39 RLIMIT_CPU = 0,
40 #define RLIMIT_CPU RLIMIT_CPU
41
42 /* Largest file that can be created, in bytes. */
43 RLIMIT_FSIZE = 1,
44 #define RLIMIT_FSIZE RLIMIT_FSIZE
45
46 /* Maximum size of data segment, in bytes. */
47 RLIMIT_DATA = 2,
48 #define RLIMIT_DATA RLIMIT_DATA
49
50 /* Maximum size of stack segment, in bytes. */
51 RLIMIT_STACK = 3,
52 #define RLIMIT_STACK RLIMIT_STACK
53
54 /* Largest core file that can be created, in bytes. */
55 RLIMIT_CORE = 4,
56 #define RLIMIT_CORE RLIMIT_CORE
57
58 /* Largest resident set size, in bytes.
59 This affects swapping; processes that are exceeding their
60 resident set size will be more likely to have physical memory
61 taken from them. */
62 __RLIMIT_RSS = 5,
63 #define RLIMIT_RSS __RLIMIT_RSS
64
65 /* Locked-in-memory address space. */
66 __RLIMIT_MEMLOCK = 6,
67 #define RLIMIT_MEMLOCK __RLIMIT_MEMLOCK
68
69 /* Number of processes. */
70 __RLIMIT_NPROC = 7,
71 #define RLIMIT_NPROC __RLIMIT_NPROC
72
73 /* Number of open files. */
74 RLIMIT_NOFILE = 8,
75 #define RLIMIT_NOFILE RLIMIT_NOFILE
76
77 /* Maximum size of all socket buffers. */
78 __RLIMIT_SBSIZE = 9,
79 #define RLIMIT_SBSIZE __RLIMIT_SBSIZE
80
81 /* Address space limit. */
82 RLIMIT_AS = 10,
83 #define RLIMIT_AS RLIMIT_AS
84 RLIMIT_VMEM = RLIMIT_AS,
85
86 /* Pseudo-terminals. */
87 RLIMIT_NPTS = 11,
88 #define RLIMIT_NPTS RLIMIT_NPTS
89
90 /* Swap used. */
91 RLIMIT_SWAP = 12,
92 #define RLIMIT_SWAP RLIMIT_SWAP
93
94 __RLIMIT_NLIMITS = 13,
95 __RLIM_NLIMITS = __RLIMIT_NLIMITS
96 #define RLIMIT_NLIMITS __RLIMIT_NLIMITS
97 #define RLIM_NLIMITS __RLIM_NLIMITS
98 };
99
100 /* Value to indicate that there is no limit. */
101 #define RLIM_INFINITY 0x7fffffffffffffffLL
102 #ifdef __USE_LARGEFILE64
103 # define RLIM64_INFINITY 0x7fffffffffffffffLL
104 #endif
105
106
107 /* Type for resource quantity measurement. */
108 typedef __rlim_t rlim_t;
109 #ifdef __USE_LARGEFILE64
110 typedef __rlim64_t rlim64_t;
111 #endif
112
113 struct rlimit
114 {
115 /* The current (soft) limit. */
116 rlim_t rlim_cur;
117 /* The hard limit. */
118 rlim_t rlim_max;
119 };
120
121 #ifdef __USE_LARGEFILE64
122 struct rlimit64
123 {
124 /* The current (soft) limit. */
125 rlim64_t rlim_cur;
126 /* The hard limit. */
127 rlim64_t rlim_max;
128 };
129 #endif
130
131 struct orlimit {
132 __int32_t rlim_cur; /* current (soft) limit */
133 __int32_t rlim_max; /* maximum value for rlim_cur */
134 };
135
136 struct loadavg {
137 __fixpt_t ldavg[3];
138 long fscale;
139 };
140
141 #define CP_USER 0
142 #define CP_NICE 1
143 #define CP_SYS 2
144 #define CP_INTR 3
145 #define CP_IDLE 4
146 #define CPUSTATES 5
147
148 /* Whose usage statistics do you want? */
149 enum __rusage_who
150 {
151 /* The calling process. */
152 RUSAGE_SELF = 0,
153 #define RUSAGE_SELF RUSAGE_SELF
154
155 /* All of its terminated child processes. */
156 RUSAGE_CHILDREN = -1
157 #define RUSAGE_CHILDREN RUSAGE_CHILDREN
158 };
159
160 #include <bits/types/struct_timeval.h>
161
162 /* Structure which says how much of each resource has been used. */
163 struct rusage
164 {
165 /* Total amount of user time used. */
166 struct timeval ru_utime;
167 /* Total amount of system time used. */
168 struct timeval ru_stime;
169 /* Maximum resident set size (in kilobytes). */
170 long int ru_maxrss;
171 /* Amount of sharing of text segment memory
172 with other processes (kilobyte-seconds). */
173 long int ru_ixrss;
174 /* Amount of data segment memory used (kilobyte-seconds). */
175 long int ru_idrss;
176 /* Amount of stack memory used (kilobyte-seconds). */
177 long int ru_isrss;
178 /* Number of soft page faults (i.e. those serviced by reclaiming
179 a page from the list of pages awaiting reallocation. */
180 long int ru_minflt;
181 /* Number of hard page faults (i.e. those that required I/O). */
182 long int ru_majflt;
183 /* Number of times a process was swapped out of physical memory. */
184 long int ru_nswap;
185 /* Number of input operations via the file system. Note: This
186 and `ru_oublock' do not include operations with the cache. */
187 long int ru_inblock;
188 /* Number of output operations via the file system. */
189 long int ru_oublock;
190 /* Number of IPC messages sent. */
191 long int ru_msgsnd;
192 /* Number of IPC messages received. */
193 long int ru_msgrcv;
194 /* Number of signals delivered. */
195 long int ru_nsignals;
196 /* Number of voluntary context switches, i.e. because the process
197 gave up the process before it had to (usually to wait for some
198 resource to be available). */
199 long int ru_nvcsw;
200 /* Number of involuntary context switches, i.e. a higher priority process
201 became runnable or the current process used up its time slice. */
202 long int ru_nivcsw;
203 };
204
205 /* Priority limits. */
206 #define PRIO_MIN -20 /* Minimum priority a process can have. */
207 #define PRIO_MAX 20 /* Maximum priority a process can have. */
208
209 /* The type of the WHICH argument to `getpriority' and `setpriority',
210 indicating what flavor of entity the WHO argument specifies. */
211 enum __priority_which
212 {
213 PRIO_PROCESS = 0, /* WHO is a process ID. */
214 #define PRIO_PROCESS PRIO_PROCESS
215 PRIO_PGRP = 1, /* WHO is a process group ID. */
216 #define PRIO_PGRP PRIO_PGRP
217 PRIO_USER = 2 /* WHO is a user ID. */
218 #define PRIO_USER PRIO_USER
219 };