Index: base/allocator/allocator_shim_default_dispatch_to_glibc.cc |
diff --git a/base/allocator/allocator_shim_default_dispatch_to_glibc.cc b/base/allocator/allocator_shim_default_dispatch_to_glibc.cc |
index 8574da3eb3d011f08625f1e11cbeb1b0b5729965..50f5533b8c4eb5ec6a721eb548d0703c3d6a3345 100644 |
--- a/base/allocator/allocator_shim_default_dispatch_to_glibc.cc |
+++ b/base/allocator/allocator_shim_default_dispatch_to_glibc.cc |
@@ -6,6 +6,11 @@ |
#include <malloc.h> |
+// This is required for posix_memalign |
+#if defined(OS_AIX) |
+#include <stdlib.h> |
+#endif |
+ |
// This translation unit defines a default dispatch for the allocator shim which |
// routes allocations to libc functions. |
// The code here is strongly inspired from tcmalloc's libc_override_glibc.h. |
@@ -23,32 +28,56 @@ namespace { |
using base::allocator::AllocatorDispatch; |
void* GlibcMalloc(const AllocatorDispatch*, size_t size, void* context) { |
+#if defined(OS_AIX) |
+ return malloc(size); |
Primiano Tucci (use gerrit)
2017/04/13 09:59:14
this is just going to cause loops in the malloc co
|
+#else |
return __libc_malloc(size); |
+#endif |
} |
void* GlibcCalloc(const AllocatorDispatch*, |
size_t n, |
size_t size, |
void* context) { |
+#if defined(OS_AIX) |
+ return calloc(n, size); |
+#else |
return __libc_calloc(n, size); |
+#endif |
} |
void* GlibcRealloc(const AllocatorDispatch*, |
void* address, |
size_t size, |
void* context) { |
+#if defined(OS_AIX) |
+ return realloc(address, size); |
+#else |
return __libc_realloc(address, size); |
+#endif |
} |
void* GlibcMemalign(const AllocatorDispatch*, |
size_t alignment, |
size_t size, |
void* context) { |
+#if defined(OS_AIX) |
+ void* p; |
+ if (posix_memalign(&p, alignment, size) == 0) |
+ return p; |
+ else |
+ return NULL; |
+#else |
return __libc_memalign(alignment, size); |
+#endif |
} |
void GlibcFree(const AllocatorDispatch*, void* address, void* context) { |
- __libc_free(address); |
+#if defined(OS_AIX) |
+ return free(address); |
+#else |
+ return __libc_free(address); |
+#endif |
} |
size_t GlibcGetSizeEstimate(const AllocatorDispatch*, |
@@ -56,7 +85,11 @@ size_t GlibcGetSizeEstimate(const AllocatorDispatch*, |
void* context) { |
// TODO(siggi, primiano): malloc_usable_size may need redirection in the |
// presence of interposing shims that divert allocations. |
+#if defined(OS_AIX) |
+ return 0; |
+#else |
return malloc_usable_size(address); |
+#endif |
} |
} // namespace |