From 741fca1bb7773e14cf929824b94506eb9f545e5e Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 11 Jul 2018 21:39:44 +0200 Subject: [PATCH] Hide smallocx even when enabled from the library API The experimental `smallocx` API is not exposed via header files, requiring the users to peek at `jemalloc`'s source code to manually add the external declarations to their own programs. This should reinforce that `smallocx` is experimental, and that `jemalloc` does not offer any kind of backwards compatiblity or ABI gurantees for it. --- include/jemalloc/jemalloc_protos.h.in | 4 ---- include/jemalloc/jemalloc_typedefs.h.in | 7 ------- src/jemalloc.c | 5 +++++ test/integration/smallocx.c | 7 +++++++ 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/jemalloc/jemalloc_protos.h.in b/include/jemalloc/jemalloc_protos.h.in index 05fc056f..a78414b1 100644 --- a/include/jemalloc/jemalloc_protos.h.in +++ b/include/jemalloc/jemalloc_protos.h.in @@ -28,10 +28,6 @@ JEMALLOC_EXPORT void JEMALLOC_NOTHROW @je_@free(void *ptr) JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN void JEMALLOC_NOTHROW *@je_@mallocx(size_t size, int flags) JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE(1); -#ifdef JEMALLOC_EXPERIMENTAL_SMALLOCX_API -JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN - smallocx_return_t JEMALLOC_NOTHROW @je_@smallocx(size_t size, int flags); -#endif JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN void JEMALLOC_NOTHROW *@je_@rallocx(void *ptr, size_t size, int flags) JEMALLOC_ALLOC_SIZE(2); diff --git a/include/jemalloc/jemalloc_typedefs.h.in b/include/jemalloc/jemalloc_typedefs.h.in index fe0d7d1e..1a588743 100644 --- a/include/jemalloc/jemalloc_typedefs.h.in +++ b/include/jemalloc/jemalloc_typedefs.h.in @@ -75,10 +75,3 @@ struct extent_hooks_s { extent_split_t *split; extent_merge_t *merge; }; - -#ifdef JEMALLOC_EXPERIMENTAL_SMALLOCX_API -typedef struct { - void *ptr; - size_t size; -} smallocx_return_t; -#endif diff --git a/src/jemalloc.c b/src/jemalloc.c index 01e2db97..57d9f157 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -2770,6 +2770,11 @@ int __posix_memalign(void** r, size_t a, size_t s) PREALIAS(je_posix_memalign); */ #ifdef JEMALLOC_EXPERIMENTAL_SMALLOCX_API +typedef struct { + void *ptr; + size_t size; +} smallocx_return_t; + JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN smallocx_return_t JEMALLOC_NOTHROW /* diff --git a/test/integration/smallocx.c b/test/integration/smallocx.c index 376fec25..f49ec845 100644 --- a/test/integration/smallocx.c +++ b/test/integration/smallocx.c @@ -1,5 +1,12 @@ #include "test/jemalloc_test.h" +typedef struct { + void *ptr; + size_t size; +} smallocx_return_t; + +extern smallocx_return_t smallocx(size_t size, int flags); + static unsigned get_nsizes_impl(const char *cmd) { unsigned ret;