Skip to content

Commit 9d59a04

Browse files
committed
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 zephyrproject-rtos#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 <[email protected]>
1 parent 7e351af commit 9d59a04

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: lib/libc/minimal/include/inttypes.h

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#define PRIdLEAST16 "d" /* int_least16_t */
2323
#define PRIdLEAST32 "d" /* int_least32_t */
2424
#define PRIdLEAST64 "lld" /* int_least64_t */
25+
#define PRIdMAX "lld" /* intmax_t */
2526
#define PRIdPTR "ld" /* intptr_t */
2627

2728
#define PRIi8 "i" /* int8_t */
@@ -36,6 +37,7 @@
3637
#define PRIiLEAST16 "i" /* int_least16_t */
3738
#define PRIiLEAST32 "i" /* int_least32_t */
3839
#define PRIiLEAST64 "lli" /* int_least64_t */
40+
#define PRIiMAX "lli" /* intmax_t */
3941
#define PRIiPTR "li" /* intptr_t */
4042

4143
#define PRIo8 "o" /* int8_t */
@@ -50,6 +52,7 @@
5052
#define PRIoLEAST16 "o" /* int_least16_t */
5153
#define PRIoLEAST32 "o" /* int_least32_t */
5254
#define PRIoLEAST64 "llo" /* int_least64_t */
55+
#define PRIoMAX "llo" /* intmax_t */
5356
#define PRIoPTR "lo" /* intptr_t */
5457

5558
#define PRIu8 "u" /* uint8_t */
@@ -64,6 +67,7 @@
6467
#define PRIuLEAST16 "u" /* uint_least16_t */
6568
#define PRIuLEAST32 "u" /* uint_least32_t */
6669
#define PRIuLEAST64 "llu" /* uint_least64_t */
70+
#define PRIuMAX "llu" /* uintmax_t */
6771
#define PRIuPTR "lu" /* uintptr_t */
6872

6973
#define PRIx8 "x" /* uint8_t */
@@ -78,6 +82,7 @@
7882
#define PRIxLEAST16 "x" /* uint_least16_t */
7983
#define PRIxLEAST32 "x" /* uint_least32_t */
8084
#define PRIxLEAST64 "llx" /* uint_least64_t */
85+
#define PRIxMAX "llx" /* uintmax_t */
8186
#define PRIxPTR "lx" /* uintptr_t */
8287

8388
#define PRIX8 "X" /* uint8_t */
@@ -92,6 +97,7 @@
9297
#define PRIXLEAST16 "X" /* uint_least16_t */
9398
#define PRIXLEAST32 "X" /* uint_least32_t */
9499
#define PRIXLEAST64 "llX" /* uint_least64_t */
100+
#define PRIXMAX "llX" /* uintmax_t */
95101
#define PRIXPTR "lX" /* uintptr_t */
96102

97103
#endif

0 commit comments

Comments
 (0)