[libc++/abi] Clean up uses of <iostream> in the test suite
We used <iostream> in several places where we don't actually need the
full power of <iostream>, and where using basic `std::printf` is enough.
This is better, since `std::printf` can be supported on systems that don't
have a notion of locales, while <iostream> can't.
GitOrigin-RevId: cc69d211d0d65d7bf0335fecbc323f784ac3afcc
diff --git a/src/fallback_malloc.cpp b/src/fallback_malloc.cpp
index fdae407..8c0fd6c 100644
--- a/src/fallback_malloc.cpp
+++ b/src/fallback_malloc.cpp
@@ -144,29 +144,26 @@
mutexor mtx(&heap_mutex);
#ifdef DEBUG_FALLBACK_MALLOC
- std::cout << "Freeing item at " << offset_from_node(cp) << " of size "
- << cp->len << std::endl;
+ std::printf("Freeing item at %d of size %d\n", offset_from_node(cp), cp->len);
#endif
for (p = freelist, prev = 0; p && p != list_end;
prev = p, p = node_from_offset(p->next_node)) {
#ifdef DEBUG_FALLBACK_MALLOC
- std::cout << " p, cp, after (p), after(cp) " << offset_from_node(p) << ' '
- << offset_from_node(cp) << ' ' << offset_from_node(after(p))
- << ' ' << offset_from_node(after(cp)) << std::endl;
+ std::printf(" p=%d, cp=%d, after(p)=%d, after(cp)=%d\n",
+ offset_from_node(p), offset_from_node(cp),
+ offset_from_node(after(p)), offset_from_node(after(cp)));
#endif
if (after(p) == cp) {
#ifdef DEBUG_FALLBACK_MALLOC
- std::cout << " Appending onto chunk at " << offset_from_node(p)
- << std::endl;
+ std::printf(" Appending onto chunk at %d\n", offset_from_node(p));
#endif
p->len = static_cast<heap_size>(
p->len + cp->len); // make the free heap_node larger
return;
} else if (after(cp) == p) { // there's a free heap_node right after
#ifdef DEBUG_FALLBACK_MALLOC
- std::cout << " Appending free chunk at " << offset_from_node(p)
- << std::endl;
+ std::printf(" Appending free chunk at %d\n", offset_from_node(p));
#endif
cp->len = static_cast<heap_size>(cp->len + p->len);
if (prev == 0) {
@@ -179,8 +176,7 @@
}
// Nothing to merge with, add it to the start of the free list
#ifdef DEBUG_FALLBACK_MALLOC
- std::cout << " Making new free list entry " << offset_from_node(cp)
- << std::endl;
+ std::printf(" Making new free list entry %d\n", offset_from_node(cp));
#endif
cp->next_node = offset_from_node(freelist);
freelist = cp;
@@ -195,11 +191,11 @@
for (p = freelist, prev = 0; p && p != list_end;
prev = p, p = node_from_offset(p->next_node)) {
- std::cout << (prev == 0 ? "" : " ") << "Offset: " << offset_from_node(p)
- << "\tsize: " << p->len << " Next: " << p->next_node << std::endl;
+ std::printf("%sOffset: %d\tsize: %d Next: %d\n",
+ (prev == 0 ? "" : " "), offset_from_node(p), p->len, p->next_node);
total_free += p->len;
}
- std::cout << "Total Free space: " << total_free << std::endl;
+ std::printf("Total Free space: %d\n", total_free);
return total_free;
}
#endif