stdint.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. /*-------------------------------------------------------------------------
  2. stdint.h - ISO C99 7.18 Integer types <stdint.h>
  3. Copyright (C) 2005, Maarten Brock, sourceforge.brock@dse.nl
  4. Copyright (C) 2011, Philipp Klaus Krause, pkk@spth.de
  5. This library is free software; you can redistribute it and/or modify it
  6. under the terms of the GNU General Public License as published by the
  7. Free Software Foundation; either version 2, or (at your option) any
  8. later version.
  9. This 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
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this library; see the file COPYING. If not, write to the
  15. Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
  16. MA 02110-1301, USA.
  17. As a special exception, if you link this library with other files,
  18. some of which are compiled with SDCC, to produce an executable,
  19. this library does not by itself cause the resulting executable to
  20. be covered by the GNU General Public License. This exception does
  21. not however invalidate any other reasons why the executable file
  22. might be covered by the GNU General Public License.
  23. -------------------------------------------------------------------------*/
  24. #ifndef _STDINT_H
  25. #define _STDINT_H 1
  26. /* Exact integral types. */
  27. #if !defined(__SDCC_mcs51) && !defined(__SDCC_ds390) && !defined(__SDCC_ds400) && !defined(__SDCC_pic14) && !defined(__SDCC_pic16)
  28. #if __STDC_VERSION__ >= 199901L
  29. #define __SDCC_LONGLONG
  30. #endif
  31. #endif
  32. /* Signed. */
  33. typedef signed char int8_t;
  34. typedef short int int16_t;
  35. typedef long int int32_t;
  36. #ifdef __SDCC_LONGLONG
  37. typedef long long int int64_t;
  38. #endif
  39. /* Unsigned. */
  40. typedef unsigned char uint8_t;
  41. typedef unsigned short int uint16_t;
  42. typedef unsigned long int uint32_t;
  43. #ifdef __SDCC_LONGLONG
  44. typedef unsigned long long int uint64_t;
  45. #endif
  46. /* Small types. */
  47. /* Signed. */
  48. typedef signed char int_least8_t;
  49. typedef short int int_least16_t;
  50. typedef long int int_least32_t;
  51. #ifdef __SDCC_LONGLONG
  52. typedef long long int int_least64_t;
  53. #endif
  54. /* Unsigned. */
  55. typedef unsigned char uint_least8_t;
  56. typedef unsigned short int uint_least16_t;
  57. typedef unsigned long int uint_least32_t;
  58. #ifdef __SDCC_LONGLONG
  59. typedef unsigned long long int uint_least64_t;
  60. #endif
  61. /* Fast types. */
  62. /* Signed. */
  63. typedef signed char int_fast8_t;
  64. typedef int int_fast16_t;
  65. typedef long int int_fast32_t;
  66. #ifdef __SDCC_LONGLONG
  67. typedef long long int int_fast64_t;
  68. #endif
  69. /* Unsigned. */
  70. typedef unsigned char uint_fast8_t;
  71. typedef unsigned int uint_fast16_t;
  72. typedef unsigned long int uint_fast32_t;
  73. #ifdef __SDCC_LONGLONG
  74. typedef unsigned long long int uint_fast64_t;
  75. #endif
  76. /* Types for `void *' pointers. */
  77. #if defined (__SDCC_mcs51) || defined (__SDCC_ds390)
  78. typedef long int intptr_t;
  79. typedef unsigned long int uintptr_t;
  80. #else
  81. typedef int intptr_t;
  82. typedef unsigned int uintptr_t;
  83. #endif
  84. /* Largest integral types. */
  85. #ifndef __SDCC_LONGLONG
  86. typedef long int intmax_t;
  87. typedef unsigned long int uintmax_t;
  88. #else
  89. typedef long long int intmax_t;
  90. typedef unsigned long long int uintmax_t;
  91. #endif
  92. /* Limits of integral types. */
  93. /* Minimum of signed integral types. */
  94. #define INT8_MIN (-128)
  95. #define INT16_MIN (-32767-1)
  96. #define INT32_MIN (-2147483647L-1)
  97. #ifdef __SDCC_LONGLONG
  98. #define INT64_MIN (-9223372036854775807LL-1)
  99. #endif
  100. /* Maximum of signed integral types. */
  101. #define INT8_MAX (127)
  102. #define INT16_MAX (32767)
  103. #define INT32_MAX (2147483647L)
  104. #ifdef __SDCC_LONGLONG
  105. #define INT64_MAX (9223372036854775807LL)
  106. #endif
  107. /* Maximum of unsigned integral types. */
  108. #define UINT8_MAX (255)
  109. #define UINT16_MAX (65535)
  110. #define UINT32_MAX (4294967295UL)
  111. #ifdef __SDCC_LONGLONG
  112. #define UINT64_MAX (18446744073709551615ULL)
  113. #endif
  114. /* Minimum of signed integral types having a minimum size. */
  115. #define INT_LEAST8_MIN INT8_MIN
  116. #define INT_LEAST16_MIN INT16_MIN
  117. #define INT_LEAST32_MIN INT32_MIN
  118. #ifdef __SDCC_LONGLONG
  119. #define INT_LEAST64_MIN INT64_MIN
  120. #endif
  121. /* Maximum of signed integral types having a minimum size. */
  122. #define INT_LEAST8_MAX INT8_MAX
  123. #define INT_LEAST16_MAX INT16_MAX
  124. #define INT_LEAST32_MAX INT32_MAX
  125. #ifdef __SDCC_LONGLONG
  126. #define INT_LEAST64_MAX INT64_MAX
  127. #endif
  128. /* Maximum of unsigned integral types having a minimum size. */
  129. #define UINT_LEAST8_MAX UINT8_MAX
  130. #define UINT_LEAST16_MAX UINT16_MAX
  131. #define UINT_LEAST32_MAX UINT32_MAX
  132. #ifdef __SDCC_LONGLONG
  133. #define UINT_LEAST64_MAX UINT64_MAX
  134. #endif
  135. /* Minimum of fast signed integral types having a minimum size. */
  136. #define INT_FAST8_MIN INT8_MIN
  137. #define INT_FAST16_MIN INT16_MIN
  138. #define INT_FAST32_MIN INT32_MIN
  139. #ifdef __SDCC_LONGLONG
  140. #define INT_FAST64_MIN INT64_MIN
  141. #endif
  142. /* Maximum of fast signed integral types having a minimum size. */
  143. #define INT_FAST8_MAX INT8_MAX
  144. #define INT_FAST16_MAX INT16_MAX
  145. #define INT_FAST32_MAX INT32_MAX
  146. #ifdef __SDCC_LONGLONG
  147. #define INT_FAST64_MAX INT64_MAX
  148. #endif
  149. /* Maximum of fast unsigned integral types having a minimum size. */
  150. #define UINT_FAST8_MAX UINT8_MAX
  151. #define UINT_FAST16_MAX UINT16_MAX
  152. #define UINT_FAST32_MAX UINT32_MAX
  153. #ifdef __SDCC_LONGLONG
  154. #define UINT_FAST64_MAX UINT64_MAX
  155. #endif
  156. /* Values to test for integral types holding `void *' pointer. */
  157. #if defined (__SDCC_mcs51) || defined (__SDCC_ds390)
  158. #define INTPTR_MIN (-2147483647L-1)
  159. #define INTPTR_MAX (2147483647L)
  160. #define UINTPTR_MAX (4294967295UL)
  161. #else
  162. #define INTPTR_MIN (-32767-1)
  163. #define INTPTR_MAX (32767)
  164. #define UINTPTR_MAX (65535)
  165. #endif
  166. /* Minimum for largest signed integral type. */
  167. #define INTMAX_MIN (-__INT32_C(-2147483647L)-1)
  168. /* Maximum for largest signed integral type. */
  169. #define INTMAX_MAX (__INT32_C(2147483647L))
  170. /* Maximum for largest unsigned integral type. */
  171. #define UINTMAX_MAX (__UINT32_C(4294967295UL))
  172. /* Limits of other integer types. */
  173. /* Limits of `ptrdiff_t' type. */
  174. #if defined (__SDCC_mcs51) || defined (__SDCC_ds390)
  175. #define PTRDIFF_MIN (-2147483647L-1)
  176. #define PTRDIFF_MAX (2147483647L)
  177. #else
  178. #define PTRDIFF_MIN (-32767-1)
  179. #define PTRDIFF_MAX (32767)
  180. #endif
  181. /* Limit of `size_t' type. */
  182. #define SIZE_MAX (65535u)
  183. /* Signed. */
  184. #define INT8_C(c) c
  185. #define INT16_C(c) c
  186. #define INT32_C(c) c ## L
  187. #ifdef __SDCC_LONGLONG
  188. #define INT64_C(c) c ## LL
  189. #endif
  190. /* Unsigned. */
  191. #define UINT8_C(c) c ## U
  192. #define UINT16_C(c) c ## U
  193. #define UINT32_C(c) c ## UL
  194. #ifdef __SDCC_LONGLONG
  195. #define UINT64_C(c) c ## ULL
  196. #endif
  197. #define WCHAR_MIN CHAR_MIN
  198. #define WCHAR_MAX CHAR_MAX
  199. #define WINT_MIN INT_MIN
  200. #define WINT_MAX INT_MAX
  201. /* Maximal type. */
  202. #ifdef __SDCC_LONGLONG
  203. #define INTMAX_C(c) c ## LL
  204. #define UINTMAX_C(c) c ## ULL
  205. #else
  206. #define INTMAX_C(c) c ## L
  207. #define UINTMAX_C(c) c ## UL
  208. #endif
  209. /* Bounds-checking interfaces from annex K of the C11 standard. */
  210. #if defined (__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__
  211. #define RSIZE_MAX SIZE_MAX
  212. #endif
  213. #endif /* stdint.h */