resource.h 7.1 KB

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