2017-10-22 01:40:41 +00:00
|
|
|
/****************************************************************
|
|
|
|
*
|
|
|
|
* inttypes.h - format conversion of integer types
|
|
|
|
*
|
|
|
|
* September 2017
|
|
|
|
* Stephen Heumann
|
|
|
|
*
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#ifndef __inttypes__
|
|
|
|
#define __inttypes__
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
/* fprintf macros for signed integers */
|
|
|
|
|
|
|
|
#define PRId8 "d" /* int8_t */
|
|
|
|
#define PRId16 "d" /* int16_t */
|
|
|
|
#define PRId32 "ld" /* int32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define PRId64 "lld" /* int64_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define PRIdLEAST8 "d" /* int_least8_t */
|
|
|
|
#define PRIdLEAST16 "d" /* int_least16_t */
|
|
|
|
#define PRIdLEAST32 "ld" /* int_least32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define PRIdLEAST64 "lld" /* int_least64_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define PRIdFAST8 "d" /* int_fast8_t */
|
|
|
|
#define PRIdFAST16 "d" /* int_fast16_t */
|
|
|
|
#define PRIdFAST32 "ld" /* int_fast32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define PRIdFAST64 "lld" /* int_fast64_t */
|
|
|
|
#define PRIdMAX "jd" /* intmax_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define PRIdPTR "ld" /* intptr_t */
|
|
|
|
|
|
|
|
#define PRIi8 "i" /* int8_t */
|
|
|
|
#define PRIi16 "i" /* int16_t */
|
|
|
|
#define PRIi32 "li" /* int32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define PRIi64 "lli" /* int64_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define PRIiLEAST8 "i" /* int_least8_t */
|
|
|
|
#define PRIiLEAST16 "i" /* int_least16_t */
|
|
|
|
#define PRIiLEAST32 "li" /* int_least32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define PRIiLEAST64 "lli" /* int_least64_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define PRIiFAST8 "i" /* int_fast8_t */
|
|
|
|
#define PRIiFAST16 "i" /* int_fast16_t */
|
|
|
|
#define PRIiFAST32 "li" /* int_fast32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define PRIiFAST64 "lli" /* int_fast64_t */
|
|
|
|
#define PRIiMAX "ji" /* intmax_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define PRIiPTR "li" /* intptr_t */
|
|
|
|
|
|
|
|
/* fprintf macros for unsigned integers */
|
|
|
|
|
|
|
|
#define PRIo8 "o" /* uint8_t */
|
|
|
|
#define PRIo16 "o" /* uint16_t */
|
|
|
|
#define PRIo32 "lo" /* uint32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define PRIo64 "llo" /* uint64_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define PRIoLEAST8 "o" /* uint_least8_t */
|
|
|
|
#define PRIoLEAST16 "o" /* uint_least16_t */
|
|
|
|
#define PRIoLEAST32 "lo" /* uint_least32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define PRIoLEAST64 "llo" /* uint_least64_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define PRIoFAST8 "o" /* uint_fast8_t */
|
|
|
|
#define PRIoFAST16 "o" /* uint_fast16_t */
|
|
|
|
#define PRIoFAST32 "lo" /* uint_fast32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define PRIoFAST64 "llo" /* uint_fast64_t */
|
|
|
|
#define PRIoMAX "jo" /* uintmax_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define PRIoPTR "lo" /* uintptr_t */
|
|
|
|
|
|
|
|
#define PRIu8 "u" /* uint8_t */
|
|
|
|
#define PRIu16 "u" /* uint16_t */
|
|
|
|
#define PRIu32 "lu" /* uint32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define PRIu64 "llu" /* uint64_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define PRIuLEAST8 "u" /* uint_least8_t */
|
|
|
|
#define PRIuLEAST16 "u" /* uint_least16_t */
|
|
|
|
#define PRIuLEAST32 "lu" /* uint_least32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define PRIuLEAST64 "llu" /* uint_least64_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define PRIuFAST8 "u" /* uint_fast8_t */
|
|
|
|
#define PRIuFAST16 "u" /* uint_fast16_t */
|
|
|
|
#define PRIuFAST32 "lu" /* uint_fast32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define PRIuFAST64 "llu" /* uint_fast64_t */
|
|
|
|
#define PRIuMAX "ju" /* uintmax_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define PRIuPTR "lu" /* uintptr_t */
|
|
|
|
|
|
|
|
#define PRIx8 "x" /* uint8_t */
|
|
|
|
#define PRIx16 "x" /* uint16_t */
|
|
|
|
#define PRIx32 "lx" /* uint32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define PRIx64 "llx" /* uint64_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define PRIxLEAST8 "x" /* uint_least8_t */
|
|
|
|
#define PRIxLEAST16 "x" /* uint_least16_t */
|
|
|
|
#define PRIxLEAST32 "lx" /* uint_least32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define PRIxLEAST64 "llx" /* uint_least64_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define PRIxFAST8 "x" /* uint_fast8_t */
|
|
|
|
#define PRIxFAST16 "x" /* uint_fast16_t */
|
|
|
|
#define PRIxFAST32 "lx" /* uint_fast32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define PRIxFAST64 "llx" /* uint_fast64_t */
|
|
|
|
#define PRIxMAX "jx" /* uintmax_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define PRIxPTR "lx" /* uintptr_t */
|
|
|
|
|
|
|
|
#define PRIX8 "X" /* uint8_t */
|
|
|
|
#define PRIX16 "X" /* uint16_t */
|
|
|
|
#define PRIX32 "lX" /* uint32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define PRIX64 "llX" /* uint64_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define PRIXLEAST8 "X" /* uint_least8_t */
|
|
|
|
#define PRIXLEAST16 "X" /* uint_least16_t */
|
|
|
|
#define PRIXLEAST32 "lX" /* uint_least32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define PRIXLEAST64 "llX" /* uint_least64_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define PRIXFAST8 "X" /* uint_fast8_t */
|
|
|
|
#define PRIXFAST16 "X" /* uint_fast16_t */
|
|
|
|
#define PRIXFAST32 "lX" /* uint_fast32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define PRIXFAST64 "llX" /* uint_fast64_t */
|
|
|
|
#define PRIXMAX "jX" /* uintmax_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define PRIXPTR "lX" /* uintptr_t */
|
|
|
|
|
|
|
|
/* fscanf macros for signed integers */
|
|
|
|
|
2020-01-22 18:14:39 +00:00
|
|
|
#define SCNd8 "hhd" /* int8_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define SCNd16 "hd" /* int16_t */
|
|
|
|
#define SCNd32 "ld" /* int32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define SCNd64 "lld" /* int64_t */
|
2020-01-22 18:14:39 +00:00
|
|
|
#define SCNdLEAST8 "hhd" /* int_least8_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define SCNdLEAST16 "hd" /* int_least16_t */
|
|
|
|
#define SCNdLEAST32 "ld" /* int_least32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define SCNdLEAST64 "lld" /* int_least64_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define SCNdFAST8 "hd" /* int_fast8_t */
|
|
|
|
#define SCNdFAST16 "hd" /* int_fast16_t */
|
|
|
|
#define SCNdFAST32 "ld" /* int_fast32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define SCNdFAST64 "lld" /* int_fast64_t */
|
|
|
|
#define SCNdMAX "jd" /* intmax_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define SCNdPTR "ld" /* intptr_t */
|
|
|
|
|
2020-01-22 18:14:39 +00:00
|
|
|
#define SCNi8 "hhi" /* int8_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define SCNi16 "hi" /* int16_t */
|
|
|
|
#define SCNi32 "li" /* int32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define SCNi64 "lli" /* int64_t */
|
2020-01-22 18:14:39 +00:00
|
|
|
#define SCNiLEAST8 "hhi" /* int_least8_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define SCNiLEAST16 "hi" /* int_least16_t */
|
|
|
|
#define SCNiLEAST32 "li" /* int_least32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define SCNiLEAST64 "lli" /* int_least64_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define SCNiFAST8 "hi" /* int_fast8_t */
|
|
|
|
#define SCNiFAST16 "hi" /* int_fast16_t */
|
|
|
|
#define SCNiFAST32 "li" /* int_fast32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define SCNiFAST64 "lli" /* int_fast64_t */
|
|
|
|
#define SCNiMAX "ji" /* intmax_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define SCNiPTR "li" /* intptr_t */
|
|
|
|
|
|
|
|
/* fscanf macros for unsigned integers */
|
|
|
|
|
2020-01-22 18:14:39 +00:00
|
|
|
#define SCNo8 "hho" /* uint8_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define SCNo16 "ho" /* uint16_t */
|
|
|
|
#define SCNo32 "lo" /* uint32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define SCNo64 "llo" /* uint64_t */
|
2020-01-22 18:14:39 +00:00
|
|
|
#define SCNoLEAST8 "hho" /* uint_least8_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define SCNoLEAST16 "ho" /* uint_least16_t */
|
|
|
|
#define SCNoLEAST32 "lo" /* uint_least32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define SCNoLEAST64 "llo" /* uint_least64_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define SCNoFAST8 "ho" /* uint_fast8_t */
|
|
|
|
#define SCNoFAST16 "ho" /* uint_fast16_t */
|
|
|
|
#define SCNoFAST32 "lo" /* uint_fast32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define SCNoFAST64 "llo" /* uint_fast64_t */
|
|
|
|
#define SCNoMAX "jo" /* uintmax_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define SCNoPTR "lo" /* uintptr_t */
|
|
|
|
|
2020-01-22 18:14:39 +00:00
|
|
|
#define SCNu8 "hhu" /* uint8_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define SCNu16 "hu" /* uint16_t */
|
|
|
|
#define SCNu32 "lu" /* uint32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define SCNu64 "llu" /* uint64_t */
|
2020-01-22 18:14:39 +00:00
|
|
|
#define SCNuLEAST8 "hhu" /* uint_least8_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define SCNuLEAST16 "hu" /* uint_least16_t */
|
|
|
|
#define SCNuLEAST32 "lu" /* uint_least32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define SCNuLEAST64 "llu" /* uint_least64_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define SCNuFAST8 "hu" /* uint_fast8_t */
|
|
|
|
#define SCNuFAST16 "hu" /* uint_fast16_t */
|
|
|
|
#define SCNuFAST32 "lu" /* uint_fast32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define SCNuFAST64 "llu" /* uint_fast64_t */
|
|
|
|
#define SCNuMAX "ju" /* uintmax_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define SCNuPTR "lu" /* uintptr_t */
|
|
|
|
|
2020-01-22 18:14:39 +00:00
|
|
|
#define SCNx8 "hhx" /* uint8_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define SCNx16 "hx" /* uint16_t */
|
|
|
|
#define SCNx32 "lx" /* uint32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define SCNx64 "llx" /* uint64_t */
|
2020-01-22 18:14:39 +00:00
|
|
|
#define SCNxLEAST8 "hhx" /* uint_least8_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define SCNxLEAST16 "hx" /* uint_least16_t */
|
|
|
|
#define SCNxLEAST32 "lx" /* uint_least32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define SCNxLEAST64 "llx" /* uint_least64_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define SCNxFAST8 "hx" /* uint_fast8_t */
|
|
|
|
#define SCNxFAST16 "hx" /* uint_fast16_t */
|
|
|
|
#define SCNxFAST32 "lx" /* uint_fast32_t */
|
2021-02-17 20:57:18 +00:00
|
|
|
#define SCNxFAST64 "llx" /* uint_fast64_t */
|
|
|
|
#define SCNxMAX "jx" /* uintmax_t */
|
2017-10-22 01:40:41 +00:00
|
|
|
#define SCNxPTR "lx" /* uintptr_t */
|
|
|
|
|
2021-02-17 20:57:18 +00:00
|
|
|
#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
|
|
|
|
|
2017-10-22 01:40:41 +00:00
|
|
|
/*
|
2021-02-17 20:57:18 +00:00
|
|
|
* The C99 and C11 standards require the following functions
|
|
|
|
* to be declared here, but they are not currently supported.
|
2017-10-22 01:40:41 +00:00
|
|
|
*
|
2021-02-17 20:57:18 +00:00
|
|
|
* intmax_t wcstoimax(const wchar_t * restrict, wchar_t ** restrict, int);
|
|
|
|
* uintmax_t wcstoumax(const wchar_t * restrict, wchar_t ** restrict, int);
|
2017-10-22 01:40:41 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#endif
|