Define CLOCKS_PER_SEC type to the type clock_t
[platform/upstream/glibc.git] / bits / resource.h
1 /* Bit values & structures for resource limits.  4.4 BSD/generic GNU version.
2    Copyright (C) 1994-2015 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, see
17    <http://www.gnu.org/licenses/>.  */
18
19 #ifndef _SYS_RESOURCE_H
20 # error "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
21 #endif
22
23 #include <bits/types.h>
24
25 /* These are the values for 4.4 BSD and GNU.  Earlier BSD systems have a
26    subset of these kinds of resource limit.  In systems where `getrlimit'
27    and `setrlimit' are not system calls, these are the values used by the C
28    library to emulate them.  */
29
30 /* Kinds of resource limit.  */
31 enum __rlimit_resource
32   {
33     /* Per-process CPU limit, in seconds.  */
34     RLIMIT_CPU,
35 #define RLIMIT_CPU      RLIMIT_CPU
36     /* Largest file that can be created, in bytes.  */
37     RLIMIT_FSIZE,
38 #define RLIMIT_FSIZE    RLIMIT_FSIZE
39     /* Maximum size of data segment, in bytes.  */
40     RLIMIT_DATA,
41 #define RLIMIT_DATA     RLIMIT_DATA
42     /* Maximum size of stack segment, in bytes.  */
43     RLIMIT_STACK,
44 #define RLIMIT_STACK    RLIMIT_STACK
45     /* Largest core file that can be created, in bytes.  */
46     RLIMIT_CORE,
47 #define RLIMIT_CORE     RLIMIT_CORE
48     /* Largest resident set size, in bytes.
49        This affects swapping; processes that are exceeding their
50        resident set size will be more likely to have physical memory
51        taken from them.  */
52     RLIMIT_RSS,
53 #define RLIMIT_RSS      RLIMIT_RSS
54     /* Locked-in-memory address space.  */
55     RLIMIT_MEMLOCK,
56 #define RLIMIT_MEMLOCK  RLIMIT_MEMLOCK
57     /* Number of processes.  */
58     RLIMIT_NPROC,
59 #define RLIMIT_NPROC    RLIMIT_NPROC
60     /* Number of open files.  */
61     RLIMIT_OFILE,
62     RLIMIT_NOFILE = RLIMIT_OFILE, /* Another name for the same thing.  */
63 #define RLIMIT_OFILE    RLIMIT_OFILE
64 #define RLIMIT_NOFILE   RLIMIT_NOFILE
65     /* Maximum size of all socket buffers.  */
66     RLIMIT_SBSIZE,
67 #define RLIMIT_SBSIZE   RLIMIT_SBSIZE
68     /* Maximum size in bytes of the process address space.  */
69     RLIMIT_AS,
70     RLIMIT_VMEM = RLIMIT_AS,    /* Another name for the same thing.  */
71 #define RLIMIT_AS       RLIMIT_AS
72 #define RLIMIT_VMEM     RLIMIT_AS
73
74     RLIMIT_NLIMITS,             /* Number of limit flavors.  */
75     RLIM_NLIMITS = RLIMIT_NLIMITS /* Traditional name for same.  */
76   };
77
78 /* Value to indicate that there is no limit.  */
79 #ifndef __USE_FILE_OFFSET64
80 # define RLIM_INFINITY 0x7fffffff
81 #else
82 # define RLIM_INFINITY 0x7fffffffffffffffLL
83 #endif
84
85 #ifdef __USE_LARGEFILE64
86 # define RLIM64_INFINITY 0x7fffffffffffffffLL
87 #endif
88
89
90 /* Type for resource quantity measurement.  */
91 #ifndef __USE_FILE_OFFSET64
92 typedef __rlim_t rlim_t;
93 #else
94 typedef __rlim64_t rlim_t;
95 #endif
96 #ifdef __USE_LARGEFILE64
97 typedef __rlim64_t rlim64_t;
98 #endif
99
100 struct rlimit
101   {
102     /* The current (soft) limit.  */
103     rlim_t rlim_cur;
104     /* The hard limit.  */
105     rlim_t rlim_max;
106   };
107
108 #ifdef __USE_LARGEFILE64
109 struct rlimit64
110   {
111     /* The current (soft) limit.  */
112     rlim64_t rlim_cur;
113     /* The hard limit.  */
114     rlim64_t rlim_max;
115  };
116 #endif
117
118 /* Whose usage statistics do you want?  */
119 enum __rusage_who
120 /* The macro definitions are necessary because some programs want
121    to test for operating system features with #ifdef RUSAGE_SELF.
122    In ISO C the reflexive definition is a no-op.  */
123   {
124     /* The calling process.  */
125     RUSAGE_SELF = 0,
126 #define RUSAGE_SELF     RUSAGE_SELF
127     /* All of its terminated child processes.  */
128     RUSAGE_CHILDREN = -1
129 #define RUSAGE_CHILDREN RUSAGE_CHILDREN
130   };
131
132 #define __need_timeval
133 #include <bits/time.h>           /* For `struct timeval'.  */
134
135 /* Structure which says how much of each resource has been used.  */
136 struct rusage
137   {
138     /* Total amount of user time used.  */
139     struct timeval ru_utime;
140     /* Total amount of system time used.  */
141     struct timeval ru_stime;
142     /* Maximum resident set size (in kilobytes).  */
143     long int ru_maxrss;
144     /* Amount of sharing of text segment memory
145        with other processes (kilobyte-seconds).  */
146     long int ru_ixrss;
147     /* Amount of data segment memory used (kilobyte-seconds).  */
148     long int ru_idrss;
149     /* Amount of stack memory used (kilobyte-seconds).  */
150     long int ru_isrss;
151     /* Number of soft page faults (i.e. those serviced by reclaiming
152        a page from the list of pages awaiting reallocation.  */
153     long int ru_minflt;
154     /* Number of hard page faults (i.e. those that required I/O).  */
155     long int ru_majflt;
156     /* Number of times a process was swapped out of physical memory.  */
157     long int ru_nswap;
158     /* Number of input operations via the file system.  Note: This
159        and `ru_oublock' do not include operations with the cache.  */
160     long int ru_inblock;
161     /* Number of output operations via the file system.  */
162     long int ru_oublock;
163     /* Number of IPC messages sent.  */
164     long int ru_msgsnd;
165     /* Number of IPC messages received.  */
166     long int ru_msgrcv;
167     /* Number of signals delivered.  */
168     long int ru_nsignals;
169     /* Number of voluntary context switches, i.e. because the process
170        gave up the process before it had to (usually to wait for some
171        resource to be available).  */
172     long int ru_nvcsw;
173     /* Number of involuntary context switches, i.e. a higher priority process
174        became runnable or the current process used up its time slice.  */
175     long int ru_nivcsw;
176   };
177
178 /* Priority limits.  */
179 #define PRIO_MIN        -20     /* Minimum priority a process can have.  */
180 #define PRIO_MAX        20      /* Maximum priority a process can have.  */
181
182 /* The type of the WHICH argument to `getpriority' and `setpriority',
183    indicating what flavor of entity the WHO argument specifies.  */
184 enum __priority_which
185   {
186     PRIO_PROCESS = 0,           /* WHO is a process ID.  */
187 #define PRIO_PROCESS PRIO_PROCESS
188     PRIO_PGRP = 1,              /* WHO is a process group ID.  */
189 #define PRIO_PGRP PRIO_PGRP
190     PRIO_USER = 2               /* WHO is a user ID.  */
191 #define PRIO_USER PRIO_USER
192   };