Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
  2.    This file is part of the GNU C Library.
  3.  
  4.    The GNU C Library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Lesser General Public
  6.    License as published by the Free Software Foundation; either
  7.    version 2.1 of the License, or (at your option) any later version.
  8.  
  9.    The GNU C 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 GNU
  12.    Lesser General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU Lesser General Public
  15.    License along with the GNU C Library; if not, write to the Free
  16.    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  17.    02111-1307 USA.  */
  18.  
  19. /*
  20.  *      ISO C99: 7.18 Integer types <stdint.h>
  21.  */
  22.  
  23. #ifndef _STDINT_H
  24. #define _STDINT_H       1
  25.  
  26. #include <features.h>
  27. #include <bits/wchar.h>
  28. #include <bits/wordsize.h>
  29.  
  30. /* Exact integral types.  */
  31.  
  32. /* Signed.  */
  33.  
  34. /* There is some amount of overlap with <sys/types.h> as known by inet code */
  35. #ifndef __int8_t_defined
  36. #define __int8_t_defined
  37. typedef signed char             int8_t;
  38. typedef short int               int16_t;
  39. typedef int                     int32_t;
  40. # if __WORDSIZE == 64
  41. typedef long int                int64_t;
  42. # else
  43. typedef long long int           int64_t;
  44. # endif
  45. #endif
  46.  
  47. /* Unsigned.  */
  48. typedef unsigned char           uint8_t;
  49. typedef unsigned short int      uint16_t;
  50. #ifndef __uint32_t_defined
  51. typedef unsigned int            uint32_t;
  52. # define __uint32_t_defined
  53. #endif
  54. #if __WORDSIZE == 64
  55. typedef unsigned long int       uint64_t;
  56. #else
  57. typedef unsigned long long int  uint64_t;
  58. #endif
  59.  
  60.  
  61. /* Small types.  */
  62.  
  63. /* Signed.  */
  64. typedef signed char             int_least8_t;
  65. typedef short int               int_least16_t;
  66. typedef int                     int_least32_t;
  67. #if __WORDSIZE == 64
  68. typedef long int                int_least64_t;
  69. #else
  70. typedef long long int           int_least64_t;
  71. #endif
  72.  
  73. /* Unsigned.  */
  74. typedef unsigned char           uint_least8_t;
  75. typedef unsigned short int      uint_least16_t;
  76. typedef unsigned int            uint_least32_t;
  77. #if __WORDSIZE == 64
  78. typedef unsigned long int       uint_least64_t;
  79. #else
  80. typedef unsigned long long int  uint_least64_t;
  81. #endif
  82.  
  83.  
  84. /* Fast types.  */
  85.  
  86. /* Signed.  */
  87. typedef signed char             int_fast8_t;
  88. #if __WORDSIZE == 64
  89. typedef long int                int_fast16_t;
  90. typedef long int                int_fast32_t;
  91. typedef long int                int_fast64_t;
  92. #else
  93. typedef int                     int_fast16_t;
  94. typedef int                     int_fast32_t;
  95. typedef long long int           int_fast64_t;
  96. #endif
  97.  
  98. /* Unsigned.  */
  99. typedef unsigned char           uint_fast8_t;
  100. #if __WORDSIZE == 64
  101. typedef unsigned long int       uint_fast16_t;
  102. typedef unsigned long int       uint_fast32_t;
  103. typedef unsigned long int       uint_fast64_t;
  104. #else
  105. typedef unsigned int            uint_fast16_t;
  106. typedef unsigned int            uint_fast32_t;
  107. typedef unsigned long long int  uint_fast64_t;
  108. #endif
  109.  
  110.  
  111. /* Types for `void *' pointers.  */
  112. #if __WORDSIZE == 64
  113. # ifndef __intptr_t_defined
  114. typedef long int                intptr_t;
  115. #  define __intptr_t_defined
  116. # endif
  117. typedef unsigned long int       uintptr_t;
  118. #else
  119. # ifndef __intptr_t_defined
  120. typedef int                     intptr_t;
  121. #  define __intptr_t_defined
  122. # endif
  123. typedef unsigned int            uintptr_t;
  124. #endif
  125.  
  126.  
  127. /* Largest integral types.  */
  128. #if __WORDSIZE == 64
  129. typedef long int                intmax_t;
  130. typedef unsigned long int       uintmax_t;
  131. #else
  132. typedef long long int           intmax_t;
  133. typedef unsigned long long int  uintmax_t;
  134. #endif
  135.  
  136.  
  137. /* The ISO C99 standard specifies that in C++ implementations these
  138.    macros should only be defined if explicitly requested.  */
  139. #if !defined __cplusplus || defined __STDC_LIMIT_MACROS
  140.  
  141. # if __WORDSIZE == 64
  142. #  define __INT64_C(c)  c ## L
  143. #  define __UINT64_C(c) c ## UL
  144. # else
  145. #  define __INT64_C(c)  c ## LL
  146. #  define __UINT64_C(c) c ## ULL
  147. # endif
  148.  
  149. /* Limits of integral types.  */
  150.  
  151. /* Minimum of signed integral types.  */
  152. # define INT8_MIN               (-128)
  153. # define INT16_MIN              (-32767-1)
  154. # define INT32_MIN              (-2147483647-1)
  155. # define INT64_MIN              (-__INT64_C(9223372036854775807)-1)
  156. /* Maximum of signed integral types.  */
  157. # define INT8_MAX               (127)
  158. # define INT16_MAX              (32767)
  159. # define INT32_MAX              (2147483647)
  160. # define INT64_MAX              (__INT64_C(9223372036854775807))
  161.  
  162. /* Maximum of unsigned integral types.  */
  163. # define UINT8_MAX              (255)
  164. # define UINT16_MAX             (65535)
  165. # define UINT32_MAX             (4294967295U)
  166. # define UINT64_MAX             (__UINT64_C(18446744073709551615))
  167.  
  168.  
  169. /* Minimum of signed integral types having a minimum size.  */
  170. # define INT_LEAST8_MIN         (-128)
  171. # define INT_LEAST16_MIN        (-32767-1)
  172. # define INT_LEAST32_MIN        (-2147483647-1)
  173. # define INT_LEAST64_MIN        (-__INT64_C(9223372036854775807)-1)
  174. /* Maximum of signed integral types having a minimum size.  */
  175. # define INT_LEAST8_MAX         (127)
  176. # define INT_LEAST16_MAX        (32767)
  177. # define INT_LEAST32_MAX        (2147483647)
  178. # define INT_LEAST64_MAX        (__INT64_C(9223372036854775807))
  179.  
  180. /* Maximum of unsigned integral types having a minimum size.  */
  181. # define UINT_LEAST8_MAX        (255)
  182. # define UINT_LEAST16_MAX       (65535)
  183. # define UINT_LEAST32_MAX       (4294967295U)
  184. # define UINT_LEAST64_MAX       (__UINT64_C(18446744073709551615))
  185.  
  186.  
  187. /* Minimum of fast signed integral types having a minimum size.  */
  188. # define INT_FAST8_MIN          (-128)
  189. # if __WORDSIZE == 64
  190. #  define INT_FAST16_MIN        (-9223372036854775807L-1)
  191. #  define INT_FAST32_MIN        (-9223372036854775807L-1)
  192. # else
  193. #  define INT_FAST16_MIN        (-2147483647-1)
  194. #  define INT_FAST32_MIN        (-2147483647-1)
  195. # endif
  196. # define INT_FAST64_MIN         (-__INT64_C(9223372036854775807)-1)
  197. /* Maximum of fast signed integral types having a minimum size.  */
  198. # define INT_FAST8_MAX          (127)
  199. # if __WORDSIZE == 64
  200. #  define INT_FAST16_MAX        (9223372036854775807L)
  201. #  define INT_FAST32_MAX        (9223372036854775807L)
  202. # else
  203. #  define INT_FAST16_MAX        (2147483647)
  204. #  define INT_FAST32_MAX        (2147483647)
  205. # endif
  206. # define INT_FAST64_MAX         (__INT64_C(9223372036854775807))
  207.  
  208. /* Maximum of fast unsigned integral types having a minimum size.  */
  209. # define UINT_FAST8_MAX         (255)
  210. # if __WORDSIZE == 64
  211. #  define UINT_FAST16_MAX       (18446744073709551615UL)
  212. #  define UINT_FAST32_MAX       (18446744073709551615UL)
  213. # else
  214. #  define UINT_FAST16_MAX       (4294967295U)
  215. #  define UINT_FAST32_MAX       (4294967295U)
  216. # endif
  217. # define UINT_FAST64_MAX        (__UINT64_C(18446744073709551615))
  218.  
  219.  
  220. /* Values to test for integral types holding `void *' pointer.  */
  221. # if __WORDSIZE == 64
  222. #  define INTPTR_MIN            (-9223372036854775807L-1)
  223. #  define INTPTR_MAX            (9223372036854775807L)
  224. #  define UINTPTR_MAX           (18446744073709551615UL)
  225. # else
  226. #  define INTPTR_MIN            (-2147483647-1)
  227. #  define INTPTR_MAX            (2147483647)
  228. #  define UINTPTR_MAX           (4294967295U)
  229. # endif
  230.  
  231.  
  232. /* Minimum for largest signed integral type.  */
  233. # define INTMAX_MIN             (-__INT64_C(9223372036854775807)-1)
  234. /* Maximum for largest signed integral type.  */
  235. # define INTMAX_MAX             (__INT64_C(9223372036854775807))
  236.  
  237. /* Maximum for largest unsigned integral type.  */
  238. # define UINTMAX_MAX            (__UINT64_C(18446744073709551615))
  239.  
  240.  
  241. /* Limits of other integer types.  */
  242.  
  243. /* Limits of `ptrdiff_t' type.  */
  244. # if __WORDSIZE == 64
  245. #  define PTRDIFF_MIN           (-9223372036854775807L-1)
  246. #  define PTRDIFF_MAX           (9223372036854775807L)
  247. # else
  248. #  define PTRDIFF_MIN           (-2147483647-1)
  249. #  define PTRDIFF_MAX           (2147483647)
  250. # endif
  251.  
  252. /* Limits of `sig_atomic_t'.  */
  253. # define SIG_ATOMIC_MIN         (-2147483647-1)
  254. # define SIG_ATOMIC_MAX         (2147483647)
  255.  
  256. /* Limit of `size_t' type.  */
  257. # if __WORDSIZE == 64
  258. #  define SIZE_MAX              (18446744073709551615UL)
  259. # else
  260. #  define SIZE_MAX              (4294967295U)
  261. # endif
  262.  
  263. /* Limits of `wchar_t'.  */
  264. # ifndef WCHAR_MIN
  265. /* These constants might also be defined in <wchar.h>.  */
  266. #  define WCHAR_MIN             __WCHAR_MIN
  267. #  define WCHAR_MAX             __WCHAR_MAX
  268. # endif
  269.  
  270. /* Limits of `wint_t'.  */
  271. # define WINT_MIN               (0u)
  272. # define WINT_MAX               (4294967295u)
  273.  
  274. #endif  /* C++ && limit macros */
  275.  
  276.  
  277. /* The ISO C99 standard specifies that in C++ implementations these
  278.    should only be defined if explicitly requested.  */
  279. #if !defined __cplusplus || defined __STDC_CONSTANT_MACROS
  280.  
  281. /* Signed.  */
  282. # define INT8_C(c)      c
  283. # define INT16_C(c)     c
  284. # define INT32_C(c)     c
  285. # if __WORDSIZE == 64
  286. #  define INT64_C(c)    c ## L
  287. # else
  288. #  define INT64_C(c)    c ## LL
  289. # endif
  290.  
  291. /* Unsigned.  */
  292. # define UINT8_C(c)     c ## U
  293. # define UINT16_C(c)    c ## U
  294. # define UINT32_C(c)    c ## U
  295. # if __WORDSIZE == 64
  296. #  define UINT64_C(c)   c ## UL
  297. # else
  298. #  define UINT64_C(c)   c ## ULL
  299. # endif
  300.  
  301. /* Maximal type.  */
  302. # if __WORDSIZE == 64
  303. #  define INTMAX_C(c)   c ## L
  304. #  define UINTMAX_C(c)  c ## UL
  305. # else
  306. #  define INTMAX_C(c)   c ## LL
  307. #  define UINTMAX_C(c)  c ## ULL
  308. # endif
  309.  
  310. #endif  /* C++ && constant macros */
  311.  
  312. #endif /* stdint.h */
  313.