This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 4042cdf5532 [Fix](memory) Fix allocator.h compiling failed on mac.
(#38646)
4042cdf5532 is described below
commit 4042cdf5532d433b94e2c4339ca3cdda13e30df8
Author: Qi Chen <[email protected]>
AuthorDate: Thu Aug 1 13:56:53 2024 +0800
[Fix](memory) Fix allocator.h compiling failed on mac. (#38646)
Backport #38562. Fix allocator.h compiling failed on mac which
introduced by #37257.
---
be/src/vec/common/allocator.h | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/be/src/vec/common/allocator.h b/be/src/vec/common/allocator.h
index 9e0a4ac966f..83cb6eddb7d 100644
--- a/be/src/vec/common/allocator.h
+++ b/be/src/vec/common/allocator.h
@@ -26,7 +26,14 @@
#if defined(USE_JEMALLOC)
#include <jemalloc/jemalloc.h>
#endif // defined(USE_JEMALLOC)
+
+#ifdef __APPLE__
+#include <malloc/malloc.h>
+#define GET_MALLOC_SIZE(ptr) malloc_size(ptr)
+#else
#include <malloc.h>
+#define GET_MALLOC_SIZE(ptr) malloc_usable_size(ptr)
+#endif
#include <stdint.h>
#include <string.h>
@@ -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 @@ public:
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);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]