diff --git a/be/src/vec/common/allocator.h b/be/src/vec/common/allocator.h index 88c85dceeb32ed..2bcce9a9c68941 100644 --- a/be/src/vec/common/allocator.h +++ b/be/src/vec/common/allocator.h @@ -26,7 +26,14 @@ #if defined(USE_JEMALLOC) #include #endif // defined(USE_JEMALLOC) + +#ifdef __APPLE__ +#include +#define GET_MALLOC_SIZE(ptr) malloc_size(ptr) +#else #include +#define GET_MALLOC_SIZE(ptr) malloc_usable_size(ptr) +#endif #include #include @@ -64,6 +71,14 @@ #define MAP_ANONYMOUS MAP_ANON #endif +#ifndef __THROW +#if __cplusplus +#define __THROW noexcept +#else +#define __THROW +#endif +#endif + static constexpr size_t MMAP_MIN_ALIGNMENT = 4096; static constexpr size_t MALLOC_MIN_ALIGNMENT = 8; @@ -106,7 +121,7 @@ class ORCMemoryAllocator { static constexpr bool need_record_actual_size() { return true; } - static size_t allocated_size(void* ptr) { return malloc_usable_size(ptr); } + static size_t allocated_size(void* ptr) { return GET_MALLOC_SIZE(ptr); } static int posix_memalign(void** ptr, size_t alignment, size_t size) __THROW { return ::posix_memalign(ptr, alignment, size);