PageRenderTime 67ms CodeModel.GetById 9ms RepoModel.GetById 1ms app.codeStats 0ms

/attic/p42/SysCore/Include/limits.h

http://github.com/mooseman/plan_42
C Header | 225 lines | 132 code | 40 blank | 53 comment | 13 complexity | be3504da06ef447ed53bd6aca66fcf11 MD5 | raw file
Possible License(s): Unlicense
  1. /************************************************************************
  2. * *
  3. * limits.h - type limits *
  4. * *
  5. * Copyright (c) BrokenThorn Entertainment Co. All Rights Reserved. *
  6. * *
  7. ************************************************************************/
  8. #ifndef LIMITS_H
  9. #define LIMITS_H
  10. #include <float.h>
  11. /*
  12. * Sizes of integral types
  13. */
  14. #define CHAR_BIT 8 /* max # of bits in a "char" */
  15. #define SCHAR_MIN (-128) /* min value of a "signed char" */
  16. #define SCHAR_MAX 127 /* max value of a "signed char" */
  17. #define UCHAR_MAX 255 /* max value of an "unsigned char" */
  18. #define MB_LEN_MAX 5
  19. #define CHAR_MIN SCHAR_MIN /* min value of a "char" */
  20. #define CHAR_MAX SCHAR_MAX /* max value of a "char" */
  21. #define SHRT_MIN (-32768) /* min value of a "short int" */
  22. #define SHRT_MAX 32767 /* max value of a "short int" */
  23. #define USHRT_MAX 65535 /* max value of "unsigned short int" */
  24. #define INT_MIN (-2147483647-1) /* min value of an "int" */
  25. #define INT_MAX 2147483647 /* max value of an "int" */
  26. #define UINT_MAX 4294967295U /* max value of an "unsigned int" */
  27. #define LONG_MIN (-2147483647L-1L) /* min value of a "long int" */
  28. #define LONG_MAX 2147483647L /* max value of a "long int" */
  29. #define ULONG_MAX 4294967295UL /* max value of "unsigned long int" */
  30. #if defined(__EXTENSIONS__) || __STDC__ - 0 == 0 || \
  31. defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
  32. #define SSIZE_MAX INT_MAX /* max value of an "ssize_t" */
  33. /*
  34. * ARG_MAX is calculated as follows:
  35. * NCARGS - ((sizeof(struct arg_hunk *))*(0x10000/(sizeof)(struct arg_hunk)))
  36. */
  37. #define ARG_MAX 1048320 /* max length of arguments to exec */
  38. #define LINK_MAX 32767 /* max # of links to a single file */
  39. #ifndef MAX_CANON
  40. #define MAX_CANON 256 /* max bytes in line for canonical processing */
  41. #endif
  42. #ifndef MAX_INPUT
  43. #define MAX_INPUT 512 /* max size of a char input buffer */
  44. #endif
  45. #define NGROUPS_MAX 16 /* max number of groups for a user */
  46. #ifndef PATH_MAX
  47. #define PATH_MAX 1024 /* max # of characters in a path name */
  48. #endif
  49. #define PIPE_BUF 5120 /* max # bytes atomic in write to a pipe */
  50. #ifndef TMP_MAX
  51. #define TMP_MAX 17576 /* 26 * 26 * 26 */
  52. #endif
  53. /*
  54. * POSIX conformant definitions - An implementation may define
  55. * other symbols which reflect the actual implementation. Alternate
  56. * definitions may not be as restrictive as the POSIX definitions.
  57. */
  58. #define _POSIX_AIO_LISTIO_MAX 2
  59. #define _POSIX_AIO_MAX 1
  60. #define _POSIX_ARG_MAX 4096
  61. #define _POSIX_CHILD_MAX 6
  62. #define _POSIX_DELAYTIMER_MAX 32
  63. #define _POSIX_LINK_MAX 8
  64. #define _POSIX_MAX_CANON 255
  65. #define _POSIX_MAX_INPUT 255
  66. #define _POSIX_MQ_OPEN_MAX 8
  67. #define _POSIX_MQ_PRIO_MAX 32
  68. #define _POSIX_NAME_MAX 14
  69. #define _POSIX_NGROUPS_MAX 0
  70. #define _POSIX_OPEN_MAX 16
  71. #define _POSIX_PATH_MAX 255
  72. #define _POSIX_PIPE_BUF 512
  73. #define _POSIX_RTSIG_MAX 8
  74. #define _POSIX_SEM_NSEMS_MAX 256
  75. #define _POSIX_SEM_VALUE_MAX 32767
  76. #define _POSIX_SIGQUEUE_MAX 32
  77. #define _POSIX_SSIZE_MAX 32767
  78. #define _POSIX_STREAM_MAX 8
  79. #define _POSIX_TIMER_MAX 32
  80. #define _POSIX_TZNAME_MAX 3
  81. /* POSIX.1c conformant */
  82. #define _POSIX_LOGIN_NAME_MAX 9
  83. #define _POSIX_THREAD_DESTRUCTOR_INTERATION 4
  84. #define _POSIX_THREAD_KEYS_MAX 128
  85. #define _POSIX_THREAD_THREADS_MAX 64
  86. #define _POSIX_TTY_NAME_MAX 9
  87. /*
  88. * POSIX.2 and XPG4-XSH4 conformant definitions
  89. */
  90. #define _POSIX2_BC_BASE_MAX 99
  91. #define _POSIX2_BC_DIM_MAX 2048
  92. #define _POSIX2_BC_SCALE_MAX 99
  93. #define _POSIX2_BC_STRING_MAX 1000
  94. #define _POSIX2_COLL_WEIGHTS_MAX 2
  95. #define _POSIX2_EXPR_NEST_MAX 32
  96. #define _POSIX2_LINE_MAX 2048
  97. #define _POSIX2_RE_DUP_MAX 255
  98. #define BC_BASE_MAX _POSIX2_BC_BASE_MAX
  99. #define BC_DIM_MAX _POSIX2_BC_DIM_MAX
  100. #define BC_SCALE_MAX _POSIX2_BC_SCALE_MAX
  101. #define BC_STRING_MAX _POSIX2_BC_STRING_MAX
  102. #define COLL_WEIGHTS_MAX _POSIX2_COLL_WEIGHTS_MAX
  103. #define EXPR_NEST_MAX _POSIX2_EXPR_NEST_MAX
  104. #define LINE_MAX _POSIX2_LINE_MAX
  105. #define RE_DUP_MAX _POSIX2_RE_DUP_MAX
  106. #endif /* defined(__EXTENSIONS__) || __STDC__ - 0 == 0 || ... */
  107. #if defined(__EXTENSIONS__) || \
  108. (__STDC__ - 0 == 0 && !defined(_POSIX_C_SOURCE)) || \
  109. defined(_XOPEN_SOURCE)
  110. #define PASS_MAX 8 /* max # of characters in a password */
  111. #define CHARCLASS_NAME_MAX 14 /* max # bytes in a char class name */
  112. #define NL_ARGMAX 9 /* max value of "digit" in calls to the */
  113. /* NLS printf() and scanf() */
  114. #define NL_LANGMAX 14 /* max # of bytes in a LANG name */
  115. #define NL_MSGMAX 32767 /* max message number */
  116. #define NL_NMAX 1 /* max # bytes in N-to-1 mapping characters */
  117. #define NL_SETMAX 255 /* max set number */
  118. #define NL_TEXTMAX 2048 /* max set number */
  119. #define NZERO 20 /* default process priority */
  120. #define WORD_BIT 32 /* # of bits in a "word" or "int" */
  121. #define LONG_BIT 32 /* # of bits in a "long" */
  122. #define DBL_DIG 15 /* digits of precision of a "double" */
  123. //#define DBL_MAX 1.7976931348623157E+308 /* max decimal value of a */
  124. /* "double" */
  125. //#define DBL_MIN 2.2250738585072014E-308 /* min decimal value of a */
  126. /* "double" */
  127. #define FLT_DIG 6 /* digits of precision of a "float" */
  128. //#define FLT_MAX 3.402823466E+38F /* max decimal value of a "float" */
  129. //#define FLT_MIN 1.175494351E-38F /* min decimal value of a "float" */
  130. #endif /* defined(__EXTENSIONS__) || (__STDC__ - 0 == 0 && ... */
  131. #if defined(__EXTENSIONS__) || (__STDC__ - 0 == 0 && \
  132. !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE))
  133. #define FCHR_MAX 1048576 /* max size of a file in bytes */
  134. #define PID_MAX 30000 /* max value for a process ID */
  135. /*
  136. * POSIX 1003.1a, section 2.9.5, table 2-5 contains [NAME_MAX] and the
  137. * related text states:
  138. *
  139. * A definition of one of the values from Table 2-5 shall be omitted from the
  140. * <limits.h> on specific implementations where the corresponding value is
  141. * equal to or greater than the stated minimum, but where the value can vary
  142. * depending on the file to which it is applied. The actual value supported for
  143. * a specific pathname shall be provided by the pathconf() (5.7.1) function.
  144. *
  145. * This is clear that any machine supporting multiple file system types
  146. * and/or a network can not include this define, regardless of protection
  147. * by the _POSIX_SOURCE and _POSIX_C_SOURCE flags.
  148. *
  149. * #define NAME_MAX 14
  150. */
  151. #define CHILD_MAX 25 /* max # of processes per user id */
  152. #ifndef OPEN_MAX
  153. #define OPEN_MAX 64 /* max # of files a process can have open */
  154. #endif
  155. #define PIPE_MAX 5120 /* max # bytes written to a pipe in a write */
  156. #define STD_BLK 1024 /* # bytes in a physical I/O block */
  157. #define UID_MAX 60002 /* max value for a user or group ID */
  158. #define USI_MAX 4294967295 /* max decimal value of an "unsigned" */
  159. #define SYSPID_MAX 1 /* max pid of system processes */
  160. #ifndef SYS_NMLN /* also defined in sys/utsname.h */
  161. #define SYS_NMLN 257 /* 4.0 size of utsname elements */
  162. #endif
  163. #ifndef CLK_TCK
  164. extern long _sysconf(int); /* System Private interface to sysconf() */
  165. #define CLK_TCK _sysconf(3) /* 3 is _SC_CLK_TCK */
  166. #endif
  167. #define LOGNAME_MAX 8 /* max # of characters in a login name */
  168. #define TTYNAME_MAX 128 /* max # of characters in a tty name */
  169. /*
  170. * Size constants for long long
  171. */
  172. #define LLONG_MIN (-9223372036854775807LL-1LL)
  173. #define LLONG_MAX 9223372036854775807LL
  174. #define ULLONG_MAX 18446744073709551615ULL
  175. #endif /* defined(__EXTENSIONS__) || (__STDC__ - 0 == 0 && ... */
  176. /*
  177. * POSIX.1c Note:
  178. * PTHREAD_STACK_MIN is also defined in <pthread.h>.
  179. */
  180. #if defined(__EXTENSIONS__) || (_POSIX_C_SOURCE >= 199506L)
  181. #include <sys/unistd.h>
  182. extern long _sysconf(int); /* System Private interface to sysconf() */
  183. #define PTHREAD_STACK_MIN _sysconf(_SC_THREAD_STACK_MIN)
  184. #endif /* defined(__EXTENSIONS__) || (_POSIX_C_SOURCE >= 199506L) */
  185. #endif