resource.h 6.5 KB

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