diff --git a/arch/risc-v/include/inttypes.h b/arch/risc-v/include/inttypes.h index b06bc9328b..f11bc42988 100644 --- a/arch/risc-v/include/inttypes.h +++ b/arch/risc-v/include/inttypes.h @@ -44,91 +44,107 @@ * Pre-processor Definitions ****************************************************************************/ +#if defined(__LP64__) +#define _PRI32PREFIX +#define _PRI64PREFIX "l" +#define _SCN32PREFIX +#define _SCN64PREFIX "l" +#define INT32_C(x) x +#define INT64_C(x) x ## l +#define UINT32_C(x) x ## u +#define UINT64_C(x) x ## ul +#else /* defined(__LP64__) */ +#define _PRI32PREFIX "l" +#define _PRI64PREFIX "ll" +#define _SCN32PREFIX "l" +#define _SCN64PREFIX "ll" +#define INT32_C(x) x ## l +#define INT64_C(x) x ## ll +#define UINT32_C(x) x ## ul +#define UINT64_C(x) x ## ull +#endif /* defined(__LP64__) */ + #define PRId8 "d" #define PRId16 "d" -#define PRId32 "d" -#define PRId64 "ld" +#define PRId32 _PRI32PREFIX "d" +#define PRId64 _PRI64PREFIX "d" #define PRIdPTR "d" #define PRIi8 "i" #define PRIi16 "i" -#define PRIi32 "i" -#define PRIi64 "li" +#define PRIi32 _PRI32PREFIX "i" +#define PRIi64 _PRI64PREFIX "i" #define PRIiPTR "i" #define PRIo8 "o" #define PRIo16 "o" -#define PRIo32 "o" -#define PRIo64 "lo" +#define PRIo32 _PRI32PREFIX "o" +#define PRIo64 _PRI64PREFIX "o" #define PRIoPTR "o" #define PRIu8 "u" #define PRIu16 "u" -#define PRIu32 "u" -#define PRIu64 "lu" +#define PRIu32 _PRI32PREFIX "u" +#define PRIu64 _PRI64PREFIX "u" #define PRIuPTR "u" #define PRIx8 "x" #define PRIx16 "x" -#define PRIx32 "x" -#define PRIx64 "lx" +#define PRIx32 _PRI32PREFIX "x" +#define PRIx64 _PRI64PREFIX "x" #define PRIxPTR "x" #define PRIX8 "X" #define PRIX16 "X" -#define PRIX32 "X" -#define PRIX64 "lX" +#define PRIX32 _PRI32PREFIX "X" +#define PRIX64 _PRI64PREFIX "X" #define PRIXPTR "X" #define SCNd8 "hhd" #define SCNd16 "hd" -#define SCNd32 "d" -#define SCNd64 "ld" +#define SCNd32 _SCN32PREFIX "d" +#define SCNd64 _SCN64PREFIX "d" #define SCNdPTR "d" #define SCNi8 "hhi" #define SCNi16 "hi" -#define SCNi32 "i" -#define SCNi64 "li" +#define SCNi32 _SCN32PREFIX "i" +#define SCNi64 _SCN64PREFIX "i" #define SCNiPTR "i" #define SCNo8 "hho" #define SCNo16 "ho" -#define SCNo32 "o" -#define SCNo64 "lo" +#define SCNo32 _SCN32PREFIX "o" +#define SCNo64 _SCN64PREFIX "o" #define SCNoPTR "o" #define SCNu8 "hhu" #define SCNu16 "hu" -#define SCNu32 "u" -#define SCNu64 "lu" +#define SCNu32 _SCN32PREFIX "u" +#define SCNu64 _SCN64PREFIX "u" #define SCNuPTR "u" #define SCNx8 "hhx" #define SCNx16 "hx" -#define SCNx32 "x" -#define SCNx64 "lx" +#define SCNx32 _SCN32PREFIX "x" +#define SCNx64 _SCN64PREFIX "x" #define SCNxPTR "x" #define INT8_C(x) x #define INT16_C(x) x -#define INT32_C(x) x -#define INT64_C(x) x ## l #define UINT8_C(x) x #define UINT16_C(x) x -#define UINT32_C(x) x ## u -#define UINT64_C(x) x ## ul #endif /* __ARCH_RISCV_INCLUDE_INTTYPES_H */ diff --git a/arch/risc-v/include/types.h b/arch/risc-v/include/types.h index 61e0320079..10984051d5 100644 --- a/arch/risc-v/include/types.h +++ b/arch/risc-v/include/types.h @@ -69,11 +69,19 @@ typedef unsigned char _uint8_t; typedef signed short _int16_t; typedef unsigned short _uint16_t; +#ifdef __LP64__ typedef signed int _int32_t; typedef unsigned int _uint32_t; typedef signed long _int64_t; typedef unsigned long _uint64_t; +#else /* __LP64__ */ +typedef signed long _int32_t; +typedef unsigned long _uint32_t; + +typedef signed long long _int64_t; +typedef unsigned long long _uint64_t; +#endif /* __LP64__ */ #define __INT64_DEFINED #ifdef __LP64__