From c087e6f6d565d6d32277c841617ae77ec1d3af3d Mon Sep 17 00:00:00 2001 From: klzgrad Date: Wed, 9 Nov 2022 23:36:59 +0800 Subject: [PATCH] musl: allocator: Fix __THROW and mallinfo --- .../allocator_shim_default_dispatch_to_partition_alloc.cc | 4 +++- .../src/partition_alloc/shim/allocator_shim_internals.h | 4 +++- .../shim/allocator_shim_override_libc_symbols.h | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc b/src/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc index f3ad2e06d5..17c8581c4d 100644 --- a/src/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc +++ b/src/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc @@ -738,7 +738,9 @@ SHIM_ALWAYS_EXPORT int mallopt(int cmd, int value) __THROW { #endif // !PA_BUILDFLAG(IS_APPLE) && !PA_BUILDFLAG(IS_ANDROID) -#if PA_BUILDFLAG(IS_LINUX) || PA_BUILDFLAG(IS_CHROMEOS) +#if defined(__MUSL__) +// Musl does not support struct mallinfo. +#elif PA_BUILDFLAG(IS_LINUX) || PA_BUILDFLAG(IS_CHROMEOS) SHIM_ALWAYS_EXPORT struct mallinfo mallinfo(void) __THROW { partition_alloc::SimplePartitionStatsDumper allocator_dumper; Allocator()->DumpStats("malloc", true, &allocator_dumper); diff --git a/src/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_internals.h b/src/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_internals.h index afa815114a..d7d178d646 100644 --- a/src/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_internals.h +++ b/src/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_internals.h @@ -9,7 +9,9 @@ #if defined(__GNUC__) -#if PA_BUILDFLAG(IS_POSIX) +#if defined(__MUSL__) +// Musl does not provide sys/cdefs.h +#elif PA_BUILDFLAG(IS_POSIX) #include // for __THROW #endif diff --git a/src/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_override_libc_symbols.h b/src/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_override_libc_symbols.h index 5037b7034d..a7206d73d7 100644 --- a/src/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_override_libc_symbols.h +++ b/src/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_override_libc_symbols.h @@ -25,6 +25,12 @@ #include "partition_alloc/shim/allocator_shim_internals.h" +// Musl does not specify anything for malloc() etc. +#if defined(__MUSL__) +#undef __THROW +#define __THROW +#endif + extern "C" { // WARNING: Whenever a new function is added there (which, surprisingly enough,