1/* Copyright (C) 2001-2002, 2004-2006 Free Software Foundation, Inc. 2 Written by Bruno Haible, Sam Steingold, Peter Burwood. 3 This file is part of gnulib. 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2, or (at your option) 8 any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software Foundation, 17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 18 19#ifndef _STDINT_H 20#define _STDINT_H 21 22/* 23 * ISO C 99 <stdint.h> for platforms that lack it. 24 * <http://www.opengroup.org/susv3xbd/stdint.h.html> 25 */ 26 27/* Get wchar_t, WCHAR_MIN, WCHAR_MAX. */ 28#include <stddef.h> 29/* BSD/OS 4.2 defines WCHAR_MIN, WCHAR_MAX in <wchar.h>, not <stddef.h>. */ 30#if !(defined(WCHAR_MIN) && defined(WCHAR_MAX)) && @HAVE_WCHAR_H@ 31# include <wchar.h> 32#endif 33 34/* Get LONG_MIN, LONG_MAX, ULONG_MAX. */ 35#include <limits.h> 36 37/* Get those types that are already defined in other system include files. */ 38#if defined(__FreeBSD__) && (__FreeBSD__ >= 3) && (__FreeBSD__ <= 4) 39# include <sys/inttypes.h> 40#endif 41#if defined(__OpenBSD__) || defined(__bsdi__) || defined(__sgi) 42 /* In OpenBSD 3.8, <sys/types.h> includes <machine/types.h>, which defines 43 int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__. 44 <inttypes.h> includes <machine/types.h> and also defines intptr_t and 45 uintptr_t. */ 46 /* BSD/OS 4.2 is similar, but doesn't have <inttypes.h> */ 47 /* IRIX 6.5 has <inttypes.h>, and <sys/types.h> defines some of these 48 types as well. */ 49# include <sys/types.h> 50# if @HAVE_INTTYPES_H@ 51# include @FULL_PATH_INTTYPES_H@ 52# endif 53#endif 54#if defined(__linux__) && @HAVE_SYS_BITYPES_H@ 55 /* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines 56 int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is 57 included by <sys/types.h>. */ 58# include <sys/bitypes.h> 59#endif 60#if defined(__sun) && @HAVE_SYS_INTTYPES_H@ 61 /* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and 62 the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. 63 But note that <sys/int_types.h> contains only the type definitions! */ 64# include <sys/inttypes.h> 65#endif 66#if (defined(__hpux) || defined(_AIX)) && @HAVE_INTTYPES_H@ 67 /* HP-UX 10 <inttypes.h> has nearly everything, except UINT_LEAST8_MAX, 68 UINT_FAST8_MAX, PTRDIFF_MIN, PTRDIFF_MAX. */ 69 /* AIX 4 <inttypes.h> has nearly everything, except INTPTR_MIN, INTPTR_MAX, 70 UINTPTR_MAX, PTRDIFF_MIN, PTRDIFF_MAX. */ 71# include @FULL_PATH_INTTYPES_H@ 72#endif 73#if @HAVE_STDINT_H@ 74 /* Other systems may have an incomplete <stdint.h>. */ 75 /* On some versions of IRIX, the SGI C compiler comes with an <stdint.h>, 76 but 77 - in c99 mode, <inttypes.h> includes <stdint.h>, 78 - in c89 mode, <stdint.h> spews warnings and defines nothing. 79 <inttypes.h> defines only a subset of the types and macros that 80 <stdint.h> would define in c99 mode. 81 So we rely only on <inttypes.h> (included above). It means that in 82 c89 mode, we shadow the contents of warning-spewing <stdint.h>. */ 83# if !(defined(__sgi) && @HAVE_INTTYPES_H@ && !defined(__c99)) 84# include @FULL_PATH_STDINT_H@ 85# endif 86#endif 87 88/* 7.18.1.1. Exact-width integer types */ 89 90/* Here we assume a standard architecture where the hardware integer 91 types have 8, 16, 32, optionally 64 bits. */ 92 93#if !@HAVE_INT8_T@ 94typedef signed char int8_t; 95#endif 96#if !@HAVE_UINT8_T@ 97typedef unsigned char uint8_t; 98# define _UINT8_T /* avoid collision with Solaris 2.5.1 <pthread.h> */ 99#endif 100 101#if !@HAVE_INT16_T@ 102typedef short int16_t; 103#endif 104#if !@HAVE_UINT16_T@ 105typedef unsigned short uint16_t; 106#endif 107 108#if !@HAVE_INT32_T@ 109typedef int int32_t; 110#endif 111#if !@HAVE_UINT32_T@ 112typedef unsigned int uint32_t; 113# define _UINT32_T /* avoid collision with Solaris 2.5.1 <pthread.h> */ 114#endif 115 116#if @HAVE_INT64_T@ 117# define _STDINT_H_HAVE_INT64 1 118#else 119# if @HAVE_LONG_64BIT@ 120typedef long int64_t; 121# define _STDINT_H_HAVE_INT64 1 122# elif @HAVE_LONG_LONG_64BIT@ 123typedef long long int64_t; 124# define _STDINT_H_HAVE_INT64 1 125# elif defined _MSC_VER 126typedef __int64 int64_t; 127# define _STDINT_H_HAVE_INT64 1 128# endif 129#endif 130#if @HAVE_UINT64_T@ 131# define _STDINT_H_HAVE_UINT64 1 132#else 133# if @HAVE_LONG_64BIT@ 134typedef unsigned long uint64_t; 135# define _STDINT_H_HAVE_UINT64 1 136# elif @HAVE_LONG_LONG_64BIT@ 137typedef unsigned long long uint64_t; 138# define _UINT64_T /* avoid collision with Solaris 2.5.1 <pthread.h> */ 139# define _STDINT_H_HAVE_UINT64 1 140# elif defined _MSC_VER 141typedef unsigned __int64 uint64_t; 142# define _STDINT_H_HAVE_UINT64 1 143# endif 144#endif 145 146/* 7.18.1.2. Minimum-width integer types */ 147 148/* Here we assume a standard architecture where the hardware integer 149 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types 150 are the same as the corresponding N_t types. */ 151 152#if !@HAVE_INT_LEAST8_T@ 153typedef int8_t int_least8_t; 154#endif 155#if !@HAVE_UINT_LEAST8_T@ 156typedef uint8_t uint_least8_t; 157#endif 158 159#if !@HAVE_INT_LEAST16_T@ 160typedef int16_t int_least16_t; 161#endif 162#if !@HAVE_UINT_LEAST16_T@ 163typedef uint16_t uint_least16_t; 164#endif 165 166#if !@HAVE_INT_LEAST32_T@ 167typedef int32_t int_least32_t; 168#endif 169#if !@HAVE_UINT_LEAST32_T@ 170typedef uint32_t uint_least32_t; 171#endif 172 173#if !@HAVE_INT_LEAST64_T@ && _STDINT_H_HAVE_INT64 174typedef int64_t int_least64_t; 175#endif 176#if !@HAVE_UINT_LEAST64_T@ && _STDINT_H_HAVE_UINT64 177typedef uint64_t uint_least64_t; 178#endif 179 180/* 7.18.1.3. Fastest minimum-width integer types */ 181 182/* Note: Other <stdint.h> substitutes may define these types differently. 183 It is not recommended to use these types in public header files. */ 184 185/* Here we assume a standard architecture where the hardware integer 186 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types 187 are taken from the same list of types. */ 188 189/* On alpha processors, int32_t variables are slower than int64_t variables, 190 due to the necessary zap instructions. */ 191#if defined __alpha 192# define _STDINT_H_INT64_FASTER_THAN_INT32 1 193#endif 194 195#if !@HAVE_INT_FAST8_T@ 196# if _STDINT_H_INT64_FASTER_THAN_INT32 197typedef int64_t int_fast8_t; 198# else 199typedef int32_t int_fast8_t; 200# endif 201#endif 202#if !@HAVE_UINT_FAST8_T@ 203# if _STDINT_H_INT64_FASTER_THAN_INT32 204typedef uint64_t uint_fast8_t; 205# else 206typedef uint32_t uint_fast8_t; 207# endif 208#endif 209 210#if !@HAVE_INT_FAST16_T@ 211# if _STDINT_H_INT64_FASTER_THAN_INT32 212typedef int64_t int_fast16_t; 213# else 214typedef int32_t int_fast16_t; 215# endif 216#endif 217#if !@HAVE_UINT_FAST16_T@ 218# if _STDINT_H_INT64_FASTER_THAN_INT32 219typedef uint64_t uint_fast16_t; 220# else 221typedef uint32_t uint_fast16_t; 222# endif 223#endif 224 225#if !@HAVE_INT_FAST32_T@ 226# if _STDINT_H_INT64_FASTER_THAN_INT32 227typedef int64_t int_fast32_t; 228# else 229typedef int32_t int_fast32_t; 230# endif 231#endif 232#if !@HAVE_UINT_FAST32_T@ 233# if _STDINT_H_INT64_FASTER_THAN_INT32 234typedef uint64_t uint_fast32_t; 235# else 236typedef uint32_t uint_fast32_t; 237# endif 238#endif 239 240#if !@HAVE_INT_FAST64_T@ && _STDINT_H_HAVE_INT64 241typedef int64_t int_fast64_t; 242#endif 243#if !@HAVE_UINT_FAST64_T@ && _STDINT_H_HAVE_UINT64 244typedef uint64_t uint_fast64_t; 245#endif 246 247/* 7.18.1.4. Integer types capable of holding object pointers */ 248 249/* On some platforms (like IRIX6 MIPS with -n32) sizeof(void*) < sizeof(long), 250 but this doesn't matter here. */ 251#if !@HAVE_INTPTR_T@ 252typedef long intptr_t; 253#endif 254#if !@HAVE_UINTPTR_T@ 255typedef unsigned long uintptr_t; 256#endif 257 258/* 7.18.1.5. Greatest-width integer types */ 259 260/* Note: These types are compiler dependent. It may be unwise to use them in 261 public header files. */ 262 263#if !@HAVE_INTMAX_T@ 264/* Remove possible redundant definition from gnulib's config.h first. */ 265# undef intmax_t 266# ifdef _STDINT_H_HAVE_INT64 267typedef int64_t intmax_t; 268# else 269typedef int32_t intmax_t; 270# endif 271#endif 272#if !@HAVE_UINTMAX_T@ 273/* Remove possible redundant definition from gnulib's config.h first. */ 274# undef uintmax_t 275# ifdef _STDINT_H_HAVE_UINT64 276typedef uint64_t uintmax_t; 277# else 278typedef uint32_t uintmax_t; 279# endif 280#endif 281 282/* 7.18.2. Limits of specified-width integer types */ 283 284#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) 285 286/* 7.18.2.1. Limits of exact-width integer types */ 287 288/* Here we assume a standard architecture where the hardware integer 289 types have 8, 16, 32, optionally 64 bits. */ 290 291#if @HAVE_INT8_T@ 292# ifndef INT8_MIN 293# define INT8_MIN (-1 << (@BITSIZEOF_INT8_T@ - 1)) 294# endif 295#else 296# define INT8_MIN -128 297#endif 298#if @HAVE_INT8_T@ 299# ifndef INT8_MAX 300# define INT8_MAX (~ (-1 << (@BITSIZEOF_INT8_T@ - 1))) 301# endif 302#else 303# define INT8_MAX 127 304#endif 305#if @HAVE_UINT8_T@ 306# ifndef UINT8_MAX 307# if @BITSIZEOF_UINT8_T@ < @BITSIZEOF_UNSIGNED_INT@ 308# define UINT8_MAX (((1 << (@BITSIZEOF_UINT8_T@ - 1)) - 1) * 2 + 1) 309# else 310# define UINT8_MAX (((1U << (@BITSIZEOF_UINT8_T@ - 1)) - 1) * 2 + 1) 311# endif 312# endif 313#else 314# define UINT8_MAX 255 315#endif 316 317#if @HAVE_INT16_T@ 318# ifndef INT16_MIN 319# define INT16_MIN (-1 << (@BITSIZEOF_INT16_T@ - 1)) 320# endif 321#else 322# define INT16_MIN -32768 323#endif 324#if @HAVE_INT16_T@ 325# ifndef INT16_MAX 326# define INT16_MAX (~ (-1 << (@BITSIZEOF_INT16_T@ - 1))) 327# endif 328#else 329# define INT16_MAX 32767 330#endif 331#if @HAVE_UINT16_T@ 332# ifndef UINT16_MAX 333# if @BITSIZEOF_UINT16_T@ < @BITSIZEOF_UNSIGNED_INT@ 334# define UINT16_MAX (((1 << (@BITSIZEOF_UINT16_T@ - 1)) - 1) * 2 + 1) 335# else 336# define UINT16_MAX (((1U << (@BITSIZEOF_UINT16_T@ - 1)) - 1) * 2 + 1) 337# endif 338# endif 339#else 340# define UINT16_MAX 65535 341#endif 342 343#if @HAVE_INT32_T@ 344# ifndef INT32_MIN 345# define INT32_MIN (-1 << (@BITSIZEOF_INT32_T@ - 1)) 346# endif 347#else 348# define INT32_MIN (~INT32_MAX) 349#endif 350#if @HAVE_INT32_T@ 351# ifndef INT32_MAX 352# define INT32_MAX (~ (-1 << (@BITSIZEOF_INT32_T@ - 1))) 353# endif 354#else 355# define INT32_MAX 2147483647 356#endif 357#if @HAVE_UINT32_T@ 358# ifndef UINT32_MAX 359# if @BITSIZEOF_UINT32_T@ < @BITSIZEOF_UNSIGNED_INT@ 360# define UINT32_MAX (((1 << (@BITSIZEOF_UINT32_T@ - 1)) - 1) * 2 + 1) 361# else 362# define UINT32_MAX (((1U << (@BITSIZEOF_UINT32_T@ - 1)) - 1) * 2 + 1) 363# endif 364# endif 365#else 366# define UINT32_MAX 4294967295U 367#endif 368 369#if @HAVE_INT64_T@ 370# ifndef INT64_MIN 371# if @HAVE_LONG_64BIT@ 372# define INT64_MIN (-1L << (@BITSIZEOF_INT64_T@ - 1)) 373# elif @HAVE_LONG_LONG_64BIT@ 374# define INT64_MIN (-1LL << (@BITSIZEOF_INT64_T@ - 1)) 375# elif defined _MSC_VER 376# define INT64_MIN (-1i64 << (@BITSIZEOF_INT64_T@ - 1)) 377# endif 378# endif 379#else 380# ifdef _STDINT_H_HAVE_INT64 381# define INT64_MIN (~INT64_MAX) 382# endif 383#endif 384#if @HAVE_INT64_T@ 385# ifndef INT64_MAX 386# if @HAVE_LONG_64BIT@ 387# define INT64_MAX (~ (-1L << (@BITSIZEOF_INT64_T@ - 1))) 388# elif @HAVE_LONG_LONG_64BIT@ 389# define INT64_MAX (~ (-1LL << (@BITSIZEOF_INT64_T@ - 1))) 390# elif defined _MSC_VER 391# define INT64_MAX (~ (-1i64 << (@BITSIZEOF_INT64_T@ - 1))) 392# endif 393# endif 394#else 395# ifdef _STDINT_H_HAVE_INT64 396# if @HAVE_LONG_64BIT@ 397# define INT64_MAX 9223372036854775807L 398# elif @HAVE_LONG_LONG_64BIT@ 399# define INT64_MAX 9223372036854775807LL 400# elif defined _MSC_VER 401# define INT64_MAX 9223372036854775807i64 402# endif 403# endif 404#endif 405#if @HAVE_UINT64_T@ 406# ifndef UINT64_MAX 407# if @HAVE_LONG_64BIT@ 408# define UINT64_MAX (((1UL << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1) 409# elif @HAVE_LONG_LONG_64BIT@ 410# define UINT64_MAX (((1ULL << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1) 411# elif defined _MSC_VER 412# define UINT64_MAX (((1ui64 << (@BITSIZEOF_UINT64_T@ - 1)) - 1) * 2 + 1) 413# endif 414# endif 415#else 416# ifdef _STDINT_H_HAVE_UINT64 417# if @HAVE_LONG_64BIT@ 418# define UINT64_MAX 18446744073709551615UL 419# elif @HAVE_LONG_LONG_64BIT@ 420# define UINT64_MAX 18446744073709551615ULL 421# elif defined _MSC_VER 422# define UINT64_MAX 18446744073709551615ui64 423# endif 424# endif 425#endif 426 427/* 7.18.2.2. Limits of minimum-width integer types */ 428 429/* Here we assume a standard architecture where the hardware integer 430 types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types 431 are the same as the corresponding N_t types. */ 432 433#if @HAVE_INT_LEAST8_T@ 434# ifndef INT_LEAST8_MIN 435# define INT_LEAST8_MIN (-1 << (@BITSIZEOF_INT_LEAST8_T@ - 1)) 436# endif 437#else 438# define INT_LEAST8_MIN INT8_MIN 439#endif 440#if @HAVE_INT_LEAST8_T@ 441# ifndef INT_LEAST8_MAX 442# define INT_LEAST8_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST8_T@ - 1))) 443# endif 444#else 445# define INT_LEAST8_MAX INT8_MAX 446#endif 447#if @HAVE_UINT_LEAST8_T@ 448# ifndef UINT_LEAST8_MAX 449# if @BITSIZEOF_UINT_LEAST8_T@ < @BITSIZEOF_UNSIGNED_INT@ 450# define UINT_LEAST8_MAX (((1 << (@BITSIZEOF_UINT_LEAST8_T@ - 1)) - 1) * 2 + 1) 451# else 452# define UINT_LEAST8_MAX (((1U << (@BITSIZEOF_UINT_LEAST8_T@ - 1)) - 1) * 2 + 1) 453# endif 454# endif 455#else 456# define UINT_LEAST8_MAX UINT8_MAX 457#endif 458 459#if @HAVE_INT_LEAST16_T@ 460# ifndef INT_LEAST16_MIN 461# define INT_LEAST16_MIN (-1 << (@BITSIZEOF_INT_LEAST16_T@ - 1)) 462# endif 463#else 464# define INT_LEAST16_MIN INT16_MIN 465#endif 466#if @HAVE_INT_LEAST16_T@ 467# ifndef INT_LEAST16_MAX 468# define INT_LEAST16_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST16_T@ - 1))) 469# endif 470#else 471# define INT_LEAST16_MAX INT16_MAX 472#endif 473#if @HAVE_UINT_LEAST16_T@ 474# ifndef UINT_LEAST16_MAX 475# if @BITSIZEOF_UINT_LEAST16_T@ < @BITSIZEOF_UNSIGNED_INT@ 476# define UINT_LEAST16_MAX (((1 << (@BITSIZEOF_UINT_LEAST16_T@ - 1)) - 1) * 2 + 1) 477# else 478# define UINT_LEAST16_MAX (((1U << (@BITSIZEOF_UINT_LEAST16_T@ - 1)) - 1) * 2 + 1) 479# endif 480# endif 481#else 482# define UINT_LEAST16_MAX UINT16_MAX 483#endif 484 485#if @HAVE_INT_LEAST32_T@ 486# ifndef INT_LEAST32_MIN 487# define INT_LEAST32_MIN (-1 << (@BITSIZEOF_INT_LEAST32_T@ - 1)) 488# endif 489#else 490# define INT_LEAST32_MIN INT32_MIN 491#endif 492#if @HAVE_INT_LEAST32_T@ 493# ifndef INT_LEAST32_MAX 494# define INT_LEAST32_MAX (~ (-1 << (@BITSIZEOF_INT_LEAST32_T@ - 1))) 495# endif 496#else 497# define INT_LEAST32_MAX INT32_MAX 498#endif 499#if @HAVE_UINT_LEAST32_T@ 500# ifndef UINT_LEAST32_MAX 501# if @BITSIZEOF_UINT_LEAST32_T@ < @BITSIZEOF_UNSIGNED_INT@ 502# define UINT_LEAST32_MAX (((1 << (@BITSIZEOF_UINT_LEAST32_T@ - 1)) - 1) * 2 + 1) 503# else 504# define UINT_LEAST32_MAX (((1U << (@BITSIZEOF_UINT_LEAST32_T@ - 1)) - 1) * 2 + 1) 505# endif 506# endif 507#else 508# define UINT_LEAST32_MAX UINT32_MAX 509#endif 510 511#if @HAVE_INT_LEAST64_T@ 512# ifndef INT_LEAST64_MIN 513# if @HAVE_LONG_64BIT@ 514# define INT_LEAST64_MIN (-1L << (@BITSIZEOF_INT_LEAST64_T@ - 1)) 515# elif @HAVE_LONG_LONG_64BIT@ 516# define INT_LEAST64_MIN (-1LL << (@BITSIZEOF_INT_LEAST64_T@ - 1)) 517# elif defined _MSC_VER 518# define INT_LEAST64_MIN (-1i64 << (@BITSIZEOF_INT_LEAST64_T@ - 1)) 519# endif 520# endif 521#else 522# ifdef _STDINT_H_HAVE_INT64 523# define INT_LEAST64_MIN INT64_MIN 524# endif 525#endif 526#if @HAVE_INT_LEAST64_T@ 527# ifndef INT_LEAST64_MAX 528# if @HAVE_LONG_64BIT@ 529# define INT_LEAST64_MAX (~ (-1L << (@BITSIZEOF_INT_LEAST64_T@ - 1))) 530# elif @HAVE_LONG_LONG_64BIT@ 531# define INT_LEAST64_MAX (~ (-1LL << (@BITSIZEOF_INT_LEAST64_T@ - 1))) 532# elif defined _MSC_VER 533# define INT_LEAST64_MAX (~ (-1i64 << (@BITSIZEOF_INT_LEAST64_T@ - 1))) 534# endif 535# endif 536#else 537# ifdef _STDINT_H_HAVE_INT64 538# define INT_LEAST64_MAX INT64_MAX 539# endif 540#endif 541#if @HAVE_UINT_LEAST64_T@ 542# ifndef UINT_LEAST64_MAX 543# if @HAVE_LONG_64BIT@ 544# define UINT_LEAST64_MAX (((1UL << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1) 545# elif @HAVE_LONG_LONG_64BIT@ 546# define UINT_LEAST64_MAX (((1ULL << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1) 547# elif defined _MSC_VER 548# define UINT_LEAST64_MAX (((1ui64 << (@BITSIZEOF_UINT_LEAST64_T@ - 1)) - 1) * 2 + 1) 549# endif 550# endif 551#else 552# ifdef _STDINT_H_HAVE_UINT64 553# define UINT_LEAST64_MAX UINT64_MAX 554# endif 555#endif 556 557/* 7.18.2.3. Limits of fastest minimum-width integer types */ 558 559/* Here we assume a standard architecture where the hardware integer 560 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types 561 are taken from the same list of types. */ 562 563#if @HAVE_INT_FAST8_T@ 564# ifndef INT_FAST8_MIN 565# define INT_FAST8_MIN (-1L << (@BITSIZEOF_INT_FAST8_T@ - 1)) 566# endif 567#else 568# if _STDINT_H_INT64_FASTER_THAN_INT32 569# define INT_FAST8_MIN INT64_MIN 570# else 571# define INT_FAST8_MIN INT32_MIN 572# endif 573#endif 574#if @HAVE_INT_FAST8_T@ 575# ifndef INT_FAST8_MAX 576# define INT_FAST8_MAX (~ (-1L << (@BITSIZEOF_INT_FAST8_T@ - 1))) 577# endif 578#else 579# if _STDINT_H_INT64_FASTER_THAN_INT32 580# define INT_FAST8_MAX INT64_MAX 581# else 582# define INT_FAST8_MAX INT32_MAX 583# endif 584#endif 585#if @HAVE_UINT_FAST8_T@ 586# ifndef UINT_FAST8_MAX 587# if @BITSIZEOF_UINT_FAST8_T@ < @BITSIZEOF_UNSIGNED_INT@ 588# define UINT_FAST8_MAX (((1 << (@BITSIZEOF_UINT_FAST8_T@ - 1)) - 1) * 2 + 1) 589# else 590# define UINT_FAST8_MAX (((1UL << (@BITSIZEOF_UINT_FAST8_T@ - 1)) - 1) * 2 + 1) 591# endif 592# endif 593#else 594# if _STDINT_H_INT64_FASTER_THAN_INT32 595# define UINT_FAST8_MAX UINT64_MAX 596# else 597# define UINT_FAST8_MAX UINT32_MAX 598# endif 599#endif 600 601#if @HAVE_INT_FAST16_T@ 602# ifndef INT_FAST16_MIN 603# define INT_FAST16_MIN (-1L << (@BITSIZEOF_INT_FAST16_T@ - 1)) 604# endif 605#else 606# if _STDINT_H_INT64_FASTER_THAN_INT32 607# define INT_FAST16_MIN INT64_MIN 608# else 609# define INT_FAST16_MIN INT32_MIN 610# endif 611#endif 612#if @HAVE_INT_FAST16_T@ 613# ifndef INT_FAST16_MAX 614# define INT_FAST16_MAX (~ (-1L << (@BITSIZEOF_INT_FAST16_T@ - 1))) 615# endif 616#else 617# if _STDINT_H_INT64_FASTER_THAN_INT32 618# define INT_FAST16_MAX INT64_MAX 619# else 620# define INT_FAST16_MAX INT32_MAX 621# endif 622#endif 623#if @HAVE_UINT_FAST16_T@ 624# ifndef UINT_FAST16_MAX 625# if @BITSIZEOF_UINT_FAST16_T@ < @BITSIZEOF_UNSIGNED_INT@ 626# define UINT_FAST16_MAX (((1 << (@BITSIZEOF_UINT_FAST16_T@ - 1)) - 1) * 2 + 1) 627# else 628# define UINT_FAST16_MAX (((1UL << (@BITSIZEOF_UINT_FAST16_T@ - 1)) - 1) * 2 + 1) 629# endif 630# endif 631#else 632# if _STDINT_H_INT64_FASTER_THAN_INT32 633# define UINT_FAST16_MAX UINT64_MAX 634# else 635# define UINT_FAST16_MAX UINT32_MAX 636# endif 637#endif 638 639#if @HAVE_INT_FAST32_T@ 640# ifndef INT_FAST32_MIN 641# define INT_FAST32_MIN (-1L << (@BITSIZEOF_INT_FAST32_T@ - 1)) 642# endif 643#else 644# if _STDINT_H_INT64_FASTER_THAN_INT32 645# define INT_FAST32_MIN INT64_MIN 646# else 647# define INT_FAST32_MIN INT32_MIN 648# endif 649#endif 650#if @HAVE_INT_FAST32_T@ 651# ifndef INT_FAST32_MAX 652# define INT_FAST32_MAX (~ (-1L << (@BITSIZEOF_INT_FAST32_T@ - 1))) 653# endif 654#else 655# if _STDINT_H_INT64_FASTER_THAN_INT32 656# define INT_FAST32_MAX INT64_MAX 657# else 658# define INT_FAST32_MAX INT32_MAX 659# endif 660#endif 661#if @HAVE_UINT_FAST32_T@ 662# ifndef UINT_FAST32_MAX 663# if @BITSIZEOF_UINT_FAST32_T@ < @BITSIZEOF_UNSIGNED_INT@ 664# define UINT_FAST32_MAX (((1 << (@BITSIZEOF_UINT_FAST32_T@ - 1)) - 1) * 2 + 1) 665# else 666# define UINT_FAST32_MAX (((1UL << (@BITSIZEOF_UINT_FAST32_T@ - 1)) - 1) * 2 + 1) 667# endif 668# endif 669#else 670# if _STDINT_H_INT64_FASTER_THAN_INT32 671# define UINT_FAST32_MAX UINT64_MAX 672# else 673# define UINT_FAST32_MAX UINT32_MAX 674# endif 675#endif 676 677#if @HAVE_INT_FAST64_T@ 678# ifndef INT_FAST64_MIN 679# if @HAVE_LONG_64BIT@ 680# define INT_FAST64_MIN (-1L << (@BITSIZEOF_INT_FAST64_T@ - 1)) 681# elif @HAVE_LONG_LONG_64BIT@ 682# define INT_FAST64_MIN (-1LL << (@BITSIZEOF_INT_FAST64_T@ - 1)) 683# elif defined _MSC_VER 684# define INT_FAST64_MIN (-1i64 << (@BITSIZEOF_INT_FAST64_T@ - 1)) 685# endif 686# endif 687#else 688# ifdef _STDINT_H_HAVE_INT64 689# define INT_FAST64_MIN INT64_MIN 690# endif 691#endif 692#if @HAVE_INT_FAST64_T@ 693# ifndef INT_FAST64_MAX 694# if @HAVE_LONG_64BIT@ 695# define INT_FAST64_MAX (~ (-1L << (@BITSIZEOF_INT_FAST64_T@ - 1))) 696# elif @HAVE_LONG_LONG_64BIT@ 697# define INT_FAST64_MAX (~ (-1LL << (@BITSIZEOF_INT_FAST64_T@ - 1))) 698# elif defined _MSC_VER 699# define INT_FAST64_MAX (~ (-1i64 << (@BITSIZEOF_INT_FAST64_T@ - 1))) 700# endif 701# endif 702#else 703# ifdef _STDINT_H_HAVE_INT64 704# define INT_FAST64_MAX INT64_MAX 705# endif 706#endif 707#if @HAVE_UINT_FAST64_T@ 708# ifndef UINT_FAST64_MAX 709# if @HAVE_LONG_64BIT@ 710# define UINT_FAST64_MAX (((1UL << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1) 711# elif @HAVE_LONG_LONG_64BIT@ 712# define UINT_FAST64_MAX (((1ULL << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1) 713# elif defined _MSC_VER 714# define UINT_FAST64_MAX (((1ui64 << (@BITSIZEOF_UINT_FAST64_T@ - 1)) - 1) * 2 + 1) 715# endif 716# endif 717#else 718# ifdef _STDINT_H_HAVE_UINT64 719# define UINT_FAST64_MAX UINT64_MAX 720# endif 721#endif 722 723/* 7.18.2.4. Limits of integer types capable of holding object pointers */ 724 725#if @HAVE_INTPTR_T@ 726# ifndef INTPTR_MIN 727# if @BITSIZEOF_INTPTR_T@ > @BITSIZEOF_LONG@ 728# define INTPTR_MIN (-1LL << (@BITSIZEOF_INTPTR_T@ - 1)) 729# else 730# define INTPTR_MIN (-1L << (@BITSIZEOF_INTPTR_T@ - 1)) 731# endif 732# endif 733#else 734# define INTPTR_MIN LONG_MIN 735#endif 736#if @HAVE_INTPTR_T@ 737# ifndef INTPTR_MAX 738# if @BITSIZEOF_INTPTR_T@ > @BITSIZEOF_LONG@ 739# define INTPTR_MAX (~ (-1LL << (@BITSIZEOF_INTPTR_T@ - 1))) 740# else 741# define INTPTR_MAX (~ (-1L << (@BITSIZEOF_INTPTR_T@ - 1))) 742# endif 743# endif 744#else 745# define INTPTR_MAX LONG_MAX 746#endif 747#if @HAVE_UINTPTR_T@ 748# ifndef UINTPTR_MAX 749# if @BITSIZEOF_UINTPTR_T@ > @BITSIZEOF_UNSIGNED_LONG@ 750# define UINTPTR_MAX (((1ULL << (@BITSIZEOF_UINTPTR_T@ - 1)) - 1) * 2 + 1) 751# else 752# define UINTPTR_MAX (((1UL << (@BITSIZEOF_UINTPTR_T@ - 1)) - 1) * 2 + 1) 753# endif 754# endif 755#else 756# define UINTPTR_MAX ULONG_MAX 757#endif 758 759/* 7.18.2.5. Limits of greatest-width integer types */ 760 761#if @HAVE_INTMAX_T@ 762# ifndef INTMAX_MIN 763# if @BITSIZEOF_INTMAX_T@ > @BITSIZEOF_LONG@ 764# define INTMAX_MIN (-1LL << (@BITSIZEOF_INTMAX_T@ - 1)) 765# else 766# define INTMAX_MIN (-1L << (@BITSIZEOF_INTMAX_T@ - 1)) 767# endif 768# endif 769#else 770# ifdef _STDINT_H_HAVE_INT64 771# define INTMAX_MIN INT64_MIN 772# else 773# define INTMAX_MIN INT32_MIN 774# endif 775#endif 776#if @HAVE_INTMAX_T@ 777# ifndef INTMAX_MAX 778# if @BITSIZEOF_INTMAX_T@ > @BITSIZEOF_LONG@ 779# define INTMAX_MAX (~ (-1LL << (@BITSIZEOF_INTMAX_T@ - 1))) 780# else 781# define INTMAX_MAX (~ (-1L << (@BITSIZEOF_INTMAX_T@ - 1))) 782# endif 783# endif 784#else 785# ifdef _STDINT_H_HAVE_INT64 786# define INTMAX_MAX INT64_MAX 787# else 788# define INTMAX_MAX INT32_MAX 789# endif 790#endif 791#if @HAVE_UINTMAX_T@ 792# ifndef UINTMAX_MAX 793# if @BITSIZEOF_UINTMAX_T@ > @BITSIZEOF_UNSIGNED_LONG@ 794# define UINTMAX_MAX (((1ULL << (@BITSIZEOF_UINTMAX_T@ - 1)) - 1) * 2 + 1) 795# else 796# define UINTMAX_MAX (((1UL << (@BITSIZEOF_UINTMAX_T@ - 1)) - 1) * 2 + 1) 797# endif 798# endif 799#else 800# ifdef _STDINT_H_HAVE_INT64 801# define UINTMAX_MAX UINT64_MAX 802# else 803# define UINTMAX_MAX UINT32_MAX 804# endif 805#endif 806 807/* 7.18.3. Limits of other integer types */ 808 809/* ptrdiff_t limits */ 810#ifndef PTRDIFF_MIN 811# if @BITSIZEOF_PTRDIFF_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_PTRDIFF_T_LONG@ 812# define PTRDIFF_MIN (-1L << (@BITSIZEOF_PTRDIFF_T@ - 1)) 813# else 814# define PTRDIFF_MIN (-1 << (@BITSIZEOF_PTRDIFF_T@ - 1)) 815# endif 816#endif 817#ifndef PTRDIFF_MAX 818# if @BITSIZEOF_PTRDIFF_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_PTRDIFF_T_LONG@ 819# define PTRDIFF_MAX (~ (-1L << (@BITSIZEOF_PTRDIFF_T@ - 1))) 820# else 821# define PTRDIFF_MAX (~ (-1 << (@BITSIZEOF_PTRDIFF_T@ - 1))) 822# endif 823#endif 824 825/* sig_atomic_t limits */ 826#ifndef SIG_ATOMIC_MIN 827# if @HAVE_SIGNED_SIG_ATOMIC_T@ 828# if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_LONG@ 829# define SIG_ATOMIC_MIN (-1L << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) 830# else 831# define SIG_ATOMIC_MIN (-1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) 832# endif 833# else 834# if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_UNSIGNED_LONG@ 835# define SIG_ATOMIC_MIN 0UL 836# elif @BITSIZEOF_SIG_ATOMIC_T@ >= @BITSIZEOF_UNSIGNED_INT@ 837# define SIG_ATOMIC_MIN 0U 838# else 839# define SIG_ATOMIC_MIN 0 840# endif 841# endif 842#endif 843#ifndef SIG_ATOMIC_MAX 844# if @HAVE_SIGNED_SIG_ATOMIC_T@ 845# if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_LONG@ 846# define SIG_ATOMIC_MAX (~ (-1L << (@BITSIZEOF_SIG_ATOMIC_T@ - 1))) 847# else 848# define SIG_ATOMIC_MAX (~ (-1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1))) 849# endif 850# else 851# if @BITSIZEOF_SIG_ATOMIC_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIG_ATOMIC_T_UNSIGNED_LONG@ 852# define SIG_ATOMIC_MAX (((1UL << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1) 853# elif @BITSIZEOF_SIG_ATOMIC_T@ >= @BITSIZEOF_UNSIGNED_INT@ 854# define SIG_ATOMIC_MAX (((1U << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1) 855# else 856# define SIG_ATOMIC_MAX (((1 << (@BITSIZEOF_SIG_ATOMIC_T@ - 1)) - 1) * 2 + 1) 857# endif 858# endif 859#endif 860 861/* size_t limit */ 862#ifndef SIZE_MAX /* SIZE_MAX may also be defined in config.h. */ 863# if @BITSIZEOF_SIZE_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_SIZE_T_UNSIGNED_LONG@ 864# define SIZE_MAX (((1UL << (@BITSIZEOF_SIZE_T@ - 1)) - 1) * 2 + 1) 865# else 866# define SIZE_MAX (((1U << (@BITSIZEOF_SIZE_T@ - 1)) - 1) * 2 + 1) 867# endif 868#endif 869 870/* wchar_t limits may already be defined in <stddef.h>. */ 871#ifndef WCHAR_MIN 872# if @HAVE_SIGNED_WCHAR_T@ 873# if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WCHAR_T_LONG@ 874# define WCHAR_MIN (-1L << (@BITSIZEOF_WCHAR_T@ - 1)) 875# else 876# define WCHAR_MIN (-1 << (@BITSIZEOF_WCHAR_T@ - 1)) 877# endif 878# else 879# if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WCHAR_T_UNSIGNED_LONG@ 880# define WCHAR_MIN 0UL 881# elif @BITSIZEOF_WCHAR_T@ >= @BITSIZEOF_UNSIGNED_INT@ 882# define WCHAR_MIN 0U 883# else 884# define WCHAR_MIN 0 885# endif 886# endif 887#endif 888#ifndef WCHAR_MAX 889# if @HAVE_SIGNED_WCHAR_T@ 890# if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WCHAR_T_LONG@ 891# define WCHAR_MAX (~ (-1L << (@BITSIZEOF_WCHAR_T@ - 1))) 892# else 893# define WCHAR_MAX (~ (-1 << (@BITSIZEOF_WCHAR_T@ - 1))) 894# endif 895# else 896# if @BITSIZEOF_WCHAR_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WCHAR_T_UNSIGNED_LONG@ 897# define WCHAR_MAX (((1UL << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1) 898# elif @BITSIZEOF_WCHAR_T@ >= @BITSIZEOF_UNSIGNED_INT@ 899# define WCHAR_MAX (((1U << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1) 900# else 901# define WCHAR_MAX (((1 << (@BITSIZEOF_WCHAR_T@ - 1)) - 1) * 2 + 1) 902# endif 903# endif 904#endif 905 906/* wint_t limits */ 907#ifndef WINT_MIN 908# if @HAVE_SIGNED_WINT_T@ 909# if @BITSIZEOF_WINT_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WINT_T_LONG@ 910# define WINT_MIN (-1L << (@BITSIZEOF_WINT_T@ - 1)) 911# else 912# define WINT_MIN (-1 << (@BITSIZEOF_WINT_T@ - 1)) 913# endif 914# else 915# if @BITSIZEOF_WINT_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WINT_T_UNSIGNED_LONG@ 916# define WINT_MIN 0UL 917# elif @BITSIZEOF_WINT_T@ >= @BITSIZEOF_UNSIGNED_INT@ 918# define WINT_MIN 0U 919# else 920# define WINT_MIN 0 921# endif 922# endif 923#endif 924#ifndef WINT_MAX 925# if @HAVE_SIGNED_WINT_T@ 926# if @BITSIZEOF_WINT_T@ > @BITSIZEOF_LONG@ || @SAME_TYPE_WINT_T_LONG@ 927# define WINT_MAX (~ (-1L << (@BITSIZEOF_WINT_T@ - 1))) 928# else 929# define WINT_MAX (~ (-1 << (@BITSIZEOF_WINT_T@ - 1))) 930# endif 931# else 932# if @BITSIZEOF_WINT_T@ > @BITSIZEOF_UNSIGNED_LONG@ || @SAME_TYPE_WINT_T_UNSIGNED_LONG@ 933# define WINT_MAX (((1UL << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1) 934# elif @BITSIZEOF_WINT_T@ >= @BITSIZEOF_UNSIGNED_INT@ 935# define WINT_MAX (((1U << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1) 936# else 937# define WINT_MAX (((1 << (@BITSIZEOF_WINT_T@ - 1)) - 1) * 2 + 1) 938# endif 939# endif 940#endif 941 942#endif 943 944/* 7.18.4. Macros for integer constants */ 945 946#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) 947 948/* 7.18.4.1. Macros for minimum-width integer constants */ 949/* According to ISO C 99 Technical Corrigendum 1 */ 950 951#undef INT8_C 952#undef UINT8_C 953#define INT8_C(x) x 954#if @HAVE_UINT8_T@ 955# if @BITSIZEOF_UINT8_T@ < @BITSIZEOF_UNSIGNED_INT@ 956# define UINT8_C(x) x 957# else 958# define UINT8_C(x) x##U 959# endif 960#else 961# define UINT8_C(x) x 962#endif 963 964#undef INT16_C 965#undef UINT16_C 966#define INT16_C(x) x 967#if @HAVE_UINT16_T@ 968# if @BITSIZEOF_UINT16_T@ < @BITSIZEOF_UNSIGNED_INT@ 969# define UINT16_C(x) x 970# else 971# define UINT16_C(x) x##U 972# endif 973#else 974# define UINT16_C(x) x 975#endif 976 977#undef INT32_C 978#undef UINT32_C 979#define INT32_C(x) x 980#if @HAVE_UINT32_T@ 981# if @BITSIZEOF_UINT32_T@ < @BITSIZEOF_UNSIGNED_INT@ 982# define UINT32_C(x) x 983# else 984# define UINT32_C(x) x##U 985# endif 986#else 987# define UINT32_C(x) x 988#endif 989 990#undef INT64_C 991#undef UINT64_C 992#if @HAVE_LONG_64BIT@ 993# define INT64_C(x) x##L 994# define UINT64_C(x) x##UL 995#elif @HAVE_LONG_LONG_64BIT@ 996# define INT64_C(x) x##LL 997# define UINT64_C(x) x##ULL 998#elif defined(_MSC_VER) 999# define INT64_C(x) x##i64 1000# define UINT64_C(x) x##ui64 1001#endif 1002 1003/* 7.18.4.2. Macros for greatest-width integer constants */ 1004 1005#undef INTMAX_C 1006#undef UINTMAX_C 1007#if @HAVE_LONG_64BIT@ 1008# define INTMAX_C(x) x##L 1009# define UINTMAX_C(x) x##UL 1010#elif @HAVE_LONG_LONG_64BIT@ 1011# define INTMAX_C(x) x##LL 1012# define UINTMAX_C(x) x##ULL 1013#elif defined(_MSC_VER) 1014# define INTMAX_C(x) x##i64 1015# define UINTMAX_C(x) x##ui64 1016#else 1017# define INTMAX_C(x) x 1018# define UINTMAX_C(x) x##U 1019#endif 1020 1021#endif 1022 1023#endif /* _STDINT_H */ 1024