libstdc++: Use glibc >= 2.33 mallinfo2 function
mallinfo started to be deprecated which makes performance tests failed
to build, just
adopt mallinfo2.
libstdcxx-v3/ChangeLog:
* testsuite/util/testsuite_performance.h (__mallinfo): New, our
own mallinfo
struct with just what we need. When using glibc >= 2.33 use
mallinfo2 to
populate it.
Tested under Linux x86_64,
Ok to commit ?
François
diff --git a/libstdc++-v3/testsuite/util/testsuite_performance.h b/libstdc++-v3/testsuite/util/testsuite_performance.h
index 2e05bef8460..dc002b8c390 100644
--- a/libstdc++-v3/testsuite/util/testsuite_performance.h
+++ b/libstdc++-v3/testsuite/util/testsuite_performance.h
@@ -35,37 +35,49 @@
#include <cxxabi.h>
#include <testsuite_common_types.h>
-#if defined (__linux__) || defined (__GLIBC__)
-#include <malloc.h>
-#elif defined (__FreeBSD__)
extern "C"
{
- struct mallinfo
+ struct __mallinfo
{
- int uordblks;
- int hblkhd;
+ size_t uordblks;
+ size_t hblkhd;
};
+}
- struct mallinfo
- mallinfo(void)
+#if defined (__linux__) || defined (__GLIBC__)
+#include <malloc.h>
+extern "C"
+{
+ struct __mallinfo
+ __mallinfo(void)
+ {
+#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 33
+ struct mallinfo2 mi = mallinfo2();
+ struct __mallinfo m = { mi.uordblks, mi.hblkhd };
+#else
+ struct mallinfo mi = mallinfo();
+ struct __mallinfo m = { mi.uordblks, mi.hblkhd };
+#endif
+ return m;
+ }
+}
+#elif defined (__FreeBSD__)
+extern "C"
+{
+ struct __mallinfo
+ __mallinfo(void)
{
- struct mallinfo m = { (((std::size_t) sbrk (0) + 1023) / 1024), 0 };
+ struct __mallinfo m = { (((std::size_t) sbrk (0) + 1023) / 1024), 0 };
return m;
}
}
#elif !defined (__hpux__)
extern "C"
{
- struct mallinfo
- {
- int uordblks;
- int hblkhd;
- };
-
- struct mallinfo empty = { 0, 0 };
+ struct __mallinfo empty = { 0, 0 };
- struct mallinfo
- mallinfo(void)
+ struct __mallinfo
+ __mallinfo(void)
{ return empty; }
}
#endif
@@ -146,8 +158,8 @@ namespace __gnu_test
int who;
rusage rusage_begin;
rusage rusage_end;
- struct mallinfo allocation_begin;
- struct mallinfo allocation_end;
+ struct __mallinfo allocation_begin;
+ struct __mallinfo allocation_end;
public:
resource_counter(int i = RUSAGE_SELF) : who(i)
@@ -168,7 +180,7 @@ namespace __gnu_test
if (getrusage(who, &rusage_begin) != 0 )
memset(&rusage_begin, 0, sizeof(rusage_begin));
void* p __attribute__((unused)) = malloc(0); // Needed for some implementations.
- allocation_begin = mallinfo();
+ allocation_begin = __mallinfo();
}
void
@@ -176,7 +188,7 @@ namespace __gnu_test
{
if (getrusage(who, &rusage_end) != 0 )
memset(&rusage_end, 0, sizeof(rusage_end));
- allocation_end = mallinfo();
+ allocation_end = __mallinfo();
}
int