limits.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. /*++
  2. Copyright (c) 2013 Minoca Corp.
  3. This file is licensed under the terms of the GNU Lesser General Public
  4. License version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details.
  6. Module Name:
  7. limits.h
  8. Abstract:
  9. This header contains implementation-defined constants for various system
  10. limits.
  11. Author:
  12. Evan Green 11-Mar-2013
  13. --*/
  14. #ifndef _LIMITS_H
  15. #define _LIMITS_H
  16. //
  17. // ------------------------------------------------------------------- Includes
  18. //
  19. //
  20. // ---------------------------------------------------------------- Definitions
  21. //
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. //
  26. // Define the number of bits in a char.
  27. //
  28. #define CHAR_BIT __CHAR_BIT__
  29. //
  30. // Define the minimum and maximum values a signed char can hold.
  31. //
  32. #define SCHAR_MAX __SCHAR_MAX__
  33. #define SCHAR_MIN (-SCHAR_MAX - 1)
  34. //
  35. // Define the maximum value an unsigned char can hold.
  36. //
  37. #define UCHAR_MAX (SCHAR_MAX * 2U + 1U)
  38. //
  39. // Define the minimum and maximum a char can hold.
  40. //
  41. #ifdef __CHAR_UNSIGNED__
  42. #define CHAR_MIN 0U
  43. #define CHAR_MAX UCHAR_MAX
  44. #else
  45. #define CHAR_MIN SCHAR_MIN
  46. #define CHAR_MAX SCHAR_MAX
  47. #endif
  48. //
  49. // Define the minimum and maximum values a signed short int can hold.
  50. //
  51. #define SHRT_MAX __SHRT_MAX__
  52. #define SHRT_MIN (-SHRT_MAX - 1)
  53. //
  54. // Define the maximum value an unsigned short int can hold.
  55. //
  56. #define USHRT_MAX (SHRT_MAX * 2U + 1U)
  57. //
  58. // Define the minimum and maximum values a signed int can hold.
  59. //
  60. #define INT_MAX __INT_MAX__
  61. #define INT_MIN (-INT_MAX - 1)
  62. //
  63. // Define the maximum value an unsigned int can hold.
  64. //
  65. #define UINT_MAX (INT_MAX * 2U + 1U)
  66. //
  67. // Define the minimum and maximum values a signed long int can hold.
  68. //
  69. #define LONG_MAX __LONG_MAX__
  70. #define LONG_MIN (-LONG_MAX - 1L)
  71. //
  72. // Define the maximum value an unsigned long int can hold.
  73. //
  74. #define ULONG_MAX (LONG_MAX * 2UL + 1UL)
  75. //
  76. // Define the minimum and maximum values a signed long long int can hold.
  77. //
  78. #define LLONG_MAX __LONG_LONG_MAX__
  79. #define LLONG_MIN (-LLONG_MAX - 1LL)
  80. #define LONG_LONG_MAX __LONG_LONG_MAX__
  81. #define LONG_LONG_MIN (-LONG_LONG_MAX - 1LL)
  82. //
  83. // Define the maximum value of an unsigned long long int.
  84. //
  85. #define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
  86. #define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1ULL)
  87. //
  88. // Define the maximum value an ssize_t can hold.
  89. //
  90. #define SSIZE_MAX LONG_MAX
  91. //
  92. // Define the maximum number of bytes in a multibyte character sequence.
  93. //
  94. #define MB_LEN_MAX 16
  95. //
  96. // Define the number of links a single file may have.
  97. //
  98. #define LINK_MAX 127
  99. //
  100. // Define the maximum number of bytes in a terminal canonical line.
  101. //
  102. #define MAX_CANON 511
  103. //
  104. // Define the minimum number of bytes for which space is available in a
  105. // terminal input queue. This is the maximum number of bytes a conforming
  106. // application may require to be typed as input before reading them.
  107. //
  108. #define MAX_INPUT 511
  109. //
  110. // Define the maximum length of a file, not including the null terminator.
  111. //
  112. #define NAME_MAX 255
  113. //
  114. // Define the maximum length of a file path, including the null terminator.
  115. //
  116. #define PATH_MAX 4096
  117. //
  118. // Define the maximum number of bytes that is guaranteed to be atomic when
  119. // writing to a pipe.
  120. //
  121. #define PIPE_BUF 4096
  122. //
  123. // Define the maximum length of a user name, including the null terminator.
  124. //
  125. #define LOGIN_NAME_MAX 256
  126. //
  127. // Define the maximum length of the local host name.
  128. //
  129. #define HOST_NAME_MAX 80
  130. //
  131. // Define the maximum number of simultaneous supplemental group IDs a process
  132. // can have.
  133. //
  134. #define NGROUPS_MAX 65536
  135. //
  136. // Define the maximum number of realtime signals reserved for application use
  137. // in this implementation.
  138. //
  139. #define RTSIG_MAX 32
  140. //
  141. // Define the maximum number of IO vectors that can be passed to the vectored
  142. // IO functions.
  143. //
  144. #define IOV_MAX 1024
  145. //
  146. // Define POSIX minimum requirements.
  147. //
  148. //
  149. // Define the number of I/O operations that can be specified in a list I/O
  150. // call.
  151. //
  152. #define _POSIX_AIO_LISTIO_MAX 2
  153. //
  154. // Define the number of outstanding asynchronous I/O operations.
  155. //
  156. #define _POSIX_AIO_MAX 1
  157. //
  158. // Define the maximum length of an argument to the exec functions, including
  159. // environment data.
  160. //
  161. #define _POSIX_ARG_MAX 4096
  162. //
  163. // Define the maximum number of simultaneous processes per real user ID.
  164. //
  165. #define _POSIX_CHILD_MAX 25
  166. //
  167. // Define the number of timer expiration overruns.
  168. //
  169. #define _POSIX_DELAYTIMER_MAX 32
  170. //
  171. // Define the maximum length of a hostname (not including the null terminator
  172. // as returned from the gethostname function.
  173. //
  174. #define _POSIX_HOST_NAME_MAX 255
  175. //
  176. // Define the maximum number of links to a single file.
  177. //
  178. #define _POSIX_LINK_MAX 8
  179. //
  180. // Define the size of storage required for a login name, in bytes, including
  181. // the null terminator.
  182. //
  183. #define _POSIX_LOGIN_NAME_MAX 9
  184. //
  185. // Define the maximum number of bytes in a terminal canonical input queue.
  186. //
  187. #define _POSIX_MAX_CANON 255
  188. //
  189. // Define the maximum number of bytes allowed in a terminal input queue.
  190. //
  191. #define _POSIX_MAX_INPUT 255
  192. //
  193. // Define the number of message queues that can be open for a single process.
  194. //
  195. #define _POSIX_MQ_OPEN_MAX 8
  196. //
  197. // Define the maximum number of message priorities supported by the
  198. // implementation.
  199. //
  200. #define _POSIX_MQ_PRIO_MAX 32
  201. //
  202. // Define the maximum number of bytes in a file name, not including the null
  203. // terminator.
  204. //
  205. #define _POSIX_NAME_MAX 14
  206. //
  207. // Define the number of simultaneous supplementary group IDs per process.
  208. //
  209. #define _POSIX_NGROUPS_MAX 8
  210. //
  211. // Define the maximum number of files that one process can have open at any
  212. // one time.
  213. //
  214. #define _POSIX_OPEN_MAX 20
  215. //
  216. // Define the maximum number of bytes in a pathname.
  217. //
  218. #define _POSIX_PATH_MAX 255
  219. //
  220. // Define the maximum number of bytes that is guarantted to be atomic when
  221. // writing to a pipe.
  222. //
  223. #define _POSIX_PIPE_BUF 512
  224. //
  225. // Define the number of repeated occurrences of a basic regular expression
  226. // permitted by the regexec and regcomp functions when using the interval
  227. // notation \{m,n\}.
  228. //
  229. #define _POSIX_RE_DUP_MAX 255
  230. //
  231. // Define the number of realtime signals reserved for application use.
  232. //
  233. #define _POSIX_RTSIG_MAX 8
  234. //
  235. // Define the number of semaphores a process may have.
  236. //
  237. #define _POSIX_SEM_NSEMS_MAX 256
  238. //
  239. // Define the maximum value a semaphore may have.
  240. //
  241. #define _POSIX_SEM_VALUE_MAX 32767
  242. //
  243. // Define the number of queued signals that a process may send and have pending
  244. // at the receiver(s) at any time.
  245. //
  246. #define _POSIX_SIGQUEUE_MAX 32
  247. //
  248. // Define the value that can be stored in an object of type ssize_t.
  249. //
  250. #define _POSIX_SSIZE_MAX 32767
  251. //
  252. // Define the number of streams that one process can have open at one time.
  253. //
  254. #define _POSIX_STREAM_MAX 8
  255. //
  256. // Define the number of bytes in a symlink file.
  257. //
  258. #define _POSIX_SYMLINK_MAX 255
  259. //
  260. // Define the numer of symbolic links that can be traversed in the resolution
  261. // of a pathname in the absence of a loop.
  262. //
  263. #define _POSIX_SYMLOOP_MAX 8
  264. //
  265. // Define the per-process number of timers.
  266. //
  267. #define _POSIX_TIMER_MAX 32
  268. //
  269. // Define the size of the storage required for a terminal device name,
  270. // including the null terminator.
  271. //
  272. #define _POSIX_TTY_NAME_MAX 9
  273. //
  274. // Define the maximum number of bytes supported for the name of a timezone
  275. // (not of the TZ variable).
  276. //
  277. #define _POSIX_TZNAME_MAX 6
  278. //
  279. // Define the minimum number of attempts made to destory a thread's
  280. // thread-specific data values on thread exit.
  281. //
  282. #define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
  283. //
  284. // Define the maximum number of keys that can be made per process.
  285. //
  286. #define _POSIX_THREAD_KEYS_MAX 128
  287. //
  288. // Define the maximum number of threads per process.
  289. //
  290. #define _POSIX_THREAD_THREADS_MAX 64
  291. //
  292. // Define the maximum number of bytes in a filename.
  293. //
  294. #define _XOPEN_NAME_MAX 255
  295. //
  296. // Define the maximum number of bytes in a pathname.
  297. //
  298. #define _XOPEN_PATH_MAX 1024
  299. //
  300. // Define the maximum "obase" values allowed by the bc utility.
  301. //
  302. #define _POSIX2_BC_BASE_MAX 99
  303. //
  304. // Define the maximum number of elements allowed in an array by the bc utility.
  305. //
  306. #define _POSIX2_BC_DIM_MAX 2048
  307. //
  308. // Define the maximum scale allowed by the bc utility.
  309. //
  310. #define _POSIX2_BC_SCALE_MAX 99
  311. //
  312. // Define the maximum number of bytes in a character class name.
  313. //
  314. #define _POSIX2_CHARCLASS_NAME_MAX 14
  315. //
  316. // Define the maximum length of a string constant accepted by the bc utility.
  317. //
  318. #define _POSIX2_BC_STRING_MAX 1000
  319. //
  320. // Define the maximum number of weights that can be assigned to an entry of the
  321. // LC_COLLAGE order keybowrd in the locale definition file.
  322. //
  323. #define _POSIX2_COLL_WEIGHTS_MAX 2
  324. //
  325. // Define the maximum number of expressions that can be nested within
  326. // parentheses by the expr utility.
  327. //
  328. #define _POSIX2_EXPR_NEST_MAX 32
  329. //
  330. // Define the maximum length of a utility's input line (either standard input
  331. // or another file), when the utility is described as processing text. The
  332. // length includes room for the trailing newline.
  333. //
  334. #define _POSIX2_LINE_MAX 2048
  335. //
  336. // Define the maximum number of repeated occurrences of a regular expression
  337. // permitted when using the interval notation \{m,n\}.
  338. //
  339. #define _POSIX2_RE_DUP_MAX 255
  340. //
  341. // Define reasonable limits for some required definitions. There is no actual
  342. // limit.
  343. //
  344. //
  345. // Define the maximum value of "digit" in calls to printf and scanf functions.
  346. //
  347. #define NL_ARGMAX _POSIX_ARG_MAX
  348. //
  349. // Define the number of bytes in a "lang" name.
  350. //
  351. #define NL_LANGMAX _POSIX2_LINE_MAX
  352. //
  353. // Define the maximum message number.
  354. //
  355. #define NL_MSGMAX INT_MAX
  356. //
  357. // Define the maximum number of bytes in an N-to-1 collation mapping.
  358. //
  359. #define NL_NMAX INT_MAX
  360. //
  361. // Define the maximum set number.
  362. //
  363. #define NL_SETMAX INT_MAX
  364. //
  365. // Define the maximum nubmer of bytes in a message.
  366. //
  367. #define NL_TEXTMAX INT_MAX
  368. //
  369. // Define the default process priority.
  370. //
  371. #define NZERO 20
  372. //
  373. // Define the maximum number of loops attempted to clean thread keys.
  374. //
  375. #define PTHREAD_DESTRUCTOR_ITERATIONS 4
  376. //
  377. // Define the maximum number of thread keys supported.
  378. //
  379. #define PTHREAD_KEYS_MAX 128
  380. //
  381. // Define the maximum number of threads per process.
  382. //
  383. #define PTHREAD_THREADS_MAX 2048
  384. //
  385. // Define the minimum stack size for a new thread.
  386. //
  387. #define PTHREAD_STACK_MIN 0x1000
  388. //
  389. // Define the maximum value of a semaphore.
  390. //
  391. #define SEM_VALUE_MAX 0x3FFFFFFF
  392. //
  393. // ------------------------------------------------------ Data Type Definitions
  394. //
  395. //
  396. // -------------------------------------------------------------------- Globals
  397. //
  398. //
  399. // -------------------------------------------------------- Function Prototypes
  400. //
  401. #ifdef __cplusplus
  402. }
  403. #endif
  404. #endif