[PATCH 2/3] Use "standard" printf prefixes instead of MSVC ones in inttypes.h
Mike Hommey
mh+jemalloc at glandium.org
Wed May 2 12:30:52 PDT 2012
From: Mike Hommey <mh at glandium.org>
We don't use MSVC's printf, but ours, and it doesn't support the I32 and I64
prefixes.
---
include/msvc_compat/inttypes.h | 110 +++++++++++++++++++++-------------------
1 file changed, 59 insertions(+), 51 deletions(-)
diff --git a/include/msvc_compat/inttypes.h b/include/msvc_compat/inttypes.h
index 4b3828a..a4e6b75 100644
--- a/include/msvc_compat/inttypes.h
+++ b/include/msvc_compat/inttypes.h
@@ -53,6 +53,14 @@ typedef struct {
#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198
+#ifdef _WIN64
+# define __PRI64_PREFIX "l"
+# define __PRIPTR_PREFIX "l"
+#else
+# define __PRI64_PREFIX "ll"
+# define __PRIPTR_PREFIX
+#endif
+
// The fprintf macros for signed integers are:
#define PRId8 "d"
#define PRIi8 "i"
@@ -68,25 +76,25 @@ typedef struct {
#define PRIdFAST16 "hd"
#define PRIiFAST16 "hi"
-#define PRId32 "I32d"
-#define PRIi32 "I32i"
-#define PRIdLEAST32 "I32d"
-#define PRIiLEAST32 "I32i"
-#define PRIdFAST32 "I32d"
-#define PRIiFAST32 "I32i"
+#define PRId32 "d"
+#define PRIi32 "i"
+#define PRIdLEAST32 "d"
+#define PRIiLEAST32 "i"
+#define PRIdFAST32 "d"
+#define PRIiFAST32 "i"
-#define PRId64 "I64d"
-#define PRIi64 "I64i"
-#define PRIdLEAST64 "I64d"
-#define PRIiLEAST64 "I64i"
-#define PRIdFAST64 "I64d"
-#define PRIiFAST64 "I64i"
+#define PRId64 __PRI64_PREFIX "d"
+#define PRIi64 __PRI64_PREFIX "i"
+#define PRIdLEAST64 __PRI64_PREFIX "d"
+#define PRIiLEAST64 __PRI64_PREFIX "i"
+#define PRIdFAST64 __PRI64_PREFIX "d"
+#define PRIiFAST64 __PRI64_PREFIX "i"
-#define PRIdMAX "I64d"
-#define PRIiMAX "I64i"
+#define PRIdMAX __PRI64_PREFIX "d"
+#define PRIiMAX __PRI64_PREFIX "i"
-#define PRIdPTR "Id"
-#define PRIiPTR "Ii"
+#define PRIdPTR __PRIPTR_PREFIX "d"
+#define PRIiPTR __PRIPTR_PREFIX "i"
// The fprintf macros for unsigned integers are:
#define PRIo8 "o"
@@ -115,41 +123,41 @@ typedef struct {
#define PRIxFAST16 "hx"
#define PRIXFAST16 "hX"
-#define PRIo32 "I32o"
-#define PRIu32 "I32u"
-#define PRIx32 "I32x"
-#define PRIX32 "I32X"
-#define PRIoLEAST32 "I32o"
-#define PRIuLEAST32 "I32u"
-#define PRIxLEAST32 "I32x"
-#define PRIXLEAST32 "I32X"
-#define PRIoFAST32 "I32o"
-#define PRIuFAST32 "I32u"
-#define PRIxFAST32 "I32x"
-#define PRIXFAST32 "I32X"
-
-#define PRIo64 "I64o"
-#define PRIu64 "I64u"
-#define PRIx64 "I64x"
-#define PRIX64 "I64X"
-#define PRIoLEAST64 "I64o"
-#define PRIuLEAST64 "I64u"
-#define PRIxLEAST64 "I64x"
-#define PRIXLEAST64 "I64X"
-#define PRIoFAST64 "I64o"
-#define PRIuFAST64 "I64u"
-#define PRIxFAST64 "I64x"
-#define PRIXFAST64 "I64X"
-
-#define PRIoMAX "I64o"
-#define PRIuMAX "I64u"
-#define PRIxMAX "I64x"
-#define PRIXMAX "I64X"
-
-#define PRIoPTR "Io"
-#define PRIuPTR "Iu"
-#define PRIxPTR "Ix"
-#define PRIXPTR "IX"
+#define PRIo32 "o"
+#define PRIu32 "u"
+#define PRIx32 "x"
+#define PRIX32 "X"
+#define PRIoLEAST32 "o"
+#define PRIuLEAST32 "u"
+#define PRIxLEAST32 "x"
+#define PRIXLEAST32 "X"
+#define PRIoFAST32 "o"
+#define PRIuFAST32 "u"
+#define PRIxFAST32 "x"
+#define PRIXFAST32 "X"
+
+#define PRIo64 __PRI64_PREFIX "o"
+#define PRIu64 __PRI64_PREFIX "u"
+#define PRIx64 __PRI64_PREFIX "x"
+#define PRIX64 __PRI64_PREFIX "X"
+#define PRIoLEAST64 __PRI64_PREFIX "o"
+#define PRIuLEAST64 __PRI64_PREFIX "u"
+#define PRIxLEAST64 __PRI64_PREFIX "x"
+#define PRIXLEAST64 __PRI64_PREFIX "X"
+#define PRIoFAST64 __PRI64_PREFIX "o"
+#define PRIuFAST64 __PRI64_PREFIX "u"
+#define PRIxFAST64 __PRI64_PREFIX "x"
+#define PRIXFAST64 __PRI64_PREFIX "X"
+
+#define PRIoMAX __PRI64_PREFIX "o"
+#define PRIuMAX __PRI64_PREFIX "u"
+#define PRIxMAX __PRI64_PREFIX "x"
+#define PRIXMAX __PRI64_PREFIX "X"
+
+#define PRIoPTR __PRIPTR_PREFIX "o"
+#define PRIuPTR __PRIPTR_PREFIX "u"
+#define PRIxPTR __PRIPTR_PREFIX "x"
+#define PRIXPTR __PRIPTR_PREFIX "X"
// The fscanf macros for signed integers are:
#define SCNd8 "d"
--
1.7.10
More information about the jemalloc-discuss
mailing list