Make smallocx
symbol name depend on the JEMALLOC_VERSION_GID
This comments concatenates the `JEMALLOC_VERSION_GID` to the `smallocx` symbol name, such that the symbol ends up exported as `smallocx_{git_hash}`.
This commit is contained in:
parent
837de32496
commit
01e2a38e5a
126
configure.ac
126
configure.ac
@ -538,6 +538,66 @@ AC_PROG_NM
|
||||
|
||||
AC_PROG_AWK
|
||||
|
||||
dnl ============================================================================
|
||||
dnl jemalloc version.
|
||||
dnl
|
||||
|
||||
AC_ARG_WITH([version],
|
||||
[AS_HELP_STRING([--with-version=<major>.<minor>.<bugfix>-<nrev>-g<gid>],
|
||||
[Version string])],
|
||||
[
|
||||
echo "${with_version}" | grep ['^[0-9]\+\.[0-9]\+\.[0-9]\+-[0-9]\+-g[0-9a-f]\+$'] 2>&1 1>/dev/null
|
||||
if test $? -eq 0 ; then
|
||||
echo "$with_version" > "${objroot}VERSION"
|
||||
else
|
||||
echo "${with_version}" | grep ['^VERSION$'] 2>&1 1>/dev/null
|
||||
if test $? -ne 0 ; then
|
||||
AC_MSG_ERROR([${with_version} does not match <major>.<minor>.<bugfix>-<nrev>-g<gid> or VERSION])
|
||||
fi
|
||||
fi
|
||||
], [
|
||||
dnl Set VERSION if source directory is inside a git repository.
|
||||
if test "x`test ! \"${srcroot}\" && cd \"${srcroot}\"; git rev-parse --is-inside-work-tree 2>/dev/null`" = "xtrue" ; then
|
||||
dnl Pattern globs aren't powerful enough to match both single- and
|
||||
dnl double-digit version numbers, so iterate over patterns to support up
|
||||
dnl to version 99.99.99 without any accidental matches.
|
||||
for pattern in ['[0-9].[0-9].[0-9]' '[0-9].[0-9].[0-9][0-9]' \
|
||||
'[0-9].[0-9][0-9].[0-9]' '[0-9].[0-9][0-9].[0-9][0-9]' \
|
||||
'[0-9][0-9].[0-9].[0-9]' '[0-9][0-9].[0-9].[0-9][0-9]' \
|
||||
'[0-9][0-9].[0-9][0-9].[0-9]' \
|
||||
'[0-9][0-9].[0-9][0-9].[0-9][0-9]']; do
|
||||
(test ! "${srcroot}" && cd "${srcroot}"; git describe --long --abbrev=40 --match="${pattern}") > "${objroot}VERSION.tmp" 2>/dev/null
|
||||
if test $? -eq 0 ; then
|
||||
mv "${objroot}VERSION.tmp" "${objroot}VERSION"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
rm -f "${objroot}VERSION.tmp"
|
||||
])
|
||||
|
||||
if test ! -e "${objroot}VERSION" ; then
|
||||
if test ! -e "${srcroot}VERSION" ; then
|
||||
AC_MSG_RESULT(
|
||||
[Missing VERSION file, and unable to generate it; creating bogus VERSION])
|
||||
echo "0.0.0-0-g0000000000000000000000000000000000000000" > "${objroot}VERSION"
|
||||
else
|
||||
cp ${srcroot}VERSION ${objroot}VERSION
|
||||
fi
|
||||
fi
|
||||
jemalloc_version=`cat "${objroot}VERSION"`
|
||||
jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
|
||||
jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
|
||||
jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
|
||||
jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
|
||||
jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
|
||||
AC_SUBST([jemalloc_version])
|
||||
AC_SUBST([jemalloc_version_major])
|
||||
AC_SUBST([jemalloc_version_minor])
|
||||
AC_SUBST([jemalloc_version_bugfix])
|
||||
AC_SUBST([jemalloc_version_nrev])
|
||||
AC_SUBST([jemalloc_version_gid])
|
||||
|
||||
dnl Platform-specific settings. abi and RPATH can probably be determined
|
||||
dnl programmatically, but doing so is error-prone, which makes it generally
|
||||
dnl not worth the trouble.
|
||||
@ -850,7 +910,7 @@ AC_ARG_WITH([export],
|
||||
fi]
|
||||
)
|
||||
|
||||
public_syms="aligned_alloc calloc dallocx free mallctl mallctlbymib mallctlnametomib malloc malloc_conf malloc_message malloc_stats_print malloc_usable_size mallocx smallocx nallocx posix_memalign rallocx realloc sallocx sdallocx xallocx"
|
||||
public_syms="aligned_alloc calloc dallocx free mallctl mallctlbymib mallctlnametomib malloc malloc_conf malloc_message malloc_stats_print malloc_usable_size mallocx smallocx_${jemalloc_version_gid} nallocx posix_memalign rallocx realloc sallocx sdallocx xallocx"
|
||||
dnl Check for additional platform-specific public API functions.
|
||||
AC_CHECK_FUNC([memalign],
|
||||
[AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ])
|
||||
@ -991,6 +1051,10 @@ cfghdrs_tup="include/jemalloc/jemalloc_defs.h:include/jemalloc/jemalloc_defs.h.i
|
||||
cfghdrs_tup="${cfghdrs_tup} include/jemalloc/internal/jemalloc_internal_defs.h:include/jemalloc/internal/jemalloc_internal_defs.h.in"
|
||||
cfghdrs_tup="${cfghdrs_tup} test/include/test/jemalloc_test_defs.h:test/include/test/jemalloc_test_defs.h.in"
|
||||
|
||||
dnl ============================================================================
|
||||
dnl jemalloc build options.
|
||||
dnl
|
||||
|
||||
dnl Do not compile with debugging by default.
|
||||
AC_ARG_ENABLE([debug],
|
||||
[AS_HELP_STRING([--enable-debug],
|
||||
@ -1462,66 +1526,6 @@ if test "x${LG_PAGE}" != "xundefined" -a \
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([LG_HUGEPAGE], [${je_cv_lg_hugepage}])
|
||||
|
||||
dnl ============================================================================
|
||||
dnl jemalloc configuration.
|
||||
dnl
|
||||
|
||||
AC_ARG_WITH([version],
|
||||
[AS_HELP_STRING([--with-version=<major>.<minor>.<bugfix>-<nrev>-g<gid>],
|
||||
[Version string])],
|
||||
[
|
||||
echo "${with_version}" | grep ['^[0-9]\+\.[0-9]\+\.[0-9]\+-[0-9]\+-g[0-9a-f]\+$'] 2>&1 1>/dev/null
|
||||
if test $? -eq 0 ; then
|
||||
echo "$with_version" > "${objroot}VERSION"
|
||||
else
|
||||
echo "${with_version}" | grep ['^VERSION$'] 2>&1 1>/dev/null
|
||||
if test $? -ne 0 ; then
|
||||
AC_MSG_ERROR([${with_version} does not match <major>.<minor>.<bugfix>-<nrev>-g<gid> or VERSION])
|
||||
fi
|
||||
fi
|
||||
], [
|
||||
dnl Set VERSION if source directory is inside a git repository.
|
||||
if test "x`test ! \"${srcroot}\" && cd \"${srcroot}\"; git rev-parse --is-inside-work-tree 2>/dev/null`" = "xtrue" ; then
|
||||
dnl Pattern globs aren't powerful enough to match both single- and
|
||||
dnl double-digit version numbers, so iterate over patterns to support up
|
||||
dnl to version 99.99.99 without any accidental matches.
|
||||
for pattern in ['[0-9].[0-9].[0-9]' '[0-9].[0-9].[0-9][0-9]' \
|
||||
'[0-9].[0-9][0-9].[0-9]' '[0-9].[0-9][0-9].[0-9][0-9]' \
|
||||
'[0-9][0-9].[0-9].[0-9]' '[0-9][0-9].[0-9].[0-9][0-9]' \
|
||||
'[0-9][0-9].[0-9][0-9].[0-9]' \
|
||||
'[0-9][0-9].[0-9][0-9].[0-9][0-9]']; do
|
||||
(test ! "${srcroot}" && cd "${srcroot}"; git describe --long --abbrev=40 --match="${pattern}") > "${objroot}VERSION.tmp" 2>/dev/null
|
||||
if test $? -eq 0 ; then
|
||||
mv "${objroot}VERSION.tmp" "${objroot}VERSION"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
rm -f "${objroot}VERSION.tmp"
|
||||
])
|
||||
|
||||
if test ! -e "${objroot}VERSION" ; then
|
||||
if test ! -e "${srcroot}VERSION" ; then
|
||||
AC_MSG_RESULT(
|
||||
[Missing VERSION file, and unable to generate it; creating bogus VERSION])
|
||||
echo "0.0.0-0-g0000000000000000000000000000000000000000" > "${objroot}VERSION"
|
||||
else
|
||||
cp ${srcroot}VERSION ${objroot}VERSION
|
||||
fi
|
||||
fi
|
||||
jemalloc_version=`cat "${objroot}VERSION"`
|
||||
jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
|
||||
jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
|
||||
jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
|
||||
jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
|
||||
jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
|
||||
AC_SUBST([jemalloc_version])
|
||||
AC_SUBST([jemalloc_version_major])
|
||||
AC_SUBST([jemalloc_version_minor])
|
||||
AC_SUBST([jemalloc_version_bugfix])
|
||||
AC_SUBST([jemalloc_version_nrev])
|
||||
AC_SUBST([jemalloc_version_gid])
|
||||
|
||||
dnl ============================================================================
|
||||
dnl Configure pthreads.
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#define JEMALLOC_VERSION_BUGFIX @jemalloc_version_bugfix@
|
||||
#define JEMALLOC_VERSION_NREV @jemalloc_version_nrev@
|
||||
#define JEMALLOC_VERSION_GID "@jemalloc_version_gid@"
|
||||
#define JEMALLOC_VERSION_GID_IDENT @jemalloc_version_gid@
|
||||
|
||||
#define MALLOCX_LG_ALIGN(la) ((int)(la))
|
||||
#if LG_SIZEOF_PTR == 2
|
||||
|
@ -1748,8 +1748,7 @@ struct static_opts_s {
|
||||
*/
|
||||
bool slow;
|
||||
/*
|
||||
* Return size
|
||||
*
|
||||
* Return size.
|
||||
*/
|
||||
bool usize;
|
||||
};
|
||||
@ -2770,6 +2769,11 @@ int __posix_memalign(void** r, size_t a, size_t s) PREALIAS(je_posix_memalign);
|
||||
*/
|
||||
|
||||
#ifdef JEMALLOC_EXPERIMENTAL_SMALLOCX_API
|
||||
|
||||
#define JEMALLOC_SMALLOCX_CONCAT_HELPER(x, y) x ## y
|
||||
#define JEMALLOC_SMALLOCX_CONCAT_HELPER2(x, y) \
|
||||
JEMALLOC_SMALLOCX_CONCAT_HELPER(x, y)
|
||||
|
||||
typedef struct {
|
||||
void *ptr;
|
||||
size_t size;
|
||||
@ -2781,7 +2785,8 @@ smallocx_return_t JEMALLOC_NOTHROW
|
||||
* The attribute JEMALLOC_ATTR(malloc) cannot be used due to:
|
||||
* - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86488
|
||||
*/
|
||||
je_smallocx(size_t size, int flags) {
|
||||
JEMALLOC_SMALLOCX_CONCAT_HELPER2(je_smallocx_, JEMALLOC_VERSION_GID_IDENT)
|
||||
(size_t size, int flags) {
|
||||
/*
|
||||
* Note: the attribute JEMALLOC_ALLOC_SIZE(1) cannot be
|
||||
* used here because it makes writing beyond the `size`
|
||||
@ -2828,8 +2833,6 @@ smallocx_return_t JEMALLOC_NOTHROW
|
||||
dopts.arena_ind = MALLOCX_ARENA_GET(flags);
|
||||
}
|
||||
|
||||
|
||||
|
||||
imalloc(&sopts, &dopts);
|
||||
assert(dopts.usize == je_nallocx(size, flags));
|
||||
ret.size = dopts.usize;
|
||||
@ -2837,6 +2840,8 @@ smallocx_return_t JEMALLOC_NOTHROW
|
||||
LOG("core.smallocx.exit", "result: %p, size: %zu", ret.ptr, ret.size);
|
||||
return ret;
|
||||
}
|
||||
#undef JEMALLOC_SMALLOCX_CONCAT_HELPER
|
||||
#undef JEMALLOC_SMALLOCX_CONCAT_HELPER2
|
||||
#endif
|
||||
|
||||
JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
|
||||
|
@ -1,11 +1,24 @@
|
||||
#include "test/jemalloc_test.h"
|
||||
#include "jemalloc/jemalloc_macros.h"
|
||||
|
||||
#define STR_HELPER(x) #x
|
||||
#define STR(x) STR_HELPER(x)
|
||||
|
||||
#ifndef JEMALLOC_VERSION_GID_IDENT
|
||||
#error "JEMALLOC_VERSION_GID_IDENT not defined"
|
||||
#endif
|
||||
|
||||
#define JOIN(x, y) x ## y
|
||||
#define JOIN2(x, y) JOIN(x, y)
|
||||
#define smallocx JOIN2(smallocx_, JEMALLOC_VERSION_GID_IDENT)
|
||||
|
||||
typedef struct {
|
||||
void *ptr;
|
||||
size_t size;
|
||||
} smallocx_return_t;
|
||||
|
||||
extern smallocx_return_t smallocx(size_t size, int flags);
|
||||
extern smallocx_return_t
|
||||
smallocx(size_t size, int flags);
|
||||
|
||||
static unsigned
|
||||
get_nsizes_impl(const char *cmd) {
|
||||
@ -99,11 +112,11 @@ remote_alloc(void *arg) {
|
||||
assert_d_eq(mallctl("arenas.lextent.0.size", (void *)&large_sz, &sz,
|
||||
NULL, 0), 0, "Unexpected mallctl failure");
|
||||
|
||||
smallocx_return_t r = smallocx(large_sz, MALLOCX_ARENA(arena)
|
||||
| MALLOCX_TCACHE_NONE);
|
||||
smallocx_return_t r
|
||||
= smallocx(large_sz, MALLOCX_ARENA(arena) | MALLOCX_TCACHE_NONE);
|
||||
void *ptr = r.ptr;
|
||||
assert_zu_eq(r.size, nallocx(large_sz, MALLOCX_ARENA(arena)
|
||||
| MALLOCX_TCACHE_NONE),
|
||||
assert_zu_eq(r.size,
|
||||
nallocx(large_sz, MALLOCX_ARENA(arena) | MALLOCX_TCACHE_NONE),
|
||||
"Expected smalloc(size,flags).size == nallocx(size,flags)");
|
||||
void **ret = (void **)arg;
|
||||
*ret = ptr;
|
||||
@ -247,8 +260,8 @@ TEST_BEGIN(test_alignment_and_size) {
|
||||
assert_zu_ne(nsz, 0,
|
||||
"nallocx() error for alignment=%zu, "
|
||||
"size=%zu (%#zx)", alignment, sz, sz);
|
||||
smallocx_return_t ret = smallocx(sz, MALLOCX_ALIGN(alignment) |
|
||||
MALLOCX_ZERO);
|
||||
smallocx_return_t ret
|
||||
= smallocx(sz, MALLOCX_ALIGN(alignment) | MALLOCX_ZERO);
|
||||
ps[i] = ret.ptr;
|
||||
assert_ptr_not_null(ps[i],
|
||||
"smallocx() error for alignment=%zu, "
|
||||
|
Loading…
Reference in New Issue
Block a user