"Fossies" - the Fresh Open Source Software Archive

Member "usr/include/stdint.h" (19 Aug 2019, 12432 Bytes) of package /windows/misc/cygwin-20190819-x86_64.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2  * Copyright (c) 2004, 2005 by
    3  * Ralf Corsepius, Ulm/Germany. All rights reserved.
    4  *
    5  * Permission to use, copy, modify, and distribute this software
    6  * is freely granted, provided that this notice is preserved.
    7  */
    8 
    9 #ifndef _STDINT_H
   10 #define _STDINT_H
   11 
   12 #include <machine/_default_types.h>
   13 #include <sys/_intsup.h>
   14 #include <sys/_stdint.h>
   15 
   16 #ifdef __cplusplus
   17 extern "C" {
   18 #endif
   19 
   20 #ifdef ___int_least8_t_defined
   21 typedef __int_least8_t int_least8_t;
   22 typedef __uint_least8_t uint_least8_t;
   23 #define __int_least8_t_defined 1
   24 #endif
   25 
   26 #ifdef ___int_least16_t_defined
   27 typedef __int_least16_t int_least16_t;
   28 typedef __uint_least16_t uint_least16_t;
   29 #define __int_least16_t_defined 1
   30 #endif
   31 
   32 #ifdef ___int_least32_t_defined
   33 typedef __int_least32_t int_least32_t;
   34 typedef __uint_least32_t uint_least32_t;
   35 #define __int_least32_t_defined 1
   36 #endif
   37 
   38 #ifdef ___int_least64_t_defined
   39 typedef __int_least64_t int_least64_t;
   40 typedef __uint_least64_t uint_least64_t;
   41 #define __int_least64_t_defined 1
   42 #endif
   43 
   44 /*
   45  * Fastest minimum-width integer types
   46  *
   47  * Assume int to be the fastest type for all types with a width 
   48  * less than __INT_MAX__ rsp. INT_MAX
   49  */
   50 #ifdef __INT_FAST8_TYPE__
   51   typedef __INT_FAST8_TYPE__ int_fast8_t;
   52   typedef __UINT_FAST8_TYPE__ uint_fast8_t;
   53 #define __int_fast8_t_defined 1
   54 #elif __STDINT_EXP(INT_MAX) >= 0x7f
   55   typedef signed int int_fast8_t;
   56   typedef unsigned int uint_fast8_t;
   57 #define __int_fast8_t_defined 1
   58 #endif
   59 
   60 #ifdef __INT_FAST16_TYPE__
   61   typedef __INT_FAST16_TYPE__ int_fast16_t;
   62   typedef __UINT_FAST16_TYPE__ uint_fast16_t;
   63 #define __int_fast16_t_defined 1
   64 #elif __STDINT_EXP(INT_MAX) >= 0x7fff
   65   typedef signed int int_fast16_t;
   66   typedef unsigned int uint_fast16_t;
   67 #define __int_fast16_t_defined 1
   68 #endif
   69 
   70 #ifdef __INT_FAST32_TYPE__
   71   typedef __INT_FAST32_TYPE__ int_fast32_t;
   72   typedef __UINT_FAST32_TYPE__ uint_fast32_t;
   73 #define __int_fast32_t_defined 1
   74 #elif __STDINT_EXP(INT_MAX) >= 0x7fffffff
   75   typedef signed int int_fast32_t;
   76   typedef unsigned int uint_fast32_t;
   77 #define __int_fast32_t_defined 1
   78 #endif
   79 
   80 #ifdef __INT_FAST64_TYPE__
   81   typedef __INT_FAST64_TYPE__ int_fast64_t;
   82   typedef __UINT_FAST64_TYPE__ uint_fast64_t;
   83 #define __int_fast64_t_defined 1
   84 #elif __STDINT_EXP(INT_MAX) > 0x7fffffff
   85   typedef signed int int_fast64_t;
   86   typedef unsigned int uint_fast64_t;
   87 #define __int_fast64_t_defined 1
   88 #endif
   89 
   90 /*
   91  * Fall back to [u]int_least<N>_t for [u]int_fast<N>_t types
   92  * not having been defined, yet.
   93  * Leave undefined, if [u]int_least<N>_t should not be available.
   94  */
   95 #if !__int_fast8_t_defined
   96 #if __int_least8_t_defined
   97   typedef int_least8_t int_fast8_t;
   98   typedef uint_least8_t uint_fast8_t;
   99 #define __int_fast8_t_defined 1
  100 #endif
  101 #endif
  102 
  103 #if !__int_fast16_t_defined
  104 #if __int_least16_t_defined
  105   typedef int_least16_t int_fast16_t;
  106   typedef uint_least16_t uint_fast16_t;
  107 #define __int_fast16_t_defined 1
  108 #endif
  109 #endif
  110 
  111 #if !__int_fast32_t_defined
  112 #if __int_least32_t_defined
  113   typedef int_least32_t int_fast32_t;
  114   typedef uint_least32_t uint_fast32_t;
  115 #define __int_fast32_t_defined 1
  116 #endif
  117 #endif
  118 
  119 #if !__int_fast64_t_defined
  120 #if __int_least64_t_defined
  121   typedef int_least64_t int_fast64_t;
  122   typedef uint_least64_t uint_fast64_t;
  123 #define __int_fast64_t_defined 1
  124 #endif
  125 #endif
  126 
  127 #ifdef __INTPTR_TYPE__
  128 #define INTPTR_MIN (-__INTPTR_MAX__ - 1)
  129 #define INTPTR_MAX (__INTPTR_MAX__)
  130 #define UINTPTR_MAX (__UINTPTR_MAX__)
  131 #elif defined(__PTRDIFF_TYPE__)
  132 #define INTPTR_MAX PTRDIFF_MAX
  133 #define INTPTR_MIN PTRDIFF_MIN
  134 #ifdef __UINTPTR_MAX__
  135 #define UINTPTR_MAX (__UINTPTR_MAX__)
  136 #else
  137 #define UINTPTR_MAX (2UL * PTRDIFF_MAX + 1)
  138 #endif
  139 #else
  140 /*
  141  * Fallback to hardcoded values, 
  142  * should be valid on cpu's with 32bit int/32bit void*
  143  */
  144 #define INTPTR_MAX (__STDINT_EXP(LONG_MAX))
  145 #define INTPTR_MIN (-__STDINT_EXP(LONG_MAX) - 1)
  146 #define UINTPTR_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)
  147 #endif
  148 
  149 /* Limits of Specified-Width Integer Types */
  150 
  151 #ifdef __INT8_MAX__
  152 #define INT8_MIN (-__INT8_MAX__ - 1)
  153 #define INT8_MAX (__INT8_MAX__)
  154 #define UINT8_MAX (__UINT8_MAX__)
  155 #elif defined(__int8_t_defined)
  156 #define INT8_MIN    (-128)
  157 #define INT8_MAX     (127)
  158 #define UINT8_MAX    (255)
  159 #endif
  160 
  161 #ifdef __INT_LEAST8_MAX__
  162 #define INT_LEAST8_MIN (-__INT_LEAST8_MAX__ - 1)
  163 #define INT_LEAST8_MAX (__INT_LEAST8_MAX__)
  164 #define UINT_LEAST8_MAX (__UINT_LEAST8_MAX__)
  165 #elif defined(__int_least8_t_defined)
  166 #define INT_LEAST8_MIN  (-128)
  167 #define INT_LEAST8_MAX   (127)
  168 #define UINT_LEAST8_MAX  (255)
  169 #else
  170 #error required type int_least8_t missing
  171 #endif
  172 
  173 #ifdef __INT16_MAX__
  174 #define INT16_MIN (-__INT16_MAX__ - 1)
  175 #define INT16_MAX (__INT16_MAX__)
  176 #define UINT16_MAX (__UINT16_MAX__)
  177 #elif defined(__int16_t_defined)
  178 #define INT16_MIN   (-32768)
  179 #define INT16_MAX    (32767)
  180 #define UINT16_MAX   (65535)
  181 #endif
  182 
  183 #ifdef __INT_LEAST16_MAX__
  184 #define INT_LEAST16_MIN (-__INT_LEAST16_MAX__ - 1)
  185 #define INT_LEAST16_MAX (__INT_LEAST16_MAX__)
  186 #define UINT_LEAST16_MAX (__UINT_LEAST16_MAX__)
  187 #elif defined(__int_least16_t_defined)
  188 #define INT_LEAST16_MIN (-32768)
  189 #define INT_LEAST16_MAX  (32767)
  190 #define UINT_LEAST16_MAX (65535)
  191 #else
  192 #error required type int_least16_t missing
  193 #endif
  194 
  195 #ifdef __INT32_MAX__
  196 #define INT32_MIN (-__INT32_MAX__ - 1)
  197 #define INT32_MAX (__INT32_MAX__)
  198 #define UINT32_MAX (__UINT32_MAX__)
  199 #elif defined(__int32_t_defined)
  200 #if defined (_INT32_EQ_LONG)
  201 #define INT32_MIN    (-2147483647L-1)
  202 #define INT32_MAX    (2147483647L)
  203 #define UINT32_MAX       (4294967295UL)
  204 #else
  205 #define INT32_MIN    (-2147483647-1)
  206 #define INT32_MAX    (2147483647)
  207 #define UINT32_MAX       (4294967295U)
  208 #endif
  209 #endif
  210 
  211 #ifdef __INT_LEAST32_MAX__
  212 #define INT_LEAST32_MIN (-__INT_LEAST32_MAX__ - 1)
  213 #define INT_LEAST32_MAX (__INT_LEAST32_MAX__)
  214 #define UINT_LEAST32_MAX (__UINT_LEAST32_MAX__)
  215 #elif defined(__int_least32_t_defined)
  216 #if defined (_INT32_EQ_LONG)
  217 #define INT_LEAST32_MIN  (-2147483647L-1)
  218 #define INT_LEAST32_MAX  (2147483647L)
  219 #define UINT_LEAST32_MAX (4294967295UL)
  220 #else
  221 #define INT_LEAST32_MIN  (-2147483647-1)
  222 #define INT_LEAST32_MAX  (2147483647)
  223 #define UINT_LEAST32_MAX (4294967295U)
  224 #endif
  225 #else
  226 #error required type int_least32_t missing
  227 #endif
  228 
  229 #ifdef __INT64_MAX__
  230 #define INT64_MIN (-__INT64_MAX__ - 1)
  231 #define INT64_MAX (__INT64_MAX__)
  232 #define UINT64_MAX (__UINT64_MAX__)
  233 #elif defined(__int64_t_defined)
  234 #if __have_long64
  235 #define INT64_MIN   (-9223372036854775807L-1L)
  236 #define INT64_MAX    (9223372036854775807L)
  237 #define UINT64_MAX  (18446744073709551615U)
  238 #elif __have_longlong64
  239 #define INT64_MIN   (-9223372036854775807LL-1LL)
  240 #define INT64_MAX    (9223372036854775807LL)
  241 #define UINT64_MAX  (18446744073709551615ULL)
  242 #endif
  243 #endif
  244 
  245 #ifdef __INT_LEAST64_MAX__
  246 #define INT_LEAST64_MIN (-__INT_LEAST64_MAX__ - 1)
  247 #define INT_LEAST64_MAX (__INT_LEAST64_MAX__)
  248 #define UINT_LEAST64_MAX (__UINT_LEAST64_MAX__)
  249 #elif defined(__int_least64_t_defined)
  250 #if __have_long64
  251 #define INT_LEAST64_MIN  (-9223372036854775807L-1L)
  252 #define INT_LEAST64_MAX  (9223372036854775807L)
  253 #define UINT_LEAST64_MAX (18446744073709551615U)
  254 #elif __have_longlong64
  255 #define INT_LEAST64_MIN  (-9223372036854775807LL-1LL)
  256 #define INT_LEAST64_MAX  (9223372036854775807LL)
  257 #define UINT_LEAST64_MAX (18446744073709551615ULL)
  258 #endif
  259 #endif
  260 
  261 #ifdef __INT_FAST8_MAX__
  262 #define INT_FAST8_MIN (-__INT_FAST8_MAX__ - 1)
  263 #define INT_FAST8_MAX (__INT_FAST8_MAX__)
  264 #define UINT_FAST8_MAX (__UINT_FAST8_MAX__)
  265 #elif defined(__int_fast8_t_defined)
  266 #if __STDINT_EXP(INT_MAX) >= 0x7f
  267 #define INT_FAST8_MIN   (-__STDINT_EXP(INT_MAX)-1)
  268 #define INT_FAST8_MAX   (__STDINT_EXP(INT_MAX))
  269 #define UINT_FAST8_MAX  (__STDINT_EXP(INT_MAX)*2U+1U)
  270 #else
  271 #define INT_FAST8_MIN   INT_LEAST8_MIN
  272 #define INT_FAST8_MAX   INT_LEAST8_MAX
  273 #define UINT_FAST8_MAX  UINT_LEAST8_MAX
  274 #endif
  275 #endif
  276 
  277 #ifdef __INT_FAST16_MAX__
  278 #define INT_FAST16_MIN (-__INT_FAST16_MAX__ - 1)
  279 #define INT_FAST16_MAX (__INT_FAST16_MAX__)
  280 #define UINT_FAST16_MAX (__UINT_FAST16_MAX__)
  281 #elif defined(__int_fast16_t_defined)
  282 #if __STDINT_EXP(INT_MAX) >= 0x7fff
  283 #define INT_FAST16_MIN  (-__STDINT_EXP(INT_MAX)-1)
  284 #define INT_FAST16_MAX  (__STDINT_EXP(INT_MAX))
  285 #define UINT_FAST16_MAX (__STDINT_EXP(INT_MAX)*2U+1U)
  286 #else
  287 #define INT_FAST16_MIN  INT_LEAST16_MIN
  288 #define INT_FAST16_MAX  INT_LEAST16_MAX
  289 #define UINT_FAST16_MAX UINT_LEAST16_MAX
  290 #endif
  291 #endif
  292 
  293 #ifdef __INT_FAST32_MAX__
  294 #define INT_FAST32_MIN (-__INT_FAST32_MAX__ - 1)
  295 #define INT_FAST32_MAX (__INT_FAST32_MAX__)
  296 #define UINT_FAST32_MAX (__UINT_FAST32_MAX__)
  297 #elif defined(__int_fast32_t_defined)
  298 #if __STDINT_EXP(INT_MAX) >= 0x7fffffff
  299 #define INT_FAST32_MIN  (-__STDINT_EXP(INT_MAX)-1)
  300 #define INT_FAST32_MAX  (__STDINT_EXP(INT_MAX))
  301 #define UINT_FAST32_MAX (__STDINT_EXP(INT_MAX)*2U+1U)
  302 #else
  303 #define INT_FAST32_MIN  INT_LEAST32_MIN
  304 #define INT_FAST32_MAX  INT_LEAST32_MAX
  305 #define UINT_FAST32_MAX UINT_LEAST32_MAX
  306 #endif
  307 #endif
  308 
  309 #ifdef __INT_FAST64_MAX__
  310 #define INT_FAST64_MIN (-__INT_FAST64_MAX__ - 1)
  311 #define INT_FAST64_MAX (__INT_FAST64_MAX__)
  312 #define UINT_FAST64_MAX (__UINT_FAST64_MAX__)
  313 #elif defined(__int_fast64_t_defined)
  314 #if __STDINT_EXP(INT_MAX) > 0x7fffffff
  315 #define INT_FAST64_MIN  (-__STDINT_EXP(INT_MAX)-1)
  316 #define INT_FAST64_MAX  (__STDINT_EXP(INT_MAX))
  317 #define UINT_FAST64_MAX (__STDINT_EXP(INT_MAX)*2U+1U)
  318 #else
  319 #define INT_FAST64_MIN  INT_LEAST64_MIN
  320 #define INT_FAST64_MAX  INT_LEAST64_MAX
  321 #define UINT_FAST64_MAX UINT_LEAST64_MAX
  322 #endif
  323 #endif
  324 
  325 #ifdef __INTMAX_MAX__
  326 #define INTMAX_MAX (__INTMAX_MAX__)
  327 #define INTMAX_MIN (-INTMAX_MAX - 1)
  328 #elif defined(__INTMAX_TYPE__)
  329 /* All relevant GCC versions prefer long to long long for intmax_t.  */
  330 #define INTMAX_MAX INT64_MAX
  331 #define INTMAX_MIN INT64_MIN
  332 #endif
  333 
  334 #ifdef __UINTMAX_MAX__
  335 #define UINTMAX_MAX (__UINTMAX_MAX__)
  336 #elif defined(__UINTMAX_TYPE__)
  337 /* All relevant GCC versions prefer long to long long for intmax_t.  */
  338 #define UINTMAX_MAX UINT64_MAX
  339 #endif
  340 
  341 /* This must match size_t in stddef.h, currently long unsigned int */
  342 #ifdef __SIZE_MAX__
  343 #define SIZE_MAX (__SIZE_MAX__)
  344 #else
  345 #define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)
  346 #endif
  347 
  348 /* This must match sig_atomic_t in <signal.h> (currently int) */
  349 #define SIG_ATOMIC_MIN (-__STDINT_EXP(INT_MAX) - 1)
  350 #define SIG_ATOMIC_MAX (__STDINT_EXP(INT_MAX))
  351 
  352 /* This must match ptrdiff_t  in <stddef.h> (currently long int) */
  353 #ifdef __PTRDIFF_MAX__
  354 #define PTRDIFF_MAX (__PTRDIFF_MAX__)
  355 #else
  356 #define PTRDIFF_MAX (__STDINT_EXP(LONG_MAX))
  357 #endif
  358 #define PTRDIFF_MIN (-PTRDIFF_MAX - 1)
  359 
  360 /* This must match definition in <wchar.h> */
  361 #ifndef WCHAR_MIN
  362 #ifdef __WCHAR_MIN__
  363 #define WCHAR_MIN (__WCHAR_MIN__)
  364 #elif defined(__WCHAR_UNSIGNED__) || (L'\0' - 1 > 0)
  365 #define WCHAR_MIN (0 + L'\0')
  366 #else
  367 #define WCHAR_MIN (-0x7fffffff - 1 + L'\0')
  368 #endif
  369 #endif
  370 
  371 /* This must match definition in <wchar.h> */
  372 #ifndef WCHAR_MAX
  373 #ifdef __WCHAR_MAX__
  374 #define WCHAR_MAX (__WCHAR_MAX__)
  375 #elif defined(__WCHAR_UNSIGNED__) || (L'\0' - 1 > 0)
  376 #define WCHAR_MAX (0xffffffffu + L'\0')
  377 #else
  378 #define WCHAR_MAX (0x7fffffff + L'\0')
  379 #endif
  380 #endif
  381 
  382 /* wint_t is unsigned int on almost all GCC targets.  */
  383 #ifdef __WINT_MAX__
  384 #define WINT_MAX (__WINT_MAX__)
  385 #else
  386 #define WINT_MAX (__STDINT_EXP(INT_MAX) * 2U + 1U)
  387 #endif
  388 #ifdef __WINT_MIN__
  389 #define WINT_MIN (__WINT_MIN__)
  390 #else
  391 #define WINT_MIN (0U)
  392 #endif
  393 
  394 /** Macros for minimum-width integer constant expressions */
  395 #ifdef __INT8_C
  396 #define INT8_C(x) __INT8_C(x)
  397 #define UINT8_C(x) __UINT8_C(x)
  398 #else
  399 #define INT8_C(x)   x
  400 #if __STDINT_EXP(INT_MAX) > 0x7f
  401 #define UINT8_C(x)  x
  402 #else
  403 #define UINT8_C(x)  x##U
  404 #endif
  405 #endif
  406 
  407 #ifdef __INT16_C
  408 #define INT16_C(x) __INT16_C(x)
  409 #define UINT16_C(x) __UINT16_C(x)
  410 #else
  411 #define INT16_C(x)  x
  412 #if __STDINT_EXP(INT_MAX) > 0x7fff
  413 #define UINT16_C(x) x
  414 #else
  415 #define UINT16_C(x) x##U
  416 #endif
  417 #endif
  418 
  419 #ifdef __INT32_C
  420 #define INT32_C(x) __INT32_C(x)
  421 #define UINT32_C(x) __UINT32_C(x)
  422 #else
  423 #if defined (_INT32_EQ_LONG)
  424 #define INT32_C(x)  x##L
  425 #define UINT32_C(x) x##UL
  426 #else
  427 #define INT32_C(x)  x
  428 #define UINT32_C(x) x##U
  429 #endif
  430 #endif
  431 
  432 #ifdef __INT64_C
  433 #define INT64_C(x) __INT64_C(x)
  434 #define UINT64_C(x) __UINT64_C(x)
  435 #else
  436 #if __int64_t_defined
  437 #if __have_long64
  438 #define INT64_C(x)  x##L
  439 #define UINT64_C(x) x##UL
  440 #else
  441 #define INT64_C(x)  x##LL
  442 #define UINT64_C(x) x##ULL
  443 #endif
  444 #endif
  445 #endif
  446 
  447 /** Macros for greatest-width integer constant expression */
  448 #ifdef __INTMAX_C
  449 #define INTMAX_C(x) __INTMAX_C(x)
  450 #define UINTMAX_C(x) __UINTMAX_C(x)
  451 #else
  452 #if __have_long64
  453 #define INTMAX_C(x) x##L
  454 #define UINTMAX_C(x)    x##UL
  455 #else
  456 #define INTMAX_C(x) x##LL
  457 #define UINTMAX_C(x)    x##ULL
  458 #endif
  459 #endif
  460 
  461 
  462 #ifdef __cplusplus
  463 }
  464 #endif
  465 
  466 #endif /* _STDINT_H */