comparison src/share/vm/utilities/globalDefinitions.hpp @ 4137:04b9a2566eec

Merge with hsx23/hotspot.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sat, 17 Dec 2011 21:40:27 +0100
parents 0654ee04b214 436b4a3231bf
children 33df1aeaebbf
comparison
equal deleted inserted replaced
3737:9dc19b7d89a3 4137:04b9a2566eec
22 * 22 *
23 */ 23 */
24 24
25 #ifndef SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP 25 #ifndef SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP
26 #define SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP 26 #define SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP
27
28 #ifndef __STDC_FORMAT_MACROS
29 #define __STDC_FORMAT_MACROS
30 #endif
27 31
28 #ifdef TARGET_COMPILER_gcc 32 #ifdef TARGET_COMPILER_gcc
29 # include "utilities/globalDefinitions_gcc.hpp" 33 # include "utilities/globalDefinitions_gcc.hpp"
30 #endif 34 #endif
31 #ifdef TARGET_COMPILER_visCPP 35 #ifdef TARGET_COMPILER_visCPP
1176 inline int build_int_from_shorts( jushort low, jushort high ) { 1180 inline int build_int_from_shorts( jushort low, jushort high ) {
1177 return ((int)((unsigned int)high << 16) | (unsigned int)low); 1181 return ((int)((unsigned int)high << 16) | (unsigned int)low);
1178 } 1182 }
1179 1183
1180 // Printf-style formatters for fixed- and variable-width types as pointers and 1184 // Printf-style formatters for fixed- and variable-width types as pointers and
1181 // integers. 1185 // integers. These are derived from the definitions in inttypes.h. If the platform
1182 // 1186 // doesn't provide appropriate definitions, they should be provided in
1183 // Each compiler-specific definitions file (e.g., globalDefinitions_gcc.hpp) 1187 // the compiler-specific definitions file (e.g., globalDefinitions_gcc.hpp)
1184 // must define the macro FORMAT64_MODIFIER, which is the modifier for '%x' or
1185 // '%d' formats to indicate a 64-bit quantity; commonly "l" (in LP64) or "ll"
1186 // (in ILP32).
1187 1188
1188 #define BOOL_TO_STR(_b_) ((_b_) ? "true" : "false") 1189 #define BOOL_TO_STR(_b_) ((_b_) ? "true" : "false")
1189 1190
1190 // Format 32-bit quantities. 1191 // Format 32-bit quantities.
1191 #define INT32_FORMAT "%d" 1192 #define INT32_FORMAT "%" PRId32
1192 #define UINT32_FORMAT "%u" 1193 #define UINT32_FORMAT "%" PRIu32
1193 #define INT32_FORMAT_W(width) "%" #width "d" 1194 #define INT32_FORMAT_W(width) "%" #width PRId32
1194 #define UINT32_FORMAT_W(width) "%" #width "u" 1195 #define UINT32_FORMAT_W(width) "%" #width PRIu32
1195 1196
1196 #define PTR32_FORMAT "0x%08x" 1197 #define PTR32_FORMAT "0x%08" PRIx32
1197 1198
1198 // Format 64-bit quantities. 1199 // Format 64-bit quantities.
1199 #define INT64_FORMAT "%" FORMAT64_MODIFIER "d" 1200 #define INT64_FORMAT "%" PRId64
1200 #define UINT64_FORMAT "%" FORMAT64_MODIFIER "u" 1201 #define UINT64_FORMAT "%" PRIu64
1201 #define PTR64_FORMAT "0x%016" FORMAT64_MODIFIER "x" 1202 #define INT64_FORMAT_W(width) "%" #width PRId64
1202 1203 #define UINT64_FORMAT_W(width) "%" #width PRIu64
1203 #define INT64_FORMAT_W(width) "%" #width FORMAT64_MODIFIER "d" 1204
1204 #define UINT64_FORMAT_W(width) "%" #width FORMAT64_MODIFIER "u" 1205 #define PTR64_FORMAT "0x%016" PRIx64
1205 1206
1206 // Format macros that allow the field width to be specified. The width must be 1207 // Format pointers which change size between 32- and 64-bit.
1207 // a string literal (e.g., "8") or a macro that evaluates to one.
1208 #ifdef _LP64
1209 #define UINTX_FORMAT_W(width) UINT64_FORMAT_W(width)
1210 #define SSIZE_FORMAT_W(width) INT64_FORMAT_W(width)
1211 #define SIZE_FORMAT_W(width) UINT64_FORMAT_W(width)
1212 #else
1213 #define UINTX_FORMAT_W(width) UINT32_FORMAT_W(width)
1214 #define SSIZE_FORMAT_W(width) INT32_FORMAT_W(width)
1215 #define SIZE_FORMAT_W(width) UINT32_FORMAT_W(width)
1216 #endif // _LP64
1217
1218 // Format pointers and size_t (or size_t-like integer types) which change size
1219 // between 32- and 64-bit. The pointer format theoretically should be "%p",
1220 // however, it has different output on different platforms. On Windows, the data
1221 // will be padded with zeros automatically. On Solaris, we can use "%016p" &
1222 // "%08p" on 64 bit & 32 bit platforms to make the data padded with extra zeros.
1223 // On Linux, "%016p" or "%08p" is not be allowed, at least on the latest GCC
1224 // 4.3.2. So we have to use "%016x" or "%08x" to simulate the printing format.
1225 // GCC 4.3.2, however requires the data to be converted to "intptr_t" when
1226 // using "%x".
1227 #ifdef _LP64 1208 #ifdef _LP64
1228 #define PTR_FORMAT PTR64_FORMAT 1209 #define INTPTR_FORMAT "0x%016" PRIxPTR
1229 #define UINTX_FORMAT UINT64_FORMAT 1210 #define PTR_FORMAT "0x%016" PRIxPTR
1230 #define INTX_FORMAT INT64_FORMAT
1231 #define SIZE_FORMAT UINT64_FORMAT
1232 #define SSIZE_FORMAT INT64_FORMAT
1233 #else // !_LP64 1211 #else // !_LP64
1234 #define PTR_FORMAT PTR32_FORMAT 1212 #define INTPTR_FORMAT "0x%08" PRIxPTR
1235 #define UINTX_FORMAT UINT32_FORMAT 1213 #define PTR_FORMAT "0x%08" PRIxPTR
1236 #define INTX_FORMAT INT32_FORMAT
1237 #define SIZE_FORMAT UINT32_FORMAT
1238 #define SSIZE_FORMAT INT32_FORMAT
1239 #endif // _LP64 1214 #endif // _LP64
1240 1215
1241 #define INTPTR_FORMAT PTR_FORMAT 1216 #define SSIZE_FORMAT "%" PRIdPTR
1217 #define SIZE_FORMAT "%" PRIuPTR
1218 #define SSIZE_FORMAT_W(width) "%" #width PRIdPTR
1219 #define SIZE_FORMAT_W(width) "%" #width PRIuPTR
1220
1221 #define INTX_FORMAT "%" PRIdPTR
1222 #define UINTX_FORMAT "%" PRIuPTR
1223 #define INTX_FORMAT_W(width) "%" #width PRIdPTR
1224 #define UINTX_FORMAT_W(width) "%" #width PRIuPTR
1225
1242 1226
1243 // Enable zap-a-lot if in debug version. 1227 // Enable zap-a-lot if in debug version.
1244 1228
1245 # ifdef ASSERT 1229 # ifdef ASSERT
1246 # ifdef COMPILER2 1230 # ifdef COMPILER2