Skip to content

Commit 4a9fba6

Browse files
committed
8347990: Remove SIZE_FORMAT macros and replace remaining uses
Reviewed-by: dholmes, kbarrett
1 parent c33c1cf commit 4a9fba6

25 files changed

+57
-63
lines changed

src/hotspot/share/memory/metaspace.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void MetaspaceUtils::print_on(outputStream* out) {
216216
// Used from all GCs. It first prints out totals, then, separately, the class space portion.
217217
MetaspaceCombinedStats stats = get_combined_statistics();
218218
out->print_cr(" Metaspace "
219-
"used " SIZE_FORMAT "K, "
219+
"used %zuK, "
220220
"committed %zuK, "
221221
"reserved %zuK",
222222
stats.used()/K,
@@ -225,7 +225,7 @@ void MetaspaceUtils::print_on(outputStream* out) {
225225

226226
if (Metaspace::using_class_space()) {
227227
out->print_cr(" class space "
228-
"used " SIZE_FORMAT "K, "
228+
"used %zuK, "
229229
"committed %zuK, "
230230
"reserved %zuK",
231231
stats.class_space_stats().used()/K,
@@ -565,7 +565,7 @@ void Metaspace::initialize_class_space(ReservedSpace rs) {
565565
"%zu != %zu", rs.size(), CompressedClassSpaceSize);
566566
assert(using_class_space(), "Must be using class space");
567567

568-
assert(rs.size() == CompressedClassSpaceSize, SIZE_FORMAT " != %zu",
568+
assert(rs.size() == CompressedClassSpaceSize, "%zu != %zu",
569569
rs.size(), CompressedClassSpaceSize);
570570
assert(is_aligned(rs.base(), Metaspace::reserve_alignment()) &&
571571
is_aligned(rs.size(), Metaspace::reserve_alignment()),

src/hotspot/share/utilities/globalDefinitions.hpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,6 @@ class oopDesc;
134134
#define UINT64_FORMAT_W(width) "%" #width PRIu64
135135
#define UINT64_FORMAT_0 "%016" PRIx64
136136

137-
138-
// Format integers which change size between 32- and 64-bit.
139-
#define SIZE_FORMAT "%" PRIuPTR
140-
#define SIZE_FORMAT_X "0x%" PRIxPTR
141-
#define SIZE_FORMAT_W(width) "%" #width PRIuPTR
142-
143137
// Format jlong, if necessary
144138
#ifndef JLONG_FORMAT
145139
#define JLONG_FORMAT INT64_FORMAT
@@ -373,15 +367,15 @@ inline T byte_size_in_proper_unit(T s) {
373367
}
374368
}
375369

376-
#define PROPERFMT SIZE_FORMAT "%s"
370+
#define PROPERFMT "%zu%s"
377371
#define PROPERFMTARGS(s) byte_size_in_proper_unit(s), proper_unit_for_byte_size(s)
378372

379373
// Printing a range, with start and bytes given
380-
#define RANGEFMT "[" PTR_FORMAT " - " PTR_FORMAT "), (" SIZE_FORMAT " bytes)"
374+
#define RANGEFMT "[" PTR_FORMAT " - " PTR_FORMAT "), (%zu bytes)"
381375
#define RANGEFMTARGS(p1, size) p2i(p1), p2i(p1 + size), size
382376

383377
// Printing a range, with start and end given
384-
#define RANGE2FMT "[" PTR_FORMAT " - " PTR_FORMAT "), (" SIZE_FORMAT " bytes)"
378+
#define RANGE2FMT "[" PTR_FORMAT " - " PTR_FORMAT "), (%zu bytes)"
385379
#define RANGE2FMTARGS(p1, p2) p2i(p1), p2i(p2), ((uintptr_t)p2 - (uintptr_t)p1)
386380

387381
inline const char* exact_unit_for_byte_size(size_t s) {
@@ -414,12 +408,12 @@ inline size_t byte_size_in_exact_unit(size_t s) {
414408
return s;
415409
}
416410

417-
#define EXACTFMT SIZE_FORMAT "%s"
411+
#define EXACTFMT "%zu%s"
418412
#define EXACTFMTARGS(s) byte_size_in_exact_unit(s), exact_unit_for_byte_size(s)
419413

420414
// Memory size transition formatting.
421415

422-
#define HEAP_CHANGE_FORMAT "%s: " SIZE_FORMAT "K(" SIZE_FORMAT "K)->" SIZE_FORMAT "K(" SIZE_FORMAT "K)"
416+
#define HEAP_CHANGE_FORMAT "%s: %zuK(%zuK)->%zuK(%zuK)"
423417

424418
#define HEAP_CHANGE_FORMAT_ARGS(_name_, _prev_used_, _prev_capacity_, _used_, _capacity_) \
425419
(_name_), (_prev_used_) / K, (_prev_capacity_) / K, (_used_) / K, (_capacity_) / K

test/hotspot/gtest/gc/g1/test_g1FreeIdSet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class TestG1FreeIdSetThread : public JavaTestThread {
112112
++_allocations;
113113
ThreadBlockInVM tbiv(this); // Safepoint check.
114114
}
115-
tty->print_cr("%u allocations: " SIZE_FORMAT, _thread_number, _allocations);
115+
tty->print_cr("%u allocations: %zu", _thread_number, _allocations);
116116
Atomic::add(_total_allocations, _allocations);
117117
}
118118
};
@@ -150,7 +150,7 @@ TEST_VM(G1FreeIdSetTest, stress) {
150150
ThreadInVMfromNative invm(this_thread);
151151
post.wait_with_safepoint_check(this_thread);
152152
}
153-
tty->print_cr("total allocations: " SIZE_FORMAT, total_allocations);
153+
tty->print_cr("total allocations: %zu", total_allocations);
154154
tty->print_cr("final free list: ");
155155
uint ids[size] = {};
156156
for (uint i = 0; i < size; ++i) {

test/hotspot/gtest/gc/shared/test_bufferNodeAllocator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class BufferNode::TestSupport::AllocatorThread : public JavaTestThread {
141141
++_allocations;
142142
ThreadBlockInVM tbiv(this); // Safepoint check.
143143
}
144-
tty->print_cr("allocations: " SIZE_FORMAT, _allocations);
144+
tty->print_cr("allocations: %zu", _allocations);
145145
Atomic::add(_total_allocations, _allocations);
146146
}
147147
};
@@ -233,8 +233,8 @@ static void run_test(BufferNode::Allocator* allocator, CompletedList* cbl) {
233233
post.wait_with_safepoint_check(this_thread);
234234
}
235235
ASSERT_TRUE(BufferNode::TestSupport::try_transfer_pending(allocator));
236-
tty->print_cr("total allocations: " SIZE_FORMAT, total_allocations);
237-
tty->print_cr("allocator free count: " SIZE_FORMAT, allocator->free_count());
236+
tty->print_cr("total allocations: %zu", total_allocations);
237+
tty->print_cr("allocator free count: %zu", allocator->free_count());
238238
}
239239

240240
TEST_VM(BufferNodeAllocatorTest, stress_free_list_allocator) {

test/hotspot/gtest/gc/shared/test_oopStorage.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,9 +1135,9 @@ TEST_VM_F(OopStorageTestWithAllocation, print_storage) {
11351135
{
11361136
ResourceMark rm;
11371137
stringStream expected_st;
1138-
expected_st.print("Test Storage: " SIZE_FORMAT
1139-
" entries in " SIZE_FORMAT
1140-
" blocks (%.F%%), " SIZE_FORMAT " bytes",
1138+
expected_st.print("Test Storage: %zu"
1139+
" entries in %zu"
1140+
" blocks (%.F%%), %zu bytes",
11411141
expected_entries,
11421142
expected_blocks,
11431143
expected_usage,

test/hotspot/gtest/gc/shared/test_workerDataArray.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ const char* WorkerDataArrayTest<size_t>::format_summary(
8888
size_t min, double avg, size_t max, size_t diff, size_t sum, size_t workers) {
8989

9090
stringStream out;
91-
out.print(" Min: " SIZE_FORMAT
92-
", Avg: %4.1lf, Max: " SIZE_FORMAT
93-
", Diff: " SIZE_FORMAT ", Sum: " SIZE_FORMAT
94-
", Workers: " SIZE_FORMAT "\n",
91+
out.print(" Min: %zu"
92+
", Avg: %4.1lf, Max: %zu"
93+
", Diff: %zu, Sum: %zu"
94+
", Workers: %zu\n",
9595
min, avg, max, diff, sum, workers);
9696
return out.as_string();
9797
}
@@ -104,7 +104,7 @@ const char* WorkerDataArrayTest<double>::format_summary(
104104
out.print(" Min: %4.2lf"
105105
", Avg: %4.2lf, Max: %4.2lf"
106106
", Diff: %4.2lf, Sum: %4.2lf"
107-
", Workers: " SIZE_FORMAT "\n",
107+
", Workers: %zu\n",
108108
min, avg, max, diff, sum, workers);
109109
return out.as_string();
110110
}

test/hotspot/gtest/logging/test_logFileOutput.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ TEST_VM(LogFileOutput, parse_invalid) {
8989
// Test for overflows with filesize
9090
TEST_VM(LogFileOutput, filesize_overflow) {
9191
char buf[256];
92-
int ret = jio_snprintf(buf, sizeof(buf), "filesize=" SIZE_FORMAT "K", SIZE_MAX);
92+
int ret = jio_snprintf(buf, sizeof(buf), "filesize=%zuK", SIZE_MAX);
9393
ASSERT_GT(ret, 0) << "Buffer too small";
9494

9595
ResourceMark rm;
@@ -107,7 +107,7 @@ TEST_VM(LogFileOutput, startup_rotation) {
107107
for (size_t i = 0; i < rotations; i++) {
108108
size_t len = strlen(filename) + 3;
109109
rotated_file[i] = NEW_RESOURCE_ARRAY(char, len);
110-
int ret = jio_snprintf(rotated_file[i], len, "%s." SIZE_FORMAT, filename, i);
110+
int ret = jio_snprintf(rotated_file[i], len, "%s.%zu", filename, i);
111111
ASSERT_NE(-1, ret);
112112
delete_file(rotated_file[i]);
113113
}

test/hotspot/gtest/logging/test_logMessageTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,14 @@ TEST_VM_F(LogMessageTest, message_with_many_lines) {
167167

168168
LogMessageBuffer msg;
169169
for (size_t i = 0; i < lines; i++) {
170-
msg.info("Line #" SIZE_FORMAT, i);
170+
msg.info("Line #%zu", i);
171171
}
172172
_log.write(msg);
173173

174174
char expected_lines_data[lines][line_length];
175175
const char* expected_lines[lines + 1];
176176
for (size_t i = 0; i < lines; i++) {
177-
jio_snprintf(&expected_lines_data[i][0], line_length, "Line #" SIZE_FORMAT, i);
177+
jio_snprintf(&expected_lines_data[i][0], line_length, "Line #%zu", i);
178178
expected_lines[i] = expected_lines_data[i];
179179
}
180180
expected_lines[lines] = nullptr;

test/hotspot/gtest/memory/test_arena.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ TEST_VM(Arena, random_allocs) {
248248
p = ar.AmallocWords(size);
249249
alignment = BytesPerWord;
250250
}
251-
LOG(("[%d]: " PTR_FORMAT ", size " SIZE_FORMAT ", aligned " SIZE_FORMAT,
251+
LOG(("[%d]: " PTR_FORMAT ", size %zu, aligned %zu",
252252
i, p2i(p), size, alignment));
253253
ASSERT_NOT_NULL(p);
254254
ASSERT_ALIGN(p, alignment);
@@ -279,7 +279,7 @@ TEST_VM(Arena, random_allocs) {
279279
ASSERT_NULL(p2);
280280
}
281281
ptrs[i] = p2; sizes[i] = new_size;
282-
LOG(("[%d]: realloc " PTR_FORMAT ", size " SIZE_FORMAT ", aligned " SIZE_FORMAT,
282+
LOG(("[%d]: realloc " PTR_FORMAT ", size %zu, aligned %zu",
283283
i, p2i(p2), new_size, alignments[i]));
284284
}
285285

test/hotspot/gtest/metaspace/test_blocktree.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static void test_find_nearest_fit_with_tree(const size_t sizes[], size_t request
143143
EXPECT_0(real_size);
144144
}
145145

146-
LOG(SIZE_FORMAT ": " SIZE_FORMAT ".", request_size, real_size);
146+
LOG(SIZE_FORMAT ": %zu.", request_size, real_size);
147147

148148
}
149149

@@ -397,13 +397,13 @@ class BlockTreeTest {
397397

398398
feed_all(feeding_pattern);
399399

400-
LOG("Blocks in circulation: bt1=%d:" SIZE_FORMAT ", bt2=%d:" SIZE_FORMAT ".",
400+
LOG("Blocks in circulation: bt1=%d:%zu, bt2=%d:%zu.",
401401
_bt[0].count(), _bt[0].total_size(),
402402
_bt[1].count(), _bt[1].total_size());
403403

404404
ping_pong_loop(5000);
405405

406-
LOG("After Pingpong: bt1=%d:" SIZE_FORMAT ", bt2=%d:" SIZE_FORMAT ".",
406+
LOG("After Pingpong: bt1=%d:%zu, bt2=%d:%zu.",
407407
_bt[0].count(), _bt[0].total_size(),
408408
_bt[1].count(), _bt[1].total_size());
409409

0 commit comments

Comments
 (0)