Update headers to support long long (and intmax_t typedef'd as long long).

This includes:
*Functions operating on long long in <stdlib.h>
*Limits of long long types in <limits.h>
*64-bit types and limits (plus intmax_t and its limits) in <stdint.h>
*New format codes, plus functions operating on intmax_t, in <inttypes.h>

The new stuff is generally conditionalized to only be included if __ORCAC_HAS_LONG_LONG__ is defined, or if the implementation claims to be C99 or later. This allows the headers to remain usable with older versions of ORCA/C, or with any hypothetical "strict C89" mode that might be implemented in the future.
This commit is contained in:
Stephen Heumann 2021-02-17 14:57:18 -06:00
parent 6bb91d20e5
commit 31adb5f5d6
4 changed files with 140 additions and 52 deletions

View File

@ -7,15 +7,6 @@
* *
****************************************************************/ ****************************************************************/
/*
* Note: The format specifier macros defined here generally comply with the
* C99 and C11 standards, except that those associated with intmax_t and
* uintmax_t correspond to their non-standard definitions as 32-bit types.
*
* The functions that the standards specify should be declared in this header
* are not available.
*/
#ifndef __inttypes__ #ifndef __inttypes__
#define __inttypes__ #define __inttypes__
@ -26,25 +17,31 @@
#define PRId8 "d" /* int8_t */ #define PRId8 "d" /* int8_t */
#define PRId16 "d" /* int16_t */ #define PRId16 "d" /* int16_t */
#define PRId32 "ld" /* int32_t */ #define PRId32 "ld" /* int32_t */
#define PRId64 "lld" /* int64_t */
#define PRIdLEAST8 "d" /* int_least8_t */ #define PRIdLEAST8 "d" /* int_least8_t */
#define PRIdLEAST16 "d" /* int_least16_t */ #define PRIdLEAST16 "d" /* int_least16_t */
#define PRIdLEAST32 "ld" /* int_least32_t */ #define PRIdLEAST32 "ld" /* int_least32_t */
#define PRIdLEAST64 "lld" /* int_least64_t */
#define PRIdFAST8 "d" /* int_fast8_t */ #define PRIdFAST8 "d" /* int_fast8_t */
#define PRIdFAST16 "d" /* int_fast16_t */ #define PRIdFAST16 "d" /* int_fast16_t */
#define PRIdFAST32 "ld" /* int_fast32_t */ #define PRIdFAST32 "ld" /* int_fast32_t */
#define PRIdMAX "ld" /* intmax_t */ #define PRIdFAST64 "lld" /* int_fast64_t */
#define PRIdMAX "jd" /* intmax_t */
#define PRIdPTR "ld" /* intptr_t */ #define PRIdPTR "ld" /* intptr_t */
#define PRIi8 "i" /* int8_t */ #define PRIi8 "i" /* int8_t */
#define PRIi16 "i" /* int16_t */ #define PRIi16 "i" /* int16_t */
#define PRIi32 "li" /* int32_t */ #define PRIi32 "li" /* int32_t */
#define PRIi64 "lli" /* int64_t */
#define PRIiLEAST8 "i" /* int_least8_t */ #define PRIiLEAST8 "i" /* int_least8_t */
#define PRIiLEAST16 "i" /* int_least16_t */ #define PRIiLEAST16 "i" /* int_least16_t */
#define PRIiLEAST32 "li" /* int_least32_t */ #define PRIiLEAST32 "li" /* int_least32_t */
#define PRIiLEAST64 "lli" /* int_least64_t */
#define PRIiFAST8 "i" /* int_fast8_t */ #define PRIiFAST8 "i" /* int_fast8_t */
#define PRIiFAST16 "i" /* int_fast16_t */ #define PRIiFAST16 "i" /* int_fast16_t */
#define PRIiFAST32 "li" /* int_fast32_t */ #define PRIiFAST32 "li" /* int_fast32_t */
#define PRIiMAX "li" /* intmax_t */ #define PRIiFAST64 "lli" /* int_fast64_t */
#define PRIiMAX "ji" /* intmax_t */
#define PRIiPTR "li" /* intptr_t */ #define PRIiPTR "li" /* intptr_t */
/* fprintf macros for unsigned integers */ /* fprintf macros for unsigned integers */
@ -52,49 +49,61 @@
#define PRIo8 "o" /* uint8_t */ #define PRIo8 "o" /* uint8_t */
#define PRIo16 "o" /* uint16_t */ #define PRIo16 "o" /* uint16_t */
#define PRIo32 "lo" /* uint32_t */ #define PRIo32 "lo" /* uint32_t */
#define PRIo64 "llo" /* uint64_t */
#define PRIoLEAST8 "o" /* uint_least8_t */ #define PRIoLEAST8 "o" /* uint_least8_t */
#define PRIoLEAST16 "o" /* uint_least16_t */ #define PRIoLEAST16 "o" /* uint_least16_t */
#define PRIoLEAST32 "lo" /* uint_least32_t */ #define PRIoLEAST32 "lo" /* uint_least32_t */
#define PRIoLEAST64 "llo" /* uint_least64_t */
#define PRIoFAST8 "o" /* uint_fast8_t */ #define PRIoFAST8 "o" /* uint_fast8_t */
#define PRIoFAST16 "o" /* uint_fast16_t */ #define PRIoFAST16 "o" /* uint_fast16_t */
#define PRIoFAST32 "lo" /* uint_fast32_t */ #define PRIoFAST32 "lo" /* uint_fast32_t */
#define PRIoMAX "lo" /* uintmax_t */ #define PRIoFAST64 "llo" /* uint_fast64_t */
#define PRIoMAX "jo" /* uintmax_t */
#define PRIoPTR "lo" /* uintptr_t */ #define PRIoPTR "lo" /* uintptr_t */
#define PRIu8 "u" /* uint8_t */ #define PRIu8 "u" /* uint8_t */
#define PRIu16 "u" /* uint16_t */ #define PRIu16 "u" /* uint16_t */
#define PRIu32 "lu" /* uint32_t */ #define PRIu32 "lu" /* uint32_t */
#define PRIu64 "llu" /* uint64_t */
#define PRIuLEAST8 "u" /* uint_least8_t */ #define PRIuLEAST8 "u" /* uint_least8_t */
#define PRIuLEAST16 "u" /* uint_least16_t */ #define PRIuLEAST16 "u" /* uint_least16_t */
#define PRIuLEAST32 "lu" /* uint_least32_t */ #define PRIuLEAST32 "lu" /* uint_least32_t */
#define PRIuLEAST64 "llu" /* uint_least64_t */
#define PRIuFAST8 "u" /* uint_fast8_t */ #define PRIuFAST8 "u" /* uint_fast8_t */
#define PRIuFAST16 "u" /* uint_fast16_t */ #define PRIuFAST16 "u" /* uint_fast16_t */
#define PRIuFAST32 "lu" /* uint_fast32_t */ #define PRIuFAST32 "lu" /* uint_fast32_t */
#define PRIuMAX "lu" /* uintmax_t */ #define PRIuFAST64 "llu" /* uint_fast64_t */
#define PRIuMAX "ju" /* uintmax_t */
#define PRIuPTR "lu" /* uintptr_t */ #define PRIuPTR "lu" /* uintptr_t */
#define PRIx8 "x" /* uint8_t */ #define PRIx8 "x" /* uint8_t */
#define PRIx16 "x" /* uint16_t */ #define PRIx16 "x" /* uint16_t */
#define PRIx32 "lx" /* uint32_t */ #define PRIx32 "lx" /* uint32_t */
#define PRIx64 "llx" /* uint64_t */
#define PRIxLEAST8 "x" /* uint_least8_t */ #define PRIxLEAST8 "x" /* uint_least8_t */
#define PRIxLEAST16 "x" /* uint_least16_t */ #define PRIxLEAST16 "x" /* uint_least16_t */
#define PRIxLEAST32 "lx" /* uint_least32_t */ #define PRIxLEAST32 "lx" /* uint_least32_t */
#define PRIxLEAST64 "llx" /* uint_least64_t */
#define PRIxFAST8 "x" /* uint_fast8_t */ #define PRIxFAST8 "x" /* uint_fast8_t */
#define PRIxFAST16 "x" /* uint_fast16_t */ #define PRIxFAST16 "x" /* uint_fast16_t */
#define PRIxFAST32 "lx" /* uint_fast32_t */ #define PRIxFAST32 "lx" /* uint_fast32_t */
#define PRIxMAX "lx" /* uintmax_t */ #define PRIxFAST64 "llx" /* uint_fast64_t */
#define PRIxMAX "jx" /* uintmax_t */
#define PRIxPTR "lx" /* uintptr_t */ #define PRIxPTR "lx" /* uintptr_t */
#define PRIX8 "X" /* uint8_t */ #define PRIX8 "X" /* uint8_t */
#define PRIX16 "X" /* uint16_t */ #define PRIX16 "X" /* uint16_t */
#define PRIX32 "lX" /* uint32_t */ #define PRIX32 "lX" /* uint32_t */
#define PRIX64 "llX" /* uint64_t */
#define PRIXLEAST8 "X" /* uint_least8_t */ #define PRIXLEAST8 "X" /* uint_least8_t */
#define PRIXLEAST16 "X" /* uint_least16_t */ #define PRIXLEAST16 "X" /* uint_least16_t */
#define PRIXLEAST32 "lX" /* uint_least32_t */ #define PRIXLEAST32 "lX" /* uint_least32_t */
#define PRIXLEAST64 "llX" /* uint_least64_t */
#define PRIXFAST8 "X" /* uint_fast8_t */ #define PRIXFAST8 "X" /* uint_fast8_t */
#define PRIXFAST16 "X" /* uint_fast16_t */ #define PRIXFAST16 "X" /* uint_fast16_t */
#define PRIXFAST32 "lX" /* uint_fast32_t */ #define PRIXFAST32 "lX" /* uint_fast32_t */
#define PRIXMAX "lX" /* uintmax_t */ #define PRIXFAST64 "llX" /* uint_fast64_t */
#define PRIXMAX "jX" /* uintmax_t */
#define PRIXPTR "lX" /* uintptr_t */ #define PRIXPTR "lX" /* uintptr_t */
/* fscanf macros for signed integers */ /* fscanf macros for signed integers */
@ -102,25 +111,31 @@
#define SCNd8 "hhd" /* int8_t */ #define SCNd8 "hhd" /* int8_t */
#define SCNd16 "hd" /* int16_t */ #define SCNd16 "hd" /* int16_t */
#define SCNd32 "ld" /* int32_t */ #define SCNd32 "ld" /* int32_t */
#define SCNd64 "lld" /* int64_t */
#define SCNdLEAST8 "hhd" /* int_least8_t */ #define SCNdLEAST8 "hhd" /* int_least8_t */
#define SCNdLEAST16 "hd" /* int_least16_t */ #define SCNdLEAST16 "hd" /* int_least16_t */
#define SCNdLEAST32 "ld" /* int_least32_t */ #define SCNdLEAST32 "ld" /* int_least32_t */
#define SCNdLEAST64 "lld" /* int_least64_t */
#define SCNdFAST8 "hd" /* int_fast8_t */ #define SCNdFAST8 "hd" /* int_fast8_t */
#define SCNdFAST16 "hd" /* int_fast16_t */ #define SCNdFAST16 "hd" /* int_fast16_t */
#define SCNdFAST32 "ld" /* int_fast32_t */ #define SCNdFAST32 "ld" /* int_fast32_t */
#define SCNdMAX "ld" /* intmax_t */ #define SCNdFAST64 "lld" /* int_fast64_t */
#define SCNdMAX "jd" /* intmax_t */
#define SCNdPTR "ld" /* intptr_t */ #define SCNdPTR "ld" /* intptr_t */
#define SCNi8 "hhi" /* int8_t */ #define SCNi8 "hhi" /* int8_t */
#define SCNi16 "hi" /* int16_t */ #define SCNi16 "hi" /* int16_t */
#define SCNi32 "li" /* int32_t */ #define SCNi32 "li" /* int32_t */
#define SCNi64 "lli" /* int64_t */
#define SCNiLEAST8 "hhi" /* int_least8_t */ #define SCNiLEAST8 "hhi" /* int_least8_t */
#define SCNiLEAST16 "hi" /* int_least16_t */ #define SCNiLEAST16 "hi" /* int_least16_t */
#define SCNiLEAST32 "li" /* int_least32_t */ #define SCNiLEAST32 "li" /* int_least32_t */
#define SCNiLEAST64 "lli" /* int_least64_t */
#define SCNiFAST8 "hi" /* int_fast8_t */ #define SCNiFAST8 "hi" /* int_fast8_t */
#define SCNiFAST16 "hi" /* int_fast16_t */ #define SCNiFAST16 "hi" /* int_fast16_t */
#define SCNiFAST32 "li" /* int_fast32_t */ #define SCNiFAST32 "li" /* int_fast32_t */
#define SCNiMAX "li" /* intmax_t */ #define SCNiFAST64 "lli" /* int_fast64_t */
#define SCNiMAX "ji" /* intmax_t */
#define SCNiPTR "li" /* intptr_t */ #define SCNiPTR "li" /* intptr_t */
/* fscanf macros for unsigned integers */ /* fscanf macros for unsigned integers */
@ -128,53 +143,63 @@
#define SCNo8 "hho" /* uint8_t */ #define SCNo8 "hho" /* uint8_t */
#define SCNo16 "ho" /* uint16_t */ #define SCNo16 "ho" /* uint16_t */
#define SCNo32 "lo" /* uint32_t */ #define SCNo32 "lo" /* uint32_t */
#define SCNo64 "llo" /* uint64_t */
#define SCNoLEAST8 "hho" /* uint_least8_t */ #define SCNoLEAST8 "hho" /* uint_least8_t */
#define SCNoLEAST16 "ho" /* uint_least16_t */ #define SCNoLEAST16 "ho" /* uint_least16_t */
#define SCNoLEAST32 "lo" /* uint_least32_t */ #define SCNoLEAST32 "lo" /* uint_least32_t */
#define SCNoLEAST64 "llo" /* uint_least64_t */
#define SCNoFAST8 "ho" /* uint_fast8_t */ #define SCNoFAST8 "ho" /* uint_fast8_t */
#define SCNoFAST16 "ho" /* uint_fast16_t */ #define SCNoFAST16 "ho" /* uint_fast16_t */
#define SCNoFAST32 "lo" /* uint_fast32_t */ #define SCNoFAST32 "lo" /* uint_fast32_t */
#define SCNoMAX "lo" /* uintmax_t */ #define SCNoFAST64 "llo" /* uint_fast64_t */
#define SCNoMAX "jo" /* uintmax_t */
#define SCNoPTR "lo" /* uintptr_t */ #define SCNoPTR "lo" /* uintptr_t */
#define SCNu8 "hhu" /* uint8_t */ #define SCNu8 "hhu" /* uint8_t */
#define SCNu16 "hu" /* uint16_t */ #define SCNu16 "hu" /* uint16_t */
#define SCNu32 "lu" /* uint32_t */ #define SCNu32 "lu" /* uint32_t */
#define SCNu64 "llu" /* uint64_t */
#define SCNuLEAST8 "hhu" /* uint_least8_t */ #define SCNuLEAST8 "hhu" /* uint_least8_t */
#define SCNuLEAST16 "hu" /* uint_least16_t */ #define SCNuLEAST16 "hu" /* uint_least16_t */
#define SCNuLEAST32 "lu" /* uint_least32_t */ #define SCNuLEAST32 "lu" /* uint_least32_t */
#define SCNuLEAST64 "llu" /* uint_least64_t */
#define SCNuFAST8 "hu" /* uint_fast8_t */ #define SCNuFAST8 "hu" /* uint_fast8_t */
#define SCNuFAST16 "hu" /* uint_fast16_t */ #define SCNuFAST16 "hu" /* uint_fast16_t */
#define SCNuFAST32 "lu" /* uint_fast32_t */ #define SCNuFAST32 "lu" /* uint_fast32_t */
#define SCNuMAX "lu" /* uintmax_t */ #define SCNuFAST64 "llu" /* uint_fast64_t */
#define SCNuMAX "ju" /* uintmax_t */
#define SCNuPTR "lu" /* uintptr_t */ #define SCNuPTR "lu" /* uintptr_t */
#define SCNx8 "hhx" /* uint8_t */ #define SCNx8 "hhx" /* uint8_t */
#define SCNx16 "hx" /* uint16_t */ #define SCNx16 "hx" /* uint16_t */
#define SCNx32 "lx" /* uint32_t */ #define SCNx32 "lx" /* uint32_t */
#define SCNx64 "llx" /* uint64_t */
#define SCNxLEAST8 "hhx" /* uint_least8_t */ #define SCNxLEAST8 "hhx" /* uint_least8_t */
#define SCNxLEAST16 "hx" /* uint_least16_t */ #define SCNxLEAST16 "hx" /* uint_least16_t */
#define SCNxLEAST32 "lx" /* uint_least32_t */ #define SCNxLEAST32 "lx" /* uint_least32_t */
#define SCNxLEAST64 "llx" /* uint_least64_t */
#define SCNxFAST8 "hx" /* uint_fast8_t */ #define SCNxFAST8 "hx" /* uint_fast8_t */
#define SCNxFAST16 "hx" /* uint_fast16_t */ #define SCNxFAST16 "hx" /* uint_fast16_t */
#define SCNxFAST32 "lx" /* uint_fast32_t */ #define SCNxFAST32 "lx" /* uint_fast32_t */
#define SCNxMAX "lx" /* uintmax_t */ #define SCNxFAST64 "llx" /* uint_fast64_t */
#define SCNxMAX "jx" /* uintmax_t */
#define SCNxPTR "lx" /* uintptr_t */ #define SCNxPTR "lx" /* uintptr_t */
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
typedef struct {intmax_t quot,rem;} imaxdiv_t;
intmax_t imaxabs(intmax_t);
imaxdiv_t imaxdiv(intmax_t, intmax_t);
intmax_t strtoimax(const char * restrict, char ** restrict, int);
uintmax_t strtoumax(const char * restrict, char ** restrict, int);
#endif
/* /*
* The C99 and C11 standards require the following functions and the * The C99 and C11 standards require the following functions
* type imaxdiv_t to be declared here, but they are not currently supported. * to be declared here, but they are not currently supported.
* *
* intmax_t imaxabs(intmax_t j); * intmax_t wcstoimax(const wchar_t * restrict, wchar_t ** restrict, int);
* imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom); * uintmax_t wcstoumax(const wchar_t * restrict, wchar_t ** restrict, int);
* intmax_t strtoimax(const char * restrict nptr,
* char ** restrict endptr, int base);
* uintmax_t strtoumax(const char * restrict nptr,
* char ** restrict endptr, int base);
* intmax_t wcstoimax(const wchar_t * restrict nptr,
* wchar_t ** restrict endptr, int base);
* uintmax_t wcstoumax(const wchar_t * restrict nptr,
* wchar_t ** restrict endptr, int base);
*/ */
#endif #endif

View File

@ -29,5 +29,10 @@
#define UINT_MAX 65535u #define UINT_MAX 65535u
#define ULONG_MAX 4294967295u #define ULONG_MAX 4294967295u
#define USHRT_MAX 65535u #define USHRT_MAX 65535u
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
#define LLONG_MIN (-9223372036854775807-1)
#define LLONG_MAX 9223372036854775807
#define ULLONG_MAX 18446744073709551615u
#endif
#endif #endif

View File

@ -7,12 +7,6 @@
* *
****************************************************************/ ****************************************************************/
/*
* Note: This header mostly complies with the C99 and C11 standards,
* except that 64-bit types are not provided because ORCA/C does not
* support them. See comments below for further details.
*/
#ifndef __stdint__ #ifndef __stdint__
#define __stdint__ #define __stdint__
@ -20,80 +14,122 @@
typedef signed char int8_t; typedef signed char int8_t;
typedef short int16_t; typedef short int16_t;
typedef long int32_t; typedef long int32_t;
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
typedef long long int64_t;
#endif
typedef unsigned char uint8_t; typedef unsigned char uint8_t;
typedef unsigned short uint16_t; typedef unsigned short uint16_t;
typedef unsigned long uint32_t; typedef unsigned long uint32_t;
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
typedef unsigned long long uint64_t;
#endif
/* Minimum-width integer types */ /* Minimum-width integer types */
typedef signed char int_least8_t; typedef signed char int_least8_t;
typedef short int_least16_t; typedef short int_least16_t;
typedef long int_least32_t; typedef long int_least32_t;
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
typedef long long int_least64_t;
#endif
typedef unsigned char uint_least8_t; typedef unsigned char uint_least8_t;
typedef unsigned short uint_least16_t; typedef unsigned short uint_least16_t;
typedef unsigned long uint_least32_t; typedef unsigned long uint_least32_t;
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
typedef unsigned long long uint_least64_t;
#endif
/* Fastest minimum-width integer types */ /* Fastest minimum-width integer types */
typedef short int_fast8_t; /* Note: 16-bit type */ typedef short int_fast8_t; /* Note: 16-bit type */
typedef short int_fast16_t; typedef short int_fast16_t;
typedef long int_fast32_t; typedef long int_fast32_t;
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
typedef long long int_fast64_t;
#endif
typedef unsigned short uint_fast8_t; /* Note: 16-bit type */ typedef unsigned short uint_fast8_t; /* Note: 16-bit type */
typedef unsigned short uint_fast16_t; typedef unsigned short uint_fast16_t;
typedef unsigned long uint_fast32_t; typedef unsigned long uint_fast32_t;
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
typedef unsigned long long uint_fast64_t;
#endif
/* Integer types capable of holding object pointers */ /* Integer types capable of holding object pointers */
typedef long intptr_t; typedef long intptr_t;
typedef unsigned long uintptr_t; typedef unsigned long uintptr_t;
/* Greatest-width integer types */ /* Greatest-width integer types */
/* #if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
* Note: In C99 and C11, these are required to be at least 64 bits. typedef long long intmax_t;
* Since ORCA/C does not currently support 64-bit integer types, typedef unsigned long long uintmax_t;
* they are currently defined as 32-bit types instead. #endif
*/
typedef long intmax_t;
typedef unsigned long uintmax_t;
/* Limits of exact-width integer types */ /* Limits of exact-width integer types */
#define INT8_MIN (-128) #define INT8_MIN (-128)
#define INT16_MIN (-32767-1) #define INT16_MIN (-32767-1)
#define INT32_MIN (-2147483647-1) #define INT32_MIN (-2147483647-1)
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
#define INT64_MIN (-9223372036854775807-1)
#endif
#define INT8_MAX 127 #define INT8_MAX 127
#define INT16_MAX 32767 #define INT16_MAX 32767
#define INT32_MAX 2147483647 #define INT32_MAX 2147483647
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
#define INT64_MAX 9223372036854775807
#endif
#define UINT8_MAX 255 #define UINT8_MAX 255
#define UINT16_MAX 65535u #define UINT16_MAX 65535u
#define UINT32_MAX 4294967295u #define UINT32_MAX 4294967295u
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
#define UINT64_MAX 18446744073709551615u
#endif
/* Limits of minimum-width integer types */ /* Limits of minimum-width integer types */
#define INT_LEAST8_MIN (-128) #define INT_LEAST8_MIN (-128)
#define INT_LEAST16_MIN (-32767-1) #define INT_LEAST16_MIN (-32767-1)
#define INT_LEAST32_MIN (-2147483647-1) #define INT_LEAST32_MIN (-2147483647-1)
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
#define INT_LEAST64_MIN (-9223372036854775807-1)
#endif
#define INT_LEAST8_MAX 127 #define INT_LEAST8_MAX 127
#define INT_LEAST16_MAX 32767 #define INT_LEAST16_MAX 32767
#define INT_LEAST32_MAX 2147483647 #define INT_LEAST32_MAX 2147483647
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
#define INT_LEAST64_MAX 9223372036854775807
#endif
#define UINT_LEAST8_MAX 255 #define UINT_LEAST8_MAX 255
#define UINT_LEAST16_MAX 65535u #define UINT_LEAST16_MAX 65535u
#define UINT_LEAST32_MAX 4294967295u #define UINT_LEAST32_MAX 4294967295u
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
#define UINT_LEAST64_MAX 18446744073709551615u
#endif
/* Limits of fastest minimum-width integer types */ /* Limits of fastest minimum-width integer types */
#define INT_FAST8_MIN (-32767-1) #define INT_FAST8_MIN (-32767-1)
#define INT_FAST16_MIN (-32767-1) #define INT_FAST16_MIN (-32767-1)
#define INT_FAST32_MIN (-2147483647-1) #define INT_FAST32_MIN (-2147483647-1)
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
#define INT_FAST64_MIN (-9223372036854775807-1)
#endif
#define INT_FAST8_MAX 32767 #define INT_FAST8_MAX 32767
#define INT_FAST16_MAX 32767 #define INT_FAST16_MAX 32767
#define INT_FAST32_MAX 2147483647 #define INT_FAST32_MAX 2147483647
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
#define INT_FAST64_MAX 9223372036854775807
#endif
#define UINT_FAST8_MAX 65535u #define UINT_FAST8_MAX 65535u
#define UINT_FAST16_MAX 65535u #define UINT_FAST16_MAX 65535u
#define UINT_FAST32_MAX 4294967295u #define UINT_FAST32_MAX 4294967295u
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
#define UINT_FAST64_MAX 18446744073709551615u
#endif
/* Limits of integer types capable of holding object pointers */ /* Limits of integer types capable of holding object pointers */
#define INTPTR_MIN (-2147483647-1) #define INTPTR_MIN (-2147483647-1)
@ -101,10 +137,11 @@ typedef unsigned long uintmax_t;
#define UINTPTR_MAX 4294967295u #define UINTPTR_MAX 4294967295u
/* Limits of greatest-width integer types */ /* Limits of greatest-width integer types */
/* Note: These limits are smaller than C99 and C11 require. */ #if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
#define INTMAX_MIN (-2147483647-1) #define INTMAX_MIN (-9223372036854775807-1)
#define INTMAX_MAX 2147483647 #define INTMAX_MAX 9223372036854775807
#define UINTMAX_MAX 4294967295u #define UINTMAX_MAX 18446744073709551615u
#endif
/* Limits of other integer types */ /* Limits of other integer types */
#define PTRDIFF_MIN (-2147483647-1) #define PTRDIFF_MIN (-2147483647-1)
@ -128,14 +165,21 @@ typedef unsigned long uintmax_t;
#define INT8_C(val) (val) #define INT8_C(val) (val)
#define INT16_C(val) (val) #define INT16_C(val) (val)
#define INT32_C(val) (val ## L) #define INT32_C(val) (val ## L)
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
#define INT64_C(val) (val ## LL)
#endif
#define UINT8_C(val) (val) #define UINT8_C(val) (val)
#define UINT16_C(val) (val ## U) #define UINT16_C(val) (val ## U)
#define UINT32_C(val) (val ## UL) #define UINT32_C(val) (val ## UL)
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
#define UINT64_C(val) (val ## ULL)
#endif
/* Macros for greatest-width integer constants */ /* Macros for greatest-width integer constants */
/* Note: These use 32-bit types, consistent with intmax_t and uintmax_t. */ #if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
#define INTMAX_C(val) (val ## L) #define INTMAX_C(val) (val ## LL)
#define UINTMAX_C(val) (val ## UL) #define UINTMAX_C(val) (val ## ULL)
#endif
#endif #endif

View File

@ -29,6 +29,9 @@ typedef unsigned long size_t;
typedef struct {int quot,rem;} div_t; typedef struct {int quot,rem;} div_t;
typedef struct {long quot,rem;} ldiv_t; typedef struct {long quot,rem;} ldiv_t;
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
typedef struct {long long quot,rem;} lldiv_t;
#endif
#ifndef __KeepNamespacePure__ #ifndef __KeepNamespacePure__
#define clalloc(x,y) calloc((x),(y)) #define clalloc(x,y) calloc((x),(y))
@ -45,6 +48,9 @@ int at_quick_exit(void (*__func)(void));
double atof(const char *); double atof(const char *);
int atoi(const char *); int atoi(const char *);
long atol(const char *); long atol(const char *);
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
long long atoll(const char *);
#endif
void *bsearch(const void *, const void *, size_t, size_t, int (*__compar)(const void *, const void *)); void *bsearch(const void *, const void *, size_t, size_t, int (*__compar)(const void *, const void *));
void *calloc(size_t, size_t); void *calloc(size_t, size_t);
div_t div(int, int); div_t div(int, int);
@ -55,6 +61,10 @@ void free(void *);
char *getenv(const char *); char *getenv(const char *);
long labs(long); long labs(long);
ldiv_t ldiv(long, long); ldiv_t ldiv(long, long);
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
long long llabs(long long);
lldiv_t lldiv(long long, long long);
#endif
void *malloc(size_t); void *malloc(size_t);
void qsort(void *, size_t, size_t, int (*__compar)(const void *, const void *)); void qsort(void *, size_t, size_t, int (*__compar)(const void *, const void *));
void quick_exit(int); void quick_exit(int);
@ -64,6 +74,10 @@ void srand(unsigned);
double strtod(const char *, char **); double strtod(const char *, char **);
long strtol(const char *, char **, int); long strtol(const char *, char **, int);
unsigned long strtoul(const char *, char **, int); unsigned long strtoul(const char *, char **, int);
#if defined(__ORCAC_HAS_LONG_LONG__) || __STDC_VERSION__ >= 199901L
long long strtoll(const char * restrict, char ** restrict, int);
unsigned long long strtoull(const char * restrict, char ** restrict, int);
#endif
int system(const char *); int system(const char *);
#endif #endif