changeset 2115:bf78122e49b4

. Use standard C99 printf formats rather than rolling our own where it makes sense.
author Greg Lewis <glewis@eyesbeyond.com>
date Thu, 27 Jan 2011 22:31:08 -0800
parents 90ade3e5c802
children d9307d0594c8
files src/os/bsd/vm/os_bsd.cpp src/os/linux/vm/os_linux.cpp src/share/vm/utilities/globalDefinitions.hpp
diffstat 3 files changed, 14 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/os/bsd/vm/os_bsd.cpp	Thu Jan 27 22:29:46 2011 -0800
+++ b/src/os/bsd/vm/os_bsd.cpp	Thu Jan 27 22:31:08 2011 -0800
@@ -22,8 +22,6 @@
  *
  */
 
-# define __STDC_FORMAT_MACROS
-
 // no precompiled headers
 #include "classfile/classLoader.hpp"
 #include "classfile/systemDictionary.hpp"
--- a/src/os/linux/vm/os_linux.cpp	Thu Jan 27 22:29:46 2011 -0800
+++ b/src/os/linux/vm/os_linux.cpp	Thu Jan 27 22:31:08 2011 -0800
@@ -22,8 +22,6 @@
  *
  */
 
-# define __STDC_FORMAT_MACROS
-
 // no precompiled headers
 #include "classfile/classLoader.hpp"
 #include "classfile/systemDictionary.hpp"
--- a/src/share/vm/utilities/globalDefinitions.hpp	Thu Jan 27 22:29:46 2011 -0800
+++ b/src/share/vm/utilities/globalDefinitions.hpp	Thu Jan 27 22:31:08 2011 -0800
@@ -37,6 +37,9 @@
 
 #include "utilities/macros.hpp"
 
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
+
 // This file holds all globally used constants & types, class (forward)
 // declarations and a few frequently used utility functions.
 
@@ -1180,20 +1183,20 @@
 // (in ILP32).
 
 // Format 32-bit quantities.
-#define INT32_FORMAT  "%d"
-#define UINT32_FORMAT "%u"
+#define INT32_FORMAT  "%" PRId32
+#define UINT32_FORMAT "%" PRIu32
 #define INT32_FORMAT_W(width)   "%" #width "d"
 #define UINT32_FORMAT_W(width)  "%" #width "u"
 
-#define PTR32_FORMAT  "0x%08x"
+#define PTR32_FORMAT  "0x%08" PRIx32
 
 // Format 64-bit quantities.
-#define INT64_FORMAT  "%" FORMAT64_MODIFIER "d"
-#define UINT64_FORMAT "%" FORMAT64_MODIFIER "u"
-#define PTR64_FORMAT  "0x%016" FORMAT64_MODIFIER "x"
+#define INT64_FORMAT  "%" PRId64
+#define UINT64_FORMAT "%" PRIu64
+#define PTR64_FORMAT  "0x%016" PRIx64
 
-#define INT64_FORMAT_W(width)  "%" #width FORMAT64_MODIFIER "d"
-#define UINT64_FORMAT_W(width) "%" #width FORMAT64_MODIFIER "u"
+#define INT64_FORMAT_W(width)  "%" #width PRId64
+#define UINT64_FORMAT_W(width) "%" #width PRIu64
 
 // Format macros that allow the field width to be specified.  The width must be
 // a string literal (e.g., "8") or a macro that evaluates to one.
@@ -1218,19 +1221,17 @@
 // using "%x".
 #ifdef  _LP64
 #define PTR_FORMAT    PTR64_FORMAT
-#define UINTX_FORMAT  UINT64_FORMAT
-#define INTX_FORMAT   INT64_FORMAT
 #define SIZE_FORMAT   UINT64_FORMAT
 #define SSIZE_FORMAT  INT64_FORMAT
 #else   // !_LP64
 #define PTR_FORMAT    PTR32_FORMAT
-#define UINTX_FORMAT  UINT32_FORMAT
-#define INTX_FORMAT   INT32_FORMAT
 #define SIZE_FORMAT   UINT32_FORMAT
 #define SSIZE_FORMAT  INT32_FORMAT
 #endif  // _LP64
+#define UINTX_FORMAT  "%" PRIuPTR
+#define INTX_FORMAT   "%" PRIdPTR
 
-#define INTPTR_FORMAT PTR_FORMAT
+#define INTPTR_FORMAT "%" PRIdPTR
 
 // Enable zap-a-lot if in debug version.