Skip to content

Commit

Permalink
libc: minimal: Add PRIx{FAST,LEAST}N macros
Browse files Browse the repository at this point in the history
This commit adds the missing `PRIx{FAST,LEAST}N` C99 integer type
format macros that correspond to the C99 integer types overridden in
the `zephyr_stdint.h` header:

  PRIdFAST8, PRIdFAST16, PRIdFAST32, PRIdFAST64
  PRIdLEAST8, PRIdLEAST16, PRIdLEAST32, PRIdLEAST64

  PRIiFAST8, PRIiFAST16, PRIiFAST32, PRIiFAST64
  PRIiLEAST8, PRIiLEAST16, PRIiLEAST32, PRIiLEAST64

  PRIoFAST8, PRIoFAST16, PRIoFAST32, PRIoFAST64
  PRIoLEAST8, PRIoLEAST16, PRIoLEAST32, PRIoLEAST64

  PRIuFAST8, PRIuFAST16, PRIuFAST32, PRIuFAST64
  PRIuLEAST8, PRIuLEAST16, PRIuLEAST32, PRIuLEAST64

  PRIxFAST8, PRIxFAST16, PRIxFAST32, PRIxFAST64
  PRIxLEAST8, PRIxLEAST16, PRIxLEAST32, PRIxLEAST64

  PRIXFAST8, PRIXFAST16, PRIXFAST32, PRIXFAST64
  PRIXLEAST8, PRIXLEAST16, PRIXLEAST32, PRIXLEAST64

Note that these macros will eventually need to be defined according to
the toolchain-specified types when the `zephyr_stdint.h` hack is
removed in the future; refer to the the GitHub issue zephyrproject-rtos#46032 for more
details.

Signed-off-by: Stephanos Ioannidis <[email protected]>
  • Loading branch information
stephanosio authored and carlescufi committed May 26, 2022
1 parent 51b30a5 commit c3f80aa
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions lib/libc/minimal/include/inttypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,84 @@
#define PRId16 "d" /* int16_t */
#define PRId32 "d" /* int32_t */
#define PRId64 "lld" /* int64_t */
#define PRIdFAST8 "d" /* int_fast8_t */
#define PRIdFAST16 "d" /* int_fast16_t */
#define PRIdFAST32 "d" /* int_fast32_t */
#define PRIdFAST64 "lld" /* int_fast64_t */
#define PRIdLEAST8 "d" /* int_least8_t */
#define PRIdLEAST16 "d" /* int_least16_t */
#define PRIdLEAST32 "d" /* int_least32_t */
#define PRIdLEAST64 "lld" /* int_least64_t */
#define PRIdPTR "ld" /* intptr_t */

#define PRIi8 "i" /* int8_t */
#define PRIi16 "i" /* int16_t */
#define PRIi32 "i" /* int32_t */
#define PRIi64 "lli" /* int64_t */
#define PRIiFAST8 "i" /* int_fast8_t */
#define PRIiFAST16 "i" /* int_fast16_t */
#define PRIiFAST32 "i" /* int_fast32_t */
#define PRIiFAST64 "lli" /* int_fast64_t */
#define PRIiLEAST8 "i" /* int_least8_t */
#define PRIiLEAST16 "i" /* int_least16_t */
#define PRIiLEAST32 "i" /* int_least32_t */
#define PRIiLEAST64 "lli" /* int_least64_t */
#define PRIiPTR "li" /* intptr_t */

#define PRIo8 "o" /* int8_t */
#define PRIo16 "o" /* int16_t */
#define PRIo32 "o" /* int32_t */
#define PRIo64 "llo" /* int64_t */
#define PRIoFAST8 "o" /* int_fast8_t */
#define PRIoFAST16 "o" /* int_fast16_t */
#define PRIoFAST32 "o" /* int_fast32_t */
#define PRIoFAST64 "llo" /* int_fast64_t */
#define PRIoLEAST8 "o" /* int_least8_t */
#define PRIoLEAST16 "o" /* int_least16_t */
#define PRIoLEAST32 "o" /* int_least32_t */
#define PRIoLEAST64 "llo" /* int_least64_t */
#define PRIoPTR "lo" /* intptr_t */

#define PRIu8 "u" /* uint8_t */
#define PRIu16 "u" /* uint16_t */
#define PRIu32 "u" /* uint32_t */
#define PRIu64 "llu" /* uint64_t */
#define PRIuFAST8 "u" /* uint_fast8_t */
#define PRIuFAST16 "u" /* uint_fast16_t */
#define PRIuFAST32 "u" /* uint_fast32_t */
#define PRIuFAST64 "llu" /* uint_fast64_t */
#define PRIuLEAST8 "u" /* uint_least8_t */
#define PRIuLEAST16 "u" /* uint_least16_t */
#define PRIuLEAST32 "u" /* uint_least32_t */
#define PRIuLEAST64 "llu" /* uint_least64_t */
#define PRIuPTR "lu" /* uintptr_t */

#define PRIx8 "x" /* uint8_t */
#define PRIx16 "x" /* uint16_t */
#define PRIx32 "x" /* uint32_t */
#define PRIx64 "llx" /* uint64_t */
#define PRIxFAST8 "x" /* uint_fast8_t */
#define PRIxFAST16 "x" /* uint_fast16_t */
#define PRIxFAST32 "x" /* uint_fast32_t */
#define PRIxFAST64 "llx" /* uint_fast64_t */
#define PRIxLEAST8 "x" /* uint_least8_t */
#define PRIxLEAST16 "x" /* uint_least16_t */
#define PRIxLEAST32 "x" /* uint_least32_t */
#define PRIxLEAST64 "llx" /* uint_least64_t */
#define PRIxPTR "lx" /* uintptr_t */

#define PRIX8 "X" /* uint8_t */
#define PRIX16 "X" /* uint16_t */
#define PRIX32 "X" /* uint32_t */
#define PRIX64 "llX" /* uint64_t */
#define PRIXFAST8 "X" /* uint_fast8_t */
#define PRIXFAST16 "X" /* uint_fast16_t */
#define PRIXFAST32 "X" /* uint_fast32_t */
#define PRIXFAST64 "llX" /* uint_fast64_t */
#define PRIXLEAST8 "X" /* uint_least8_t */
#define PRIXLEAST16 "X" /* uint_least16_t */
#define PRIXLEAST32 "X" /* uint_least32_t */
#define PRIXLEAST64 "llX" /* uint_least64_t */
#define PRIXPTR "lX" /* uintptr_t */

#endif

0 comments on commit c3f80aa

Please sign in to comment.