Bug 1357873 - Fix up 64-bit Android macros in IntegerPrintfMacros.h; r=Waldo

On 64-bit Android, the inttypes.h macros for [u]int_fastN_t types (e.g.
int_fast16_t) use "d", "u", etc. as the format specifier, but the types
themselves are defined as `long`, `unsigned long`, etc. This patch
redefines the macros as `PRId64`, `PRIu64`, etc. to provide correct
behavior.
This commit is contained in:
Jim Chen 2017-05-01 14:46:00 -04:00
parent 49768eb480
commit a1a22f23e5

View file

@ -49,4 +49,36 @@
# define PRIXPTR "X" /* uintptr_t */ # define PRIXPTR "X" /* uintptr_t */
#endif #endif
/*
* Fix up Android's broken macros for [u]int_fastN_t. On ARM64, Android's
* PRI*FAST16/32 macros are defined as "d", but the types themselves are defined
* as long and unsigned long.
*/
#if defined(ANDROID) && defined(__LP64__)
# undef PRIdFAST16 /* int_fast16_t */
# define PRIdFAST16 PRId64 /* int_fast16_t */
# undef PRIiFAST16 /* int_fast16_t */
# define PRIiFAST16 PRIi64 /* int_fast16_t */
# undef PRIoFAST16 /* uint_fast16_t */
# define PRIoFAST16 PRIo64 /* uint_fast16_t */
# undef PRIuFAST16 /* uint_fast16_t */
# define PRIuFAST16 PRIu64 /* uint_fast16_t */
# undef PRIxFAST16 /* uint_fast16_t */
# define PRIxFAST16 PRIx64 /* uint_fast16_t */
# undef PRIXFAST16 /* uint_fast16_t */
# define PRIXFAST16 PRIX64 /* uint_fast16_t */
# undef PRIdFAST32 /* int_fast32_t */
# define PRIdFAST32 PRId64 /* int_fast32_t */
# undef PRIiFAST32 /* int_fast32_t */
# define PRIiFAST32 PRIi64 /* int_fast32_t */
# undef PRIoFAST32 /* uint_fast32_t */
# define PRIoFAST32 PRIo64 /* uint_fast32_t */
# undef PRIuFAST32 /* uint_fast32_t */
# define PRIuFAST32 PRIu64 /* uint_fast32_t */
# undef PRIxFAST32 /* uint_fast32_t */
# define PRIxFAST32 PRIx64 /* uint_fast32_t */
# undef PRIXFAST32 /* uint_fast32_t */
# define PRIXFAST32 PRIX64 /* uint_fast32_t */
#endif
#endif /* mozilla_IntegerPrintfMacros_h_ */ #endif /* mozilla_IntegerPrintfMacros_h_ */