libc: minimal: Add PRIxMAX macros for [u]intmax_t

This commit adds the missing `PRIxMAX` macros for the C99 `intmax_t`
and `uintmax_t` types:

  PRIdMAX, PRIiMAX, PRIoMAX, PRIuMAX, PRIxMAX, PRIXMAX

Note that the `PRIxMAX` macros specify the `ll` size modifier because
the type of the `intmax_t` for the minimal libc is defined as that of
the `int64_t`, which is always overridden to `long long int` by
`zephyr_stdint.h`; for more details, refer to the GitHub PR #29876,
which deliberately introduced this scheme.

In the future, this scheme will need to be reworked such that the
minimal libc `stdint.h` defines `intmax_t` as `__INTMAX_TYPE__`, and
the `inttypes.h` resolves the corresponding format specifier.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit is contained in:
Stephanos Ioannidis 2022-05-26 16:41:02 +09:00 committed by Carles Cufí
commit d755050a14

View file

@ -22,6 +22,7 @@
#define PRIdLEAST16 "d" /* int_least16_t */
#define PRIdLEAST32 "d" /* int_least32_t */
#define PRIdLEAST64 "lld" /* int_least64_t */
#define PRIdMAX "lld" /* intmax_t */
#define PRIdPTR "ld" /* intptr_t */
#define PRIi8 "i" /* int8_t */
@ -36,6 +37,7 @@
#define PRIiLEAST16 "i" /* int_least16_t */
#define PRIiLEAST32 "i" /* int_least32_t */
#define PRIiLEAST64 "lli" /* int_least64_t */
#define PRIiMAX "lli" /* intmax_t */
#define PRIiPTR "li" /* intptr_t */
#define PRIo8 "o" /* int8_t */
@ -50,6 +52,7 @@
#define PRIoLEAST16 "o" /* int_least16_t */
#define PRIoLEAST32 "o" /* int_least32_t */
#define PRIoLEAST64 "llo" /* int_least64_t */
#define PRIoMAX "llo" /* intmax_t */
#define PRIoPTR "lo" /* intptr_t */
#define PRIu8 "u" /* uint8_t */
@ -64,6 +67,7 @@
#define PRIuLEAST16 "u" /* uint_least16_t */
#define PRIuLEAST32 "u" /* uint_least32_t */
#define PRIuLEAST64 "llu" /* uint_least64_t */
#define PRIuMAX "llu" /* uintmax_t */
#define PRIuPTR "lu" /* uintptr_t */
#define PRIx8 "x" /* uint8_t */
@ -78,6 +82,7 @@
#define PRIxLEAST16 "x" /* uint_least16_t */
#define PRIxLEAST32 "x" /* uint_least32_t */
#define PRIxLEAST64 "llx" /* uint_least64_t */
#define PRIxMAX "llx" /* uintmax_t */
#define PRIxPTR "lx" /* uintptr_t */
#define PRIX8 "X" /* uint8_t */
@ -92,6 +97,7 @@
#define PRIXLEAST16 "X" /* uint_least16_t */
#define PRIXLEAST32 "X" /* uint_least32_t */
#define PRIXLEAST64 "llX" /* uint_least64_t */
#define PRIXMAX "llX" /* uintmax_t */
#define PRIXPTR "lX" /* uintptr_t */
#endif