stdint.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*****************************************************************************/
  2. /* STDINT.H v8.2.2 */
  3. /* */
  4. /* Copyright (c) 2002-2017 Texas Instruments Incorporated */
  5. /* http://www.ti.com/ */
  6. /* */
  7. /* Redistribution and use in source and binary forms, with or without */
  8. /* modification, are permitted provided that the following conditions */
  9. /* are met: */
  10. /* */
  11. /* Redistributions of source code must retain the above copyright */
  12. /* notice, this list of conditions and the following disclaimer. */
  13. /* */
  14. /* Redistributions in binary form must reproduce the above copyright */
  15. /* notice, this list of conditions and the following disclaimer in */
  16. /* the documentation and/or other materials provided with the */
  17. /* distribution. */
  18. /* */
  19. /* Neither the name of Texas Instruments Incorporated nor the names */
  20. /* of its contributors may be used to endorse or promote products */
  21. /* derived from this software without specific prior written */
  22. /* permission. */
  23. /* */
  24. /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
  25. /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
  26. /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */
  27. /* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
  28. /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
  29. /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
  30. /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */
  31. /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */
  32. /* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
  33. /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */
  34. /* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
  35. /* */
  36. /*****************************************************************************/
  37. #ifndef _STDINT_H_
  38. #define _STDINT_H_
  39. /* 7.18.1.1 Exact-width integer types */
  40. typedef signed char int8_t;
  41. typedef unsigned char uint8_t;
  42. typedef short int16_t;
  43. typedef unsigned short uint16_t;
  44. typedef int int32_t;
  45. typedef unsigned int uint32_t;
  46. typedef __int40_t int40_t;
  47. typedef unsigned __int40_t uint40_t;
  48. typedef long long int64_t;
  49. typedef unsigned long long uint64_t;
  50. /* 7.18.1.2 Minimum-width integer types */
  51. typedef int8_t int_least8_t;
  52. typedef uint8_t uint_least8_t;
  53. typedef int16_t int_least16_t;
  54. typedef uint16_t uint_least16_t;
  55. typedef int32_t int_least32_t;
  56. typedef uint32_t uint_least32_t;
  57. typedef int40_t int_least40_t;
  58. typedef uint40_t uint_least40_t;
  59. typedef int64_t int_least64_t;
  60. typedef uint64_t uint_least64_t;
  61. /* 7.18.1.3 Fastest minimum-width integer types */
  62. typedef int32_t int_fast8_t;
  63. typedef uint32_t uint_fast8_t;
  64. typedef int32_t int_fast16_t;
  65. typedef uint32_t uint_fast16_t;
  66. typedef int32_t int_fast32_t;
  67. typedef uint32_t uint_fast32_t;
  68. typedef int40_t int_fast40_t;
  69. typedef uint40_t uint_fast40_t;
  70. typedef int64_t int_fast64_t;
  71. typedef uint64_t uint_fast64_t;
  72. /* 7.18.1.4 Integer types capable of holding object pointers */
  73. typedef int intptr_t;
  74. typedef unsigned int uintptr_t;
  75. /* 7.18.1.5 Greatest-width integer types */
  76. typedef long long intmax_t;
  77. typedef unsigned long long uintmax_t;
  78. /*
  79. According to footnotes in the 1999 C standard, "C++ implementations
  80. should define these macros only when __STDC_LIMIT_MACROS is defined
  81. before <stdint.h> is included."
  82. */
  83. #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
  84. /* 7.18.2 Limits of specified width integer types */
  85. #define INT8_MAX 0x7f
  86. #define INT8_MIN (-INT8_MAX-1)
  87. #define UINT8_MAX 0xff
  88. #define INT16_MAX 0x7fff
  89. #define INT16_MIN (-INT16_MAX-1)
  90. #define UINT16_MAX 0xffff
  91. #define INT32_MAX 0x7fffffff
  92. #define INT32_MIN (-INT32_MAX-1)
  93. #define UINT32_MAX 0xffffffff
  94. #define INT40_MAX 0x7fffffffff
  95. #define INT40_MIN (-INT40_MAX-1)
  96. #define UINT40_MAX 0xffffffffff
  97. #define INT64_MAX 0x7fffffffffffffff
  98. #define INT64_MIN (-INT64_MAX-1)
  99. #define UINT64_MAX 0xffffffffffffffff
  100. #define INT_LEAST8_MAX (INT8_MAX)
  101. #define INT_LEAST8_MIN (INT8_MIN)
  102. #define UINT_LEAST8_MAX (UINT8_MAX)
  103. #define INT_LEAST16_MAX (INT16_MAX)
  104. #define INT_LEAST16_MIN (INT16_MIN)
  105. #define UINT_LEAST16_MAX (UINT16_MAX)
  106. #define INT_LEAST32_MAX (INT32_MAX)
  107. #define INT_LEAST32_MIN (INT32_MIN)
  108. #define UINT_LEAST32_MAX (UINT32_MAX)
  109. #define INT_LEAST40_MAX (INT40_MAX)
  110. #define INT_LEAST40_MIN (INT40_MIN)
  111. #define UINT_LEAST40_MAX (UINT40_MAX)
  112. #define INT_LEAST64_MAX (INT64_MAX)
  113. #define INT_LEAST64_MIN (INT64_MIN)
  114. #define UINT_LEAST64_MAX (UINT64_MAX)
  115. #define INT_FAST8_MAX (INT32_MAX)
  116. #define INT_FAST8_MIN (INT32_MIN)
  117. #define UINT_FAST8_MAX (UINT32_MAX)
  118. #define INT_FAST16_MAX (INT32_MAX)
  119. #define INT_FAST16_MIN (INT32_MIN)
  120. #define UINT_FAST16_MAX (UINT32_MAX)
  121. #define INT_FAST32_MAX (INT32_MAX)
  122. #define INT_FAST32_MIN (INT32_MIN)
  123. #define UINT_FAST32_MAX (UINT32_MAX)
  124. #define INT_FAST40_MAX (INT40_MAX)
  125. #define INT_FAST40_MIN (INT40_MIN)
  126. #define UINT_FAST40_MAX (UINT40_MAX)
  127. #define INT_FAST64_MAX (INT64_MAX)
  128. #define INT_FAST64_MIN (INT64_MIN)
  129. #define UINT_FAST64_MAX (UINT64_MAX)
  130. #define INTPTR_MAX (INT32_MAX)
  131. #define INTPTR_MIN (INT32_MIN)
  132. #define UINTPTR_MAX (UINT32_MAX)
  133. #define INTMAX_MIN (INT64_MIN)
  134. #define INTMAX_MAX (INT64_MAX)
  135. #define UINTMAX_MAX (UINT64_MAX)
  136. /* 7.18.3 Limits of other integer types */
  137. #define PTRDIFF_MAX (INT32_MAX)
  138. #define PTRDIFF_MIN (INT32_MIN)
  139. #define SIG_ATOMIC_MIN (INT32_MIN)
  140. #define SIG_ATOMIC_MAX (INT32_MAX)
  141. #define SIZE_MAX (UINT32_MAX)
  142. #ifndef WCHAR_MAX
  143. #if !defined(__TI_WCHAR_T_BITS__) || __TI_WCHAR_T_BITS__ == 16
  144. #define WCHAR_MAX 0xffffu
  145. #else
  146. #define WCHAR_MAX 0xffffffffu
  147. #endif
  148. #endif
  149. #ifndef WCHAR_MIN
  150. #define WCHAR_MIN 0
  151. #endif
  152. #define WINT_MIN (INT32_MIN)
  153. #define WINT_MAX (INT32_MAX)
  154. /* 7.18.4.1 Macros for minimum-width integer constants */
  155. /*
  156. There is a defect report filed against the C99 standard concerning how
  157. the (U)INTN_C macros should be implemented. Please refer to --
  158. http://wwwold.dkuug.dk/JTC1/SC22/WG14/www/docs/dr_209.htm
  159. for more information. These macros are implemented according to the
  160. suggestion given at this web site.
  161. */
  162. #define INT8_C(value) ((int_least8_t)(value))
  163. #define UINT8_C(value) ((uint_least8_t)(value))
  164. #define INT16_C(value) ((int_least16_t)(value))
  165. #define UINT16_C(value) ((uint_least16_t)(value))
  166. #define INT32_C(value) ((int_least32_t)(value))
  167. #define UINT32_C(value) ((uint_least32_t)(value))
  168. #define INT40_C(value) ((int_least40_t)(value))
  169. #define UINT40_C(value) ((uint_least40_t)(value))
  170. #define INT64_C(value) ((int_least64_t)(value))
  171. #define UINT64_C(value) ((uint_least64_t)(value))
  172. /* 7.18.4.2 Macros for greatest-width integer constants */
  173. #define INTMAX_C(value) ((intmax_t)(value))
  174. #define UINTMAX_C(value) ((uintmax_t)(value))
  175. #endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
  176. #endif /* _STDINT_H_ */