Bug 1052573 - Separate the base allocator functions in malloc_decls.h. r?njn draft
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 21 Sep 2017 10:31:09 +0900
changeset 668772 96e49ce5a98e44e957a497b64fde23a82e0c8156
parent 668771 4084607826a3b3aee1e144b126752e99af213085
child 668773 3f7b1837627efa6cc01b9d0c59a4e10e49e030b0
push id81117
push userbmo:mh+mozilla@glandium.org
push dateFri, 22 Sep 2017 00:20:00 +0000
reviewersnjn
bugs1052573
milestone58.0a1
Bug 1052573 - Separate the base allocator functions in malloc_decls.h. r?njn malloc, free, calloc, realloc and memalign constitute some sort of minimal interface to the allocator. posix_memalign, aligned_alloc and valloc are already defined in terms of memalign. The remaining functions are not related to active allocation.
memory/build/malloc_decls.h
--- a/memory/build/malloc_decls.h
+++ b/memory/build/malloc_decls.h
@@ -10,44 +10,49 @@
  *   - argument types
  */
 
 #ifndef malloc_decls_h
 #  define malloc_decls_h
 
 #  include "mozjemalloc_types.h"
 
-#  define MALLOC_FUNCS_MALLOC 1
-#  define MALLOC_FUNCS_JEMALLOC 2
-#  define MALLOC_FUNCS_INIT 4
-#  define MALLOC_FUNCS_BRIDGE 8
+#  define MALLOC_FUNCS_MALLOC_BASE 1
+#  define MALLOC_FUNCS_MALLOC_EXTRA 2
+#  define MALLOC_FUNCS_MALLOC (MALLOC_FUNCS_MALLOC_BASE | \
+                               MALLOC_FUNCS_MALLOC_EXTRA)
+#  define MALLOC_FUNCS_JEMALLOC 4
+#  define MALLOC_FUNCS_INIT 8
+#  define MALLOC_FUNCS_BRIDGE 16
 #  define MALLOC_FUNCS_ALL (MALLOC_FUNCS_INIT | MALLOC_FUNCS_BRIDGE | \
                             MALLOC_FUNCS_MALLOC | MALLOC_FUNCS_JEMALLOC)
 
 #endif /* malloc_decls_h */
 
 #ifndef MALLOC_FUNCS
 #  define MALLOC_FUNCS (MALLOC_FUNCS_MALLOC | MALLOC_FUNCS_JEMALLOC)
 #endif
 
 #ifdef MALLOC_DECL
 #  if MALLOC_FUNCS & MALLOC_FUNCS_INIT
 MALLOC_DECL(init, void, const malloc_table_t *)
 #  endif
 #  if MALLOC_FUNCS & MALLOC_FUNCS_BRIDGE
 MALLOC_DECL(get_bridge, struct ReplaceMallocBridge*)
 #  endif
-#  if MALLOC_FUNCS & MALLOC_FUNCS_MALLOC
+#  if MALLOC_FUNCS & MALLOC_FUNCS_MALLOC_BASE
 MALLOC_DECL(malloc, void *, size_t)
-MALLOC_DECL(posix_memalign, int, void **, size_t, size_t)
-MALLOC_DECL(aligned_alloc, void *, size_t, size_t)
 MALLOC_DECL(calloc, void *, size_t, size_t)
 MALLOC_DECL(realloc, void *, void *, size_t)
 MALLOC_DECL(free, void, void *)
 MALLOC_DECL(memalign, void *, size_t, size_t)
+#  endif
+#  if MALLOC_FUNCS & MALLOC_FUNCS_MALLOC_EXTRA
+MALLOC_DECL(posix_memalign, int, void **, size_t, size_t)
+MALLOC_DECL(aligned_alloc, void *, size_t, size_t)
 MALLOC_DECL(valloc, void *, size_t)
 MALLOC_DECL(malloc_usable_size, size_t, usable_ptr_t)
 MALLOC_DECL(malloc_good_size, size_t, size_t)
 #  endif
 #  if MALLOC_FUNCS & MALLOC_FUNCS_JEMALLOC
 MALLOC_DECL(jemalloc_stats, void, jemalloc_stats_t *)
 /*
  * On some operating systems (Mac), we use madvise(MADV_FREE) to hand pages