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
|
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 Platform-specific settings. abi and RPATH can probably be determined
|
||||||
dnl programmatically, but doing so is error-prone, which makes it generally
|
dnl programmatically, but doing so is error-prone, which makes it generally
|
||||||
dnl not worth the trouble.
|
dnl not worth the trouble.
|
||||||
@ -850,7 +910,7 @@ AC_ARG_WITH([export],
|
|||||||
fi]
|
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.
|
dnl Check for additional platform-specific public API functions.
|
||||||
AC_CHECK_FUNC([memalign],
|
AC_CHECK_FUNC([memalign],
|
||||||
[AC_DEFINE([JEMALLOC_OVERRIDE_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} 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"
|
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.
|
dnl Do not compile with debugging by default.
|
||||||
AC_ARG_ENABLE([debug],
|
AC_ARG_ENABLE([debug],
|
||||||
[AS_HELP_STRING([--enable-debug],
|
[AS_HELP_STRING([--enable-debug],
|
||||||
@ -1462,66 +1526,6 @@ if test "x${LG_PAGE}" != "xundefined" -a \
|
|||||||
fi
|
fi
|
||||||
AC_DEFINE_UNQUOTED([LG_HUGEPAGE], [${je_cv_lg_hugepage}])
|
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 ============================================================================
|
||||||
dnl Configure pthreads.
|
dnl Configure pthreads.
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#define JEMALLOC_VERSION_BUGFIX @jemalloc_version_bugfix@
|
#define JEMALLOC_VERSION_BUGFIX @jemalloc_version_bugfix@
|
||||||
#define JEMALLOC_VERSION_NREV @jemalloc_version_nrev@
|
#define JEMALLOC_VERSION_NREV @jemalloc_version_nrev@
|
||||||
#define JEMALLOC_VERSION_GID "@jemalloc_version_gid@"
|
#define JEMALLOC_VERSION_GID "@jemalloc_version_gid@"
|
||||||
|
#define JEMALLOC_VERSION_GID_IDENT @jemalloc_version_gid@
|
||||||
|
|
||||||
#define MALLOCX_LG_ALIGN(la) ((int)(la))
|
#define MALLOCX_LG_ALIGN(la) ((int)(la))
|
||||||
#if LG_SIZEOF_PTR == 2
|
#if LG_SIZEOF_PTR == 2
|
||||||
|
@ -1748,8 +1748,7 @@ struct static_opts_s {
|
|||||||
*/
|
*/
|
||||||
bool slow;
|
bool slow;
|
||||||
/*
|
/*
|
||||||
* Return size
|
* Return size.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
bool usize;
|
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
|
#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 {
|
typedef struct {
|
||||||
void *ptr;
|
void *ptr;
|
||||||
size_t size;
|
size_t size;
|
||||||
@ -2781,7 +2785,8 @@ smallocx_return_t JEMALLOC_NOTHROW
|
|||||||
* The attribute JEMALLOC_ATTR(malloc) cannot be used due to:
|
* The attribute JEMALLOC_ATTR(malloc) cannot be used due to:
|
||||||
* - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86488
|
* - 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
|
* Note: the attribute JEMALLOC_ALLOC_SIZE(1) cannot be
|
||||||
* used here because it makes writing beyond the `size`
|
* 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);
|
dopts.arena_ind = MALLOCX_ARENA_GET(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
imalloc(&sopts, &dopts);
|
imalloc(&sopts, &dopts);
|
||||||
assert(dopts.usize == je_nallocx(size, flags));
|
assert(dopts.usize == je_nallocx(size, flags));
|
||||||
ret.size = dopts.usize;
|
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);
|
LOG("core.smallocx.exit", "result: %p, size: %zu", ret.ptr, ret.size);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#undef JEMALLOC_SMALLOCX_CONCAT_HELPER
|
||||||
|
#undef JEMALLOC_SMALLOCX_CONCAT_HELPER2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
|
JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
|
||||||
|
@ -1,11 +1,24 @@
|
|||||||
#include "test/jemalloc_test.h"
|
#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 {
|
typedef struct {
|
||||||
void *ptr;
|
void *ptr;
|
||||||
size_t size;
|
size_t size;
|
||||||
} smallocx_return_t;
|
} 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
|
static unsigned
|
||||||
get_nsizes_impl(const char *cmd) {
|
get_nsizes_impl(const char *cmd) {
|
||||||
@ -99,12 +112,12 @@ remote_alloc(void *arg) {
|
|||||||
assert_d_eq(mallctl("arenas.lextent.0.size", (void *)&large_sz, &sz,
|
assert_d_eq(mallctl("arenas.lextent.0.size", (void *)&large_sz, &sz,
|
||||||
NULL, 0), 0, "Unexpected mallctl failure");
|
NULL, 0), 0, "Unexpected mallctl failure");
|
||||||
|
|
||||||
smallocx_return_t r = smallocx(large_sz, MALLOCX_ARENA(arena)
|
smallocx_return_t r
|
||||||
| MALLOCX_TCACHE_NONE);
|
= smallocx(large_sz, MALLOCX_ARENA(arena) | MALLOCX_TCACHE_NONE);
|
||||||
void *ptr = r.ptr;
|
void *ptr = r.ptr;
|
||||||
assert_zu_eq(r.size, nallocx(large_sz, MALLOCX_ARENA(arena)
|
assert_zu_eq(r.size,
|
||||||
| MALLOCX_TCACHE_NONE),
|
nallocx(large_sz, MALLOCX_ARENA(arena) | MALLOCX_TCACHE_NONE),
|
||||||
"Expected smalloc(size,flags).size == nallocx(size,flags)");
|
"Expected smalloc(size,flags).size == nallocx(size,flags)");
|
||||||
void **ret = (void **)arg;
|
void **ret = (void **)arg;
|
||||||
*ret = ptr;
|
*ret = ptr;
|
||||||
|
|
||||||
@ -174,40 +187,40 @@ TEST_BEGIN(test_basic) {
|
|||||||
size_t sz;
|
size_t sz;
|
||||||
|
|
||||||
for (sz = 1; sz < MAXSZ; sz = nallocx(sz, 0) + 1) {
|
for (sz = 1; sz < MAXSZ; sz = nallocx(sz, 0) + 1) {
|
||||||
smallocx_return_t ret;
|
smallocx_return_t ret;
|
||||||
size_t nsz, rsz, smz;
|
size_t nsz, rsz, smz;
|
||||||
void *p;
|
void *p;
|
||||||
nsz = nallocx(sz, 0);
|
nsz = nallocx(sz, 0);
|
||||||
assert_zu_ne(nsz, 0, "Unexpected nallocx() error");
|
assert_zu_ne(nsz, 0, "Unexpected nallocx() error");
|
||||||
ret = smallocx(sz, 0);
|
ret = smallocx(sz, 0);
|
||||||
p = ret.ptr;
|
p = ret.ptr;
|
||||||
smz = ret.size;
|
smz = ret.size;
|
||||||
assert_ptr_not_null(p,
|
assert_ptr_not_null(p,
|
||||||
"Unexpected smallocx(size=%zx, flags=0) error", sz);
|
"Unexpected smallocx(size=%zx, flags=0) error", sz);
|
||||||
rsz = sallocx(p, 0);
|
rsz = sallocx(p, 0);
|
||||||
assert_zu_ge(rsz, sz, "Real size smaller than expected");
|
assert_zu_ge(rsz, sz, "Real size smaller than expected");
|
||||||
assert_zu_eq(nsz, rsz, "nallocx()/sallocx() size mismatch");
|
assert_zu_eq(nsz, rsz, "nallocx()/sallocx() size mismatch");
|
||||||
assert_zu_eq(nsz, smz, "nallocx()/smallocx() size mismatch");
|
assert_zu_eq(nsz, smz, "nallocx()/smallocx() size mismatch");
|
||||||
dallocx(p, 0);
|
dallocx(p, 0);
|
||||||
|
|
||||||
ret = smallocx(sz, 0);
|
ret = smallocx(sz, 0);
|
||||||
p = ret.ptr;
|
p = ret.ptr;
|
||||||
smz = ret.size;
|
smz = ret.size;
|
||||||
assert_ptr_not_null(p,
|
assert_ptr_not_null(p,
|
||||||
"Unexpected smallocx(size=%zx, flags=0) error", sz);
|
"Unexpected smallocx(size=%zx, flags=0) error", sz);
|
||||||
dallocx(p, 0);
|
dallocx(p, 0);
|
||||||
|
|
||||||
nsz = nallocx(sz, MALLOCX_ZERO);
|
nsz = nallocx(sz, MALLOCX_ZERO);
|
||||||
assert_zu_ne(nsz, 0, "Unexpected nallocx() error");
|
assert_zu_ne(nsz, 0, "Unexpected nallocx() error");
|
||||||
assert_zu_ne(smz, 0, "Unexpected smallocx() error");
|
assert_zu_ne(smz, 0, "Unexpected smallocx() error");
|
||||||
ret = smallocx(sz, MALLOCX_ZERO);
|
ret = smallocx(sz, MALLOCX_ZERO);
|
||||||
p = ret.ptr;
|
p = ret.ptr;
|
||||||
assert_ptr_not_null(p,
|
assert_ptr_not_null(p,
|
||||||
"Unexpected smallocx(size=%zx, flags=MALLOCX_ZERO) error",
|
"Unexpected smallocx(size=%zx, flags=MALLOCX_ZERO) error",
|
||||||
nsz);
|
nsz);
|
||||||
rsz = sallocx(p, 0);
|
rsz = sallocx(p, 0);
|
||||||
assert_zu_eq(nsz, rsz, "nallocx()/sallocx() rsize mismatch");
|
assert_zu_eq(nsz, rsz, "nallocx()/sallocx() rsize mismatch");
|
||||||
assert_zu_eq(nsz, smz, "nallocx()/smallocx() size mismatch");
|
assert_zu_eq(nsz, smz, "nallocx()/smallocx() size mismatch");
|
||||||
dallocx(p, 0);
|
dallocx(p, 0);
|
||||||
purge();
|
purge();
|
||||||
}
|
}
|
||||||
@ -247,23 +260,23 @@ TEST_BEGIN(test_alignment_and_size) {
|
|||||||
assert_zu_ne(nsz, 0,
|
assert_zu_ne(nsz, 0,
|
||||||
"nallocx() error for alignment=%zu, "
|
"nallocx() error for alignment=%zu, "
|
||||||
"size=%zu (%#zx)", alignment, sz, sz);
|
"size=%zu (%#zx)", alignment, sz, sz);
|
||||||
smallocx_return_t ret = smallocx(sz, MALLOCX_ALIGN(alignment) |
|
smallocx_return_t ret
|
||||||
MALLOCX_ZERO);
|
= smallocx(sz, MALLOCX_ALIGN(alignment) | MALLOCX_ZERO);
|
||||||
ps[i] = ret.ptr;
|
ps[i] = ret.ptr;
|
||||||
assert_ptr_not_null(ps[i],
|
assert_ptr_not_null(ps[i],
|
||||||
"smallocx() error for alignment=%zu, "
|
"smallocx() error for alignment=%zu, "
|
||||||
"size=%zu (%#zx)", alignment, sz, sz);
|
"size=%zu (%#zx)", alignment, sz, sz);
|
||||||
rsz = sallocx(ps[i], 0);
|
rsz = sallocx(ps[i], 0);
|
||||||
smz = ret.size;
|
smz = ret.size;
|
||||||
assert_zu_ge(rsz, sz,
|
assert_zu_ge(rsz, sz,
|
||||||
"Real size smaller than expected for "
|
"Real size smaller than expected for "
|
||||||
"alignment=%zu, size=%zu", alignment, sz);
|
"alignment=%zu, size=%zu", alignment, sz);
|
||||||
assert_zu_eq(nsz, rsz,
|
assert_zu_eq(nsz, rsz,
|
||||||
"nallocx()/sallocx() size mismatch for "
|
"nallocx()/sallocx() size mismatch for "
|
||||||
"alignment=%zu, size=%zu", alignment, sz);
|
"alignment=%zu, size=%zu", alignment, sz);
|
||||||
assert_zu_eq(nsz, smz,
|
assert_zu_eq(nsz, smz,
|
||||||
"nallocx()/smallocx() size mismatch for "
|
"nallocx()/smallocx() size mismatch for "
|
||||||
"alignment=%zu, size=%zu", alignment, sz);
|
"alignment=%zu, size=%zu", alignment, sz);
|
||||||
assert_ptr_null(
|
assert_ptr_null(
|
||||||
(void *)((uintptr_t)ps[i] & (alignment-1)),
|
(void *)((uintptr_t)ps[i] & (alignment-1)),
|
||||||
"%p inadequately aligned for"
|
"%p inadequately aligned for"
|
||||||
|
Loading…
Reference in New Issue
Block a user