void-packages/srcpkgs/qt6-pdf/patches/0134-musl-no-mallinfo.patch

86 lines
3.7 KiB
Diff

Source: https://git.alpinelinux.org/aports/plain/community/chromium/no-mallinfo.patch
musl does not implement mallinfo()/mallinfo2()
(or rather, malloc-ng, musl's allocator, doesn't)
--
--- a/src/3rdparty/chromium/base/trace_event/malloc_dump_provider.cc
+++ b/src/3rdparty/chromium/base/trace_event/malloc_dump_provider.cc
@@ -199,7 +199,6 @@ void ReportMallinfoStats(ProcessMemoryDu
#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
@@ -221,6 +220,7 @@ void ReportMallinfoStats(ProcessMemoryDu
MemoryAllocatorDump::kUnitsBytes,
total_allocated_size);
}
+#endif // defined(__GLIBC__) && defined(__GLIBC_PREREQ)
}
#endif
@@ -359,7 +359,7 @@ bool MallocDumpProvider::OnMemoryDump(co
&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/src/3rdparty/chromium/base/process/process_metrics_posix.cc
+++ b/src/3rdparty/chromium/base/process/process_metrics_posix.cc
@@ -106,7 +106,7 @@ void IncreaseFdLimitTo(unsigned int max_
#endif // !BUILDFLAG(IS_FUCHSIA)
-#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() {
@@ -124,7 +124,7 @@ size_t GetMallocUsageMallinfo() {
}
} // namespace
-#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ||
+#endif // (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) ||
// BUILDFLAG(IS_ANDROID)
size_t ProcessMetrics::GetMallocUsage() {
@@ -132,9 +132,9 @@ size_t ProcessMetrics::GetMallocUsage()
malloc_statistics_t stats = {0};
malloc_zone_statistics(nullptr, &stats);
return stats.size_in_use;
-#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 BUILDFLAG(IS_FUCHSIA)
+#else
// TODO(fuchsia): Not currently exposed. https://crbug.com/735087.
return 0;
#endif
--- a/src/3rdparty/chromium/base/allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc.cc
+++ b/src/3rdparty/chromium/base/allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc.cc
@@ -736,7 +736,7 @@ SHIM_ALWAYS_EXPORT int mallopt(int cmd,
#endif // !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_ANDROID)
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
+#if 0
SHIM_ALWAYS_EXPORT struct mallinfo mallinfo(void) __THROW {
partition_alloc::SimplePartitionStatsDumper allocator_dumper;
Allocator()->DumpStats("malloc", true, &allocator_dumper);
--- a/src/3rdparty/chromium/base/allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc
+++ b/src/3rdparty/chromium/base/allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc
@@ -24,7 +24,7 @@ namespace allocator_shim::internal {
#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)
PA_NOINLINE void FreeForTest(void* data) {
free(data);