Skip to content

Commit ddb5881

Browse files
committed
8329549: Remove FORMAT64_MODIFIER
Reviewed-by: dholmes, kbarrett
1 parent 098afc8 commit ddb5881

File tree

5 files changed

+12
-21
lines changed

5 files changed

+12
-21
lines changed

src/hotspot/share/runtime/os.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -971,7 +971,7 @@ static void print_hex_location(outputStream* st, const_address p, int unitsize,
971971
const uint64_t value =
972972
LITTLE_ENDIAN_ONLY((((uint64_t)i2) << 32) | i1)
973973
BIG_ENDIAN_ONLY((((uint64_t)i1) << 32) | i2);
974-
st->print("%016" FORMAT64_MODIFIER "x", value);
974+
st->print(UINT64_FORMAT_0, value);
975975
print_ascii_form(ascii_form, value, unitsize);
976976
} else {
977977
st->print_raw("????????????????");
@@ -995,7 +995,7 @@ static void print_hex_location(outputStream* st, const_address p, int unitsize,
995995
case 1: st->print("%02x", (u1)value); break;
996996
case 2: st->print("%04x", (u2)value); break;
997997
case 4: st->print("%08x", (u4)value); break;
998-
case 8: st->print("%016" FORMAT64_MODIFIER "x", (u8)value); break;
998+
case 8: st->print(UINT64_FORMAT_0, (u8)value); break;
999999
}
10001000
print_ascii_form(ascii_form, value, unitsize);
10011001
} else {

src/hotspot/share/utilities/globalDefinitions.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -99,6 +99,7 @@ class oopDesc;
9999
// _X_0 - print as hexadecimal, with leading 0s: 0x00012345
100100
// _W(w) - prints w sized string with the given value right
101101
// adjusted. Use -w to print left adjusted.
102+
// _0 - print as hexadecimal, with leading 0s, without 0x prefix: 0012345
102103
//
103104
// Note that the PTR format specifiers print using 0x with leading zeros,
104105
// just like the _X_0 version for integers.
@@ -131,6 +132,7 @@ class oopDesc;
131132
#define UINT64_FORMAT_X "0x%" PRIx64
132133
#define UINT64_FORMAT_X_0 "0x%016" PRIx64
133134
#define UINT64_FORMAT_W(width) "%" #width PRIu64
135+
#define UINT64_FORMAT_0 "%016" PRIx64
134136

135137
// Format integers which change size between 32- and 64-bit.
136138
#define SSIZE_FORMAT "%" PRIdPTR

src/hotspot/share/utilities/globalDefinitions_gcc.hpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -90,17 +90,6 @@ inline int g_isfinite(jfloat f) { return isfinite(f); }
9090
inline int g_isfinite(jdouble f) { return isfinite(f); }
9191

9292

93-
// Formatting.
94-
#ifdef _LP64
95-
# ifdef __APPLE__
96-
# define FORMAT64_MODIFIER "ll"
97-
# else
98-
# define FORMAT64_MODIFIER "l"
99-
# endif
100-
#else // !_LP64
101-
#define FORMAT64_MODIFIER "ll"
102-
#endif // _LP64
103-
10493
// gcc warns about applying offsetof() to non-POD object or calculating
10594
// offset directly when base address is null. The -Wno-invalid-offsetof
10695
// option could be used to suppress this warning, but we instead just

src/hotspot/share/utilities/globalDefinitions_visCPP.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -103,9 +103,6 @@ inline int g_isnan(jdouble f) { return _isnan(f); }
103103
inline int g_isfinite(jfloat f) { return _finite(f); }
104104
inline int g_isfinite(jdouble f) { return _finite(f); }
105105

106-
// Formatting.
107-
#define FORMAT64_MODIFIER "ll"
108-
109106
#define offset_of(klass,field) offsetof(klass,field)
110107

111108
#define THREAD_LOCAL __declspec(thread)

test/hotspot/gtest/utilities/test_globalDefinitions.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -289,4 +289,7 @@ TEST(globalDefinitions, format_specifiers) {
289289

290290
check_format(INTPTR_FORMAT, (intptr_t)0x123, "0x" LP64_ONLY("00000000") "00000123");
291291
check_format(PTR_FORMAT, (uintptr_t)0x123, "0x" LP64_ONLY("00000000") "00000123");
292+
293+
// Check all platforms print this compatibly without leading 0x.
294+
check_format(UINT64_FORMAT_0, (u8)0x123, "0000000000000123");
292295
}

0 commit comments

Comments
 (0)