c_stdint.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. #ifndef __c_stdint_h
  2. #define __c_stdint_h
  3. #include "c_types.h"
  4. #if 0
  5. /*
  6. * Depending on compiler version __int64 or __INT64_TYPE__ should be defined.
  7. */
  8. #ifndef __int64
  9. #ifdef __INT64_TYPE__
  10. #define __int64 __INT64_TYPE__
  11. #else
  12. #define __int64 long long
  13. #endif
  14. /* On some architectures neither of these may be defined - if so, fall
  15. through and error out if used. */
  16. #endif
  17. #ifndef __STDINT_DECLS
  18. #define __STDINT_DECLS
  19. #undef __CLIBNS
  20. #ifdef __cplusplus
  21. namespace std {
  22. #define __CLIBNS std::
  23. extern "C" {
  24. #else
  25. #define __CLIBNS
  26. #endif /* __cplusplus */
  27. /*
  28. * 'signed' is redundant below, except for 'signed char' and if
  29. * the typedef is used to declare a bitfield.
  30. * '__int64' is used instead of 'long long' so that this header
  31. * can be used in --strict mode.
  32. */
  33. /* 7.18.1.1 */
  34. /* exact-width signed integer types */
  35. typedef signed char int8_t;
  36. typedef signed short int int16_t;
  37. typedef signed int int32_t;
  38. typedef signed __int64 int64_t;
  39. /* exact-width unsigned integer types */
  40. typedef unsigned char uint8_t;
  41. typedef unsigned short int uint16_t;
  42. typedef unsigned int uint32_t;
  43. typedef unsigned __int64 uint64_t;
  44. /* 7.18.1.2 */
  45. /* smallest type of at least n bits */
  46. /* minimum-width signed integer types */
  47. typedef signed char int_least8_t;
  48. typedef signed short int int_least16_t;
  49. typedef signed int int_least32_t;
  50. typedef signed __int64 int_least64_t;
  51. /* minimum-width unsigned integer types */
  52. typedef unsigned char uint_least8_t;
  53. typedef unsigned short int uint_least16_t;
  54. typedef unsigned int uint_least32_t;
  55. typedef unsigned __int64 uint_least64_t;
  56. /* 7.18.1.3 */
  57. /* fastest minimum-width signed integer types */
  58. typedef signed int int_fast8_t;
  59. typedef signed int int_fast16_t;
  60. typedef signed int int_fast32_t;
  61. typedef signed __int64 int_fast64_t;
  62. /* fastest minimum-width unsigned integer types */
  63. typedef unsigned int uint_fast8_t;
  64. typedef unsigned int uint_fast16_t;
  65. typedef unsigned int uint_fast32_t;
  66. typedef unsigned __int64 uint_fast64_t;
  67. /* 7.18.1.4 integer types capable of holding object pointers */
  68. typedef signed int intptr_t;
  69. typedef unsigned int uintptr_t;
  70. /* 7.18.1.5 greatest-width integer types */
  71. typedef signed __int64 intmax_t;
  72. typedef unsigned __int64 uintmax_t;
  73. #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
  74. /* 7.18.2.1 */
  75. /* minimum values of exact-width signed integer types */
  76. #define INT8_MIN -128
  77. #define INT16_MIN -32768
  78. #define INT32_MIN (~0x7fffffff) /* -2147483648 is unsigned */
  79. #define INT64_MIN __ESCAPE__(~0x7fffffffffffffffll) /* -9223372036854775808 is unsigned */
  80. /* maximum values of exact-width signed integer types */
  81. #define INT8_MAX 127
  82. #define INT16_MAX 32767
  83. #define INT32_MAX 2147483647
  84. #define INT64_MAX __ESCAPE__(9223372036854775807ll)
  85. /* maximum values of exact-width unsigned integer types */
  86. #define UINT8_MAX 255
  87. #define UINT16_MAX 65535
  88. #define UINT32_MAX 4294967295u
  89. #define UINT64_MAX __ESCAPE__(18446744073709551615ull)
  90. /* 7.18.2.2 */
  91. /* minimum values of minimum-width signed integer types */
  92. #define INT_LEAST8_MIN -128
  93. #define INT_LEAST16_MIN -32768
  94. #define INT_LEAST32_MIN (~0x7fffffff)
  95. #define INT_LEAST64_MIN __ESCAPE__(~0x7fffffffffffffffll)
  96. /* maximum values of minimum-width signed integer types */
  97. #define INT_LEAST8_MAX 127
  98. #define INT_LEAST16_MAX 32767
  99. #define INT_LEAST32_MAX 2147483647
  100. #define INT_LEAST64_MAX __ESCAPE__(9223372036854775807ll)
  101. /* maximum values of minimum-width unsigned integer types */
  102. #define UINT_LEAST8_MAX 255
  103. #define UINT_LEAST16_MAX 65535
  104. #define UINT_LEAST32_MAX 4294967295u
  105. #define UINT_LEAST64_MAX __ESCAPE__(18446744073709551615ull)
  106. /* 7.18.2.3 */
  107. /* minimum values of fastest minimum-width signed integer types */
  108. #define INT_FAST8_MIN (~0x7fffffff)
  109. #define INT_FAST16_MIN (~0x7fffffff)
  110. #define INT_FAST32_MIN (~0x7fffffff)
  111. #define INT_FAST64_MIN __ESCAPE__(~0x7fffffffffffffffll)
  112. /* maximum values of fastest minimum-width signed integer types */
  113. #define INT_FAST8_MAX 2147483647
  114. #define INT_FAST16_MAX 2147483647
  115. #define INT_FAST32_MAX 2147483647
  116. #define INT_FAST64_MAX __ESCAPE__(9223372036854775807ll)
  117. /* maximum values of fastest minimum-width unsigned integer types */
  118. #define UINT_FAST8_MAX 4294967295u
  119. #define UINT_FAST16_MAX 4294967295u
  120. #define UINT_FAST32_MAX 4294967295u
  121. #define UINT_FAST64_MAX __ESCAPE__(18446744073709551615ull)
  122. /* 7.18.2.4 */
  123. /* minimum value of pointer-holding signed integer type */
  124. #define INTPTR_MIN (~0x7fffffff)
  125. /* maximum value of pointer-holding signed integer type */
  126. #define INTPTR_MAX 2147483647
  127. /* maximum value of pointer-holding unsigned integer type */
  128. #define UINTPTR_MAX 4294967295u
  129. /* 7.18.2.5 */
  130. /* minimum value of greatest-width signed integer type */
  131. #define INTMAX_MIN __ESCAPE__(~0x7fffffffffffffffll)
  132. /* maximum value of greatest-width signed integer type */
  133. #define INTMAX_MAX __ESCAPE__(9223372036854775807ll)
  134. /* maximum value of greatest-width unsigned integer type */
  135. #define UINTMAX_MAX __ESCAPE__(18446744073709551615ull)
  136. /* 7.18.3 */
  137. /* limits of ptrdiff_t */
  138. #define PTRDIFF_MIN (~0x7fffffff)
  139. #define PTRDIFF_MAX 2147483647
  140. /* limits of sig_atomic_t */
  141. #define SIG_ATOMIC_MIN (~0x7fffffff)
  142. #define SIG_ATOMIC_MAX 2147483647
  143. /* limit of size_t */
  144. #define SIZE_MAX 4294967295u
  145. /* limits of wchar_t */
  146. /* NB we have to undef and redef because they're defined in both
  147. * stdint.h and wchar.h */
  148. #undef WCHAR_MIN
  149. #undef WCHAR_MAX
  150. #if defined(__WCHAR32) || (defined(__ARM_SIZEOF_WCHAR_T) && __ARM_SIZEOF_WCHAR_T == 4)
  151. #define WCHAR_MIN 0
  152. #define WCHAR_MAX 0xffffffffU
  153. #else
  154. #define WCHAR_MIN 0
  155. #define WCHAR_MAX 65535
  156. #endif
  157. /* limits of wint_t */
  158. #define WINT_MIN (~0x7fffffff)
  159. #define WINT_MAX 2147483647
  160. #endif /* __STDC_LIMIT_MACROS */
  161. #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
  162. /* 7.18.4.1 macros for minimum-width integer constants */
  163. #define INT8_C(x) (x)
  164. #define INT16_C(x) (x)
  165. #define INT32_C(x) (x)
  166. #define INT64_C(x) __ESCAPE__(x ## ll)
  167. #define UINT8_C(x) (x ## u)
  168. #define UINT16_C(x) (x ## u)
  169. #define UINT32_C(x) (x ## u)
  170. #define UINT64_C(x) __ESCAPE__(x ## ull)
  171. /* 7.18.4.2 macros for greatest-width integer constants */
  172. #define INTMAX_C(x) __ESCAPE__(x ## ll)
  173. #define UINTMAX_C(x) __ESCAPE__(x ## ull)
  174. #endif /* __STDC_CONSTANT_MACROS */
  175. #ifdef __cplusplus
  176. } /* extern "C" */
  177. } /* namespace std */
  178. #endif /* __cplusplus */
  179. #endif /* __STDINT_DECLS */
  180. #ifdef __cplusplus
  181. #ifndef __STDINT_NO_EXPORTS
  182. using ::std::int8_t;
  183. using ::std::int16_t;
  184. using ::std::int32_t;
  185. using ::std::int64_t;
  186. using ::std::uint8_t;
  187. using ::std::uint16_t;
  188. using ::std::uint32_t;
  189. using ::std::uint64_t;
  190. using ::std::int_least8_t;
  191. using ::std::int_least16_t;
  192. using ::std::int_least32_t;
  193. using ::std::int_least64_t;
  194. using ::std::uint_least8_t;
  195. using ::std::uint_least16_t;
  196. using ::std::uint_least32_t;
  197. using ::std::uint_least64_t;
  198. using ::std::int_fast8_t;
  199. using ::std::int_fast16_t;
  200. using ::std::int_fast32_t;
  201. using ::std::int_fast64_t;
  202. using ::std::uint_fast8_t;
  203. using ::std::uint_fast16_t;
  204. using ::std::uint_fast32_t;
  205. using ::std::uint_fast64_t;
  206. using ::std::intptr_t;
  207. using ::std::uintptr_t;
  208. using ::std::intmax_t;
  209. using ::std::uintmax_t;
  210. #endif
  211. #endif /* __cplusplus */
  212. #endif
  213. #endif /* __c_stdint_h */
  214. /* end of c_stdint.h */