diff options
Diffstat (limited to 'community/chromium/no-mallinfo.patch')
-rw-r--r-- | community/chromium/no-mallinfo.patch | 132 |
1 files changed, 93 insertions, 39 deletions
diff --git a/community/chromium/no-mallinfo.patch b/community/chromium/no-mallinfo.patch index 22572b1eb5a..37abb3fe062 100644 --- a/community/chromium/no-mallinfo.patch +++ b/community/chromium/no-mallinfo.patch @@ -1,64 +1,67 @@ ---- .base/trace_event/malloc_dump_provider.cc.orig -+++ ./base/trace_event/malloc_dump_provider.cc -@@ -213,24 +213,7 @@ - #elif defined(OS_FUCHSIA) - // TODO(fuchsia): Port, see https://crbug.com/706592. - #else --#if defined(__GLIBC__) && defined(__GLIBC_PREREQ) --#if __GLIBC_PREREQ(2, 33) --#define MALLINFO2_FOUND_IN_LIBC -- struct mallinfo2 info = mallinfo2(); --#endif +musl does not implement mallinfo()/mallinfo2() +(or rather, malloc-ng, musl's allocator, doesn't) +-- +--- a/base/trace_event/malloc_dump_provider.cc ++++ b/base/trace_event/malloc_dump_provider.cc +@@ -185,7 +185,6 @@ + #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 --#undef MALLINFO2_FOUND_IN_LIBC -- // In case of Android's jemalloc |arena| is 0 and the outer pages size is -- // reported by |hblkhd|. In case of dlmalloc the total is given by -- // |arena| + |hblkhd|. For more details see link: http://goo.gl/fMR8lF. -- total_virtual_size = info.arena + info.hblkhd; -- resident_size = info.uordblks; -- -- // Total allocated space is given by |uordblks|. -- allocated_objects_size = info.uordblks; -+// NOOP + #if !defined(MALLINFO2_FOUND_IN_LIBC) + struct mallinfo info = mallinfo(); + #endif +@@ -205,6 +204,7 @@ + sys_alloc_dump->AddScalar(MemoryAllocatorDump::kNameSize, + MemoryAllocatorDump::kUnitsBytes, info.uordblks); + } ++#endif // defined(__GLIBC__) && defined(__GLIBC_PREREQ) + } #endif - MemoryAllocatorDump* outer_dump = pmd->CreateAllocatorDump("malloc"); ---- ./base/process/process_metrics_posix.cc -+++ ./base/process/process_metrics_posix.cc +@@ -339,7 +340,7 @@ + &allocated_objects_count); + #elif BUILDFLAG(IS_FUCHSIA) + // TODO(fuchsia): Port, see https://crbug.com/706592. +-#else ++#elif defined(__GLIBC__) + ReportMallinfoStats(/*pmd=*/nullptr, &total_virtual_size, &resident_size, + &allocated_objects_size, &allocated_objects_count); + #endif +--- a/base/process/process_metrics_posix.cc ++++ b/base/process/process_metrics_posix.cc @@ -105,7 +105,7 @@ - #endif // !defined(OS_FUCHSIA) + #endif // !BUILDFLAG(IS_FUCHSIA) --#if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) -+#if (defined(OS_LINUX) && defined(__GLIBC__)) || defined(OS_CHROMEOS) || defined(OS_ANDROID) +-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) ++#if (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) namespace { size_t GetMallocUsageMallinfo() { -@@ -127,16 +127,16 @@ +@@ -123,7 +123,7 @@ } } // namespace --#endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) -+#endif // (defined(OS_LINUX) && defined(__GLIBC__)) || defined(OS_CHROMEOS) || defined(OS_ANDROID) +-#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || ++#endif // (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) || + // BUILDFLAG(IS_ANDROID) size_t ProcessMetrics::GetMallocUsage() { - #if defined(OS_APPLE) +@@ -131,9 +131,9 @@ 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) +-#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) ++#elif (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) return GetMallocUsageMallinfo(); --#elif defined(OS_FUCHSIA) +-#elif BUILDFLAG(IS_FUCHSIA) +#else // TODO(fuchsia): Not currently exposed. https://crbug.com/735087. return 0; #endif ---- third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc.orig -+++ third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc +--- ./third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc.orig ++++ ./third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc @@ -35,7 +35,7 @@ MemoryUsage GetMemoryUsage() { @@ -68,3 +71,54 @@ rusage res; if (getrusage(RUSAGE_SELF, &res) == 0) { result.max_rss_kb = res.ru_maxrss; +--- ./third_party/swiftshader/third_party/llvm-subzero/lib/Support/Unix/Process.inc ++++ ./third_party/swiftshader/third_party/llvm-subzero/lib/Support/Unix/Process.inc.orig +@@ -86,11 +86,11 @@ + } + + size_t Process::GetMallocUsage() { +-#if defined(HAVE_MALLINFO2) ++#if defined(HAVE_MALLINFO2) && defined(__GLIBC__) + struct mallinfo2 mi; + mi = ::mallinfo2(); + return mi.uordblks; +-#elif defined(HAVE_MALLINFO) ++#elif defined(HAVE_MALLINFO) && defined(__GLIBC__) + struct mallinfo mi; + mi = ::mallinfo(); + return mi.uordblks; + +--- ./third_party/swiftshader/third_party/llvm-10.0/configs/linux/include/llvm/Config/config.h.orig 2019-09-30 13:03:42.556880537 -0400 ++++ ./third_party/swiftshader/third_party/llvm-10.0/configs/linux/include/llvm/Config/config.h 2019-09-30 13:07:27.989821227 -0400 +@@ -122,7 +122,9 @@ + /* #undef HAVE_MALLCTL */ + + /* Define to 1 if you have the `mallinfo' function. */ ++#if defined(__GLIBC__) + #define HAVE_MALLINFO 1 ++#endif + + /* Define to 1 if you have the <malloc.h> header file. */ + #define HAVE_MALLOC_H 1 +--- a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc ++++ b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc +@@ -717,7 +717,7 @@ + + #endif // !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_ANDROID) + +-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ++#if 0 + SHIM_ALWAYS_EXPORT struct mallinfo mallinfo(void) __THROW { + base::SimplePartitionStatsDumper allocator_dumper; + Allocator()->DumpStats("malloc", true, &allocator_dumper); +--- a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc ++++ b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc +@@ -24,7 +24,7 @@ + #if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) + + // Platforms on which we override weak libc symbols. +-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ++#if (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) + + NOINLINE void FreeForTest(void* data) { + free(data); |