From d40a4786e9eab2bcab140506f84ecf11dd4646ae Mon Sep 17 00:00:00 2001
|
From: Khem Raj <raj.khem@gmail.com>
|
Date: Wed, 13 Feb 2019 09:51:14 -0800
|
Subject: [PATCH] mallinfo implementation is glibc specific
|
|
Upstream-Status: Pending
|
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
---
|
--- a/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc
|
+++ b/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc
|
@@ -35,7 +35,7 @@ bool MemoryUsage::IsSupported() {
|
|
MemoryUsage GetMemoryUsage() {
|
MemoryUsage result;
|
-#ifdef __linux__
|
+#if defined(__linux__) && defined(__GLIBC__)
|
rusage res;
|
if (getrusage(RUSAGE_SELF, &res) == 0) {
|
result.max_rss_kb = res.ru_maxrss;
|
--- a/base/process/process_metrics_posix.cc
|
+++ b/base/process/process_metrics_posix.cc
|
@@ -105,7 +105,7 @@ void IncreaseFdLimitTo(unsigned int max_
|
|
#endif // !defined(OS_FUCHSIA)
|
|
-#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
|
+#if (defined(OS_LINUX) && defined(__GLIBC__)) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
|
namespace {
|
|
size_t GetMallocUsageMallinfo() {
|
@@ -127,16 +127,16 @@ size_t GetMallocUsageMallinfo() {
|
}
|
|
} // namespace
|
-#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
|
+#endif // (defined(OS_LINUX) && defined(__GLIBC__)) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
|
|
size_t ProcessMetrics::GetMallocUsage() {
|
#if defined(OS_APPLE)
|
malloc_statistics_t stats = {0};
|
malloc_zone_statistics(nullptr, &stats);
|
return stats.size_in_use;
|
-#elif defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
|
+#elif (defined(OS_LINUX) && defined(__GLIBC__)) || defined(OS_CHROMEOS) || defined(OS_ANDROID)
|
return GetMallocUsageMallinfo();
|
-#elif defined(OS_FUCHSIA)
|
+#else
|
// TODO(fuchsia): Not currently exposed. https://crbug.com/735087.
|
return 0;
|
#endif
|
--- a/base/trace_event/malloc_dump_provider.cc
|
+++ b/base/trace_event/malloc_dump_provider.cc
|
@@ -219,7 +219,6 @@ bool MallocDumpProvider::OnMemoryDump(co
|
#define MALLINFO2_FOUND_IN_LIBC
|
struct mallinfo2 info = mallinfo2();
|
#endif
|
-#endif // defined(__GLIBC__) && defined(__GLIBC_PREREQ)
|
#if !defined(MALLINFO2_FOUND_IN_LIBC)
|
struct mallinfo info = mallinfo();
|
#endif
|
@@ -232,6 +231,7 @@ bool MallocDumpProvider::OnMemoryDump(co
|
|
// Total allocated space is given by |uordblks|.
|
allocated_objects_size = info.uordblks;
|
+#endif // defined(__GLIBC__) && defined(__GLIBC_PREREQ)
|
#endif
|
|
MemoryAllocatorDump* outer_dump = pmd->CreateAllocatorDump("malloc");
|
--- a/third_party/swiftshader/third_party/llvm-subzero/build/Linux/include/llvm/Config/config.h
|
+++ b/third_party/swiftshader/third_party/llvm-subzero/build/Linux/include/llvm/Config/config.h
|
@@ -133,7 +133,7 @@
|
/* #undef HAVE_MALLCTL */
|
|
/* Define to 1 if you have the `mallinfo' function. */
|
-#define HAVE_MALLINFO 1
|
+/* #undef HAVE_MALLINFO */
|
|
/* Some projects using SwiftShader bypass cmake (eg Chromium via gn) */
|
/* so we need to check glibc version for the new API to be safe */
|
--- a/third_party/swiftshader/third_party/llvm-10.0/configs/linux/include/llvm/Config/config.h
|
+++ b/third_party/swiftshader/third_party/llvm-10.0/configs/linux/include/llvm/Config/config.h
|
@@ -128,7 +128,7 @@
|
/* #undef HAVE_MALLCTL */
|
|
/* Define to 1 if you have the `mallinfo' function. */
|
-#define HAVE_MALLINFO 1
|
+/* #undef HAVE_MALLINFO */
|
|
/* Some projects using SwiftShader bypass cmake (eg Chromium via gn) */
|
/* so we need to check glibc version for the new API to be safe */
|