more careful overriding of aligned_alloc for compilation on Conda
@@ -163,6 +163,7 @@ extern "C" {
// Posix & Unix functions definitions
// ------------------------------------------------------
+void cfree(void* p) MI_FORWARD0(mi_free, p);
void* reallocf(void* p, size_t newsize) MI_FORWARD2(mi_reallocf,p,newsize);
size_t malloc_size(void* p) MI_FORWARD1(mi_usable_size,p);
#if !defined(__ANDROID__)
@@ -170,7 +171,6 @@ size_t malloc_usable_size(void *p) MI_FORWARD1(mi_usable_size,p);
#else
size_t malloc_usable_size(const void *p) MI_FORWARD1(mi_usable_size,p);
#endif
-void cfree(void* p) MI_FORWARD0(mi_free, p);
// no forwarding here due to aliasing/name mangling issues
void* valloc(size_t size) { return mi_valloc(size); }
@@ -178,15 +178,16 @@ void* pvalloc(size_t size) { return mi_pvalloc(
void* reallocarray(void* p, size_t count, size_t size) { return mi_reallocarray(p, count, size); }
void* memalign(size_t alignment, size_t size) { return mi_memalign(alignment, size); }
int posix_memalign(void** p, size_t alignment, size_t size) { return mi_posix_memalign(p, alignment, size); }
-
-// on some glibc `aligned_alloc` is declared `static inline` so we cannot override it (e.g. Conda).
-// In those cases it will use `memalign`, `posix_memalign`, or `_aligned_malloc` so we override that instead.
-#if _GLIBCXX_HAVE__ALIGNED_MALLOC
void* _aligned_malloc(size_t alignment, size_t size) { return mi_aligned_alloc(alignment, size); }
-#else
+
+// on some glibc `aligned_alloc` is declared `static inline` so we cannot override it (e.g. Conda). This happens
+// when _GLIBCXX_HAVE_ALIGNED_ALLOC is not defined. However, in those cases it will use `memalign`, `posix_memalign`,
+// or `_aligned_malloc` and we can avoid overriding it ourselves.
+#if _GLIBCXX_HAVE_ALIGNED_ALLOC
void* aligned_alloc(size_t alignment, size_t size) { return mi_aligned_alloc(alignment, size); }
#endif
+
#if defined(__GLIBC__) && defined(__linux__)
// forward __libc interface (needed for glibc-based Linux distributions)
void* __libc_malloc(size_t size) MI_FORWARD1(mi_malloc,size);
