From ca64e30a6d3b3b9d60d48d00ba777a4c6de74a8b Mon Sep 17 00:00:00 2001 From: Michael Clark Date: Tue, 18 Jan 2022 11:36:02 +1300 Subject: [PATCH] macos: aligned_alloc function and claimed_address field not present - aligned_alloc is not present on macos. comment to suppress warning. - claimed_address is not present until macos_10.14. add appropriate preprocessor guard around zone_claimed_address function and assignment. --- src/alloc-override-osx.c | 10 +++++++--- src/alloc-override.c | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/alloc-override-osx.c b/src/alloc-override-osx.c index 63297c4c..2c6f37ad 100644 --- a/src/alloc-override-osx.c +++ b/src/alloc-override-osx.c @@ -110,11 +110,13 @@ static void zone_free_definite_size(malloc_zone_t* zone, void* p, size_t size) { zone_free(zone,p); } +#if defined(MAC_OS_X_VERSION_10_14) && \ + MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14 static boolean_t zone_claimed_address(malloc_zone_t* zone, void* p) { MI_UNUSED(zone); return mi_is_in_heap_region(p); } - +#endif /* ------------------------------------------------------ Introspection members @@ -211,12 +213,14 @@ static malloc_zone_t mi_malloc_zone = { .batch_malloc = &zone_batch_malloc, .batch_free = &zone_batch_free, .introspect = &mi_introspect, -#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 +#if defined(MAC_OS_X_VERSION_10_6) && \ + MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 // switch to version 9+ on OSX 10.6 to support memalign. .memalign = &zone_memalign, .free_definite_size = &zone_free_definite_size, .pressure_relief = &zone_pressure_relief, - #if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 + #if defined(MAC_OS_X_VERSION_10_14) && \ + MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14 .claimed_address = &zone_claimed_address, .version = 10 #else diff --git a/src/alloc-override.c b/src/alloc-override.c index 42fecbb3..d78285a7 100644 --- a/src/alloc-override.c +++ b/src/alloc-override.c @@ -77,7 +77,7 @@ typedef struct mi_nothrow_s { int _tag; } mi_nothrow_t; MI_INTERPOSE_MI(valloc), MI_INTERPOSE_MI(malloc_size), MI_INTERPOSE_MI(malloc_good_size), - MI_INTERPOSE_MI(aligned_alloc), + //MI_INTERPOSE_MI(aligned_alloc), #ifdef MI_OSX_ZONE // we interpose malloc_default_zone in alloc-override-osx.c so we can use mi_free safely MI_INTERPOSE_MI(free),