matter.c

Cross-platform minimalist libc
git clone git://git.finwo.net/lib/matter.c
Log | Files | Refs | README | LICENSE

stdint.h (8775B)


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