Port vespamalloc overload handling to clang.
@@ -13,6 +13,9 @@ public:
vespamalloc::createAllocator();
}
private:
+#ifdef __clang__
+ [[maybe_unused]]
+#endif
unsigned _initialized;
};
@@ -119,8 +122,8 @@ int posix_memalign(void** ptr, size_t align, size_t sz) __THROW
return retval;
}
-void *valloc(size_t size) __attribute__((visibility ("default")));
-void *valloc(size_t size)
+void *valloc(size_t size) __THROW __attribute__((visibility ("default")));
+void *valloc(size_t size) __THROW
{
return memalign(sysconf(_SC_PAGESIZE),size);
}
@@ -131,12 +134,24 @@ void free(void * ptr) {
}
#define ALIAS(x) __attribute__ ((weak, alias (x), visibility ("default")))
+#ifdef __clang__
+void* __libc_malloc(size_t sz) __THROW __attribute__((malloc, alloc_size(1))) ALIAS("malloc");
+void* __libc_realloc(void* ptr, size_t sz) __THROW __attribute__((malloc, alloc_size(2))) ALIAS("realloc");
+void* __libc_calloc(size_t n, size_t sz) __THROW __attribute__((malloc, alloc_size(2))) ALIAS("calloc");
+void cfree(void *) __THROW ALIAS("free");
+void __libc_free(void* ptr) __THROW ALIAS("free");
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wignored-attributes"
+void __libc_cfree(void* ptr) __THROW ALIAS("cfree");
+#pragma clang diagnostic pop
+#else
void* __libc_malloc(size_t sz) __THROW __attribute__((leaf, malloc, alloc_size(1))) ALIAS("malloc");
void* __libc_realloc(void* ptr, size_t sz) __THROW __attribute__((leaf, malloc, alloc_size(2))) ALIAS("realloc");
void* __libc_calloc(size_t n, size_t sz) __THROW __attribute__((leaf, malloc, alloc_size(2))) ALIAS("calloc");
void cfree(void *) __THROW __attribute__((leaf)) ALIAS("free");
void __libc_free(void* ptr) __THROW __attribute__((leaf)) ALIAS("free");
void __libc_cfree(void* ptr) __THROW __attribute__((leaf)) ALIAS("cfree");
+#endif
void* __libc_memalign(size_t align, size_t s) ALIAS("memalign");
int __posix_memalign(void** r, size_t a, size_t s) __THROW __nonnull((1)) ALIAS("posix_memalign");
#undef ALIAS
