mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-22 04:03:11 +00:00
Refactor LG_VADDR detection in configure.ac
The LG_VADDR detection block accumulated duplicated logic and the rdtscp feature probe was interleaved with virtual-address-bit detection. Consolidate the detection: - Wrap the whole case in a single "if LG_VADDR = detect" guard instead of repeating it in every "case" section. - Define LG_VADDR exactly once, after the case. - Check the cache variable directly for the x86_64 error path. - Move the rdtscp probe into its own x86_64 case so it stays independent of LG_VADDR detection (it must run even when --with-lg-vaddr is given). There is no functional change. Verified on x86_64 that LG_VADDR and JEMALLOC_HAVE_RDTSCP are identical to before for auto-detection, and that --with-lg-vaddr still probes rdtscp.
This commit is contained in:
committed by
Guangli Dai
parent
68c35f6557
commit
b44e84086f
56
configure.ac
56
configure.ac
@@ -533,13 +533,14 @@ esac
|
|||||||
AC_DEFINE_UNQUOTED([HAVE_CPU_SPINWAIT], [$HAVE_CPU_SPINWAIT], [ ])
|
AC_DEFINE_UNQUOTED([HAVE_CPU_SPINWAIT], [$HAVE_CPU_SPINWAIT], [ ])
|
||||||
AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT], [ ])
|
AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT], [ ])
|
||||||
|
|
||||||
|
dnl LG_VADDR: number of significant virtual address bits. Auto-detected when --with-lg-vaddr is left unset.
|
||||||
AC_ARG_WITH([lg_vaddr],
|
AC_ARG_WITH([lg_vaddr],
|
||||||
[AS_HELP_STRING([--with-lg-vaddr=<lg-vaddr>], [Number of significant virtual address bits])],
|
[AS_HELP_STRING([--with-lg-vaddr=<lg-vaddr>], [Number of significant virtual address bits])],
|
||||||
[LG_VADDR="$with_lg_vaddr"], [LG_VADDR="detect"])
|
[LG_VADDR="$with_lg_vaddr"], [LG_VADDR="detect"])
|
||||||
|
|
||||||
case "${host_cpu}" in
|
if test "x$LG_VADDR" = "xdetect"; then
|
||||||
aarch64)
|
case "${host_cpu}" in
|
||||||
if test "x$LG_VADDR" = "xdetect"; then
|
aarch64)
|
||||||
AC_MSG_CHECKING([number of significant virtual address bits])
|
AC_MSG_CHECKING([number of significant virtual address bits])
|
||||||
if test "x${LG_SIZEOF_PTR}" = "x2" ; then
|
if test "x${LG_SIZEOF_PTR}" = "x2" ; then
|
||||||
#aarch64 ILP32
|
#aarch64 ILP32
|
||||||
@@ -549,10 +550,8 @@ case "${host_cpu}" in
|
|||||||
LG_VADDR=48
|
LG_VADDR=48
|
||||||
fi
|
fi
|
||||||
AC_MSG_RESULT([$LG_VADDR])
|
AC_MSG_RESULT([$LG_VADDR])
|
||||||
fi
|
;;
|
||||||
;;
|
x86_64)
|
||||||
x86_64)
|
|
||||||
if test "x$LG_VADDR" = "xdetect"; then
|
|
||||||
AC_CACHE_CHECK([number of significant virtual address bits],
|
AC_CACHE_CHECK([number of significant virtual address bits],
|
||||||
[je_cv_lg_vaddr],
|
[je_cv_lg_vaddr],
|
||||||
AC_RUN_IFELSE([AC_LANG_PROGRAM(
|
AC_RUN_IFELSE([AC_LANG_PROGRAM(
|
||||||
@@ -592,15 +591,33 @@ typedef unsigned __int32 uint32_t;
|
|||||||
[je_cv_lg_vaddr=`cat conftest.out`],
|
[je_cv_lg_vaddr=`cat conftest.out`],
|
||||||
[je_cv_lg_vaddr=error],
|
[je_cv_lg_vaddr=error],
|
||||||
[je_cv_lg_vaddr=57]))
|
[je_cv_lg_vaddr=57]))
|
||||||
|
if test "x${je_cv_lg_vaddr}" = "xerror" ; then
|
||||||
|
AC_MSG_ERROR([cannot determine number of significant virtual address bits])
|
||||||
|
fi
|
||||||
if test "x${je_cv_lg_vaddr}" != "x" ; then
|
if test "x${je_cv_lg_vaddr}" != "x" ; then
|
||||||
LG_VADDR="${je_cv_lg_vaddr}"
|
LG_VADDR="${je_cv_lg_vaddr}"
|
||||||
fi
|
fi
|
||||||
if test "x${LG_VADDR}" != "xerror" ; then
|
;;
|
||||||
AC_DEFINE_UNQUOTED([LG_VADDR], [$LG_VADDR], [ ])
|
*)
|
||||||
|
AC_MSG_CHECKING([number of significant virtual address bits])
|
||||||
|
if test "x${LG_SIZEOF_PTR}" = "x3" ; then
|
||||||
|
LG_VADDR=64
|
||||||
|
elif test "x${LG_SIZEOF_PTR}" = "x2" ; then
|
||||||
|
LG_VADDR=32
|
||||||
|
elif test "x${LG_SIZEOF_PTR}" = "xLG_SIZEOF_PTR_WIN" ; then
|
||||||
|
LG_VADDR="(1U << (LG_SIZEOF_PTR_WIN+3))"
|
||||||
else
|
else
|
||||||
AC_MSG_ERROR([cannot determine number of significant virtual address bits])
|
AC_MSG_ERROR([Unsupported lg(pointer size): ${LG_SIZEOF_PTR}])
|
||||||
fi
|
fi
|
||||||
fi
|
AC_MSG_RESULT([$LG_VADDR])
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
AC_DEFINE_UNQUOTED([LG_VADDR], [$LG_VADDR], [ ])
|
||||||
|
|
||||||
|
dnl rdtscp feature probe for x86_64
|
||||||
|
case "${host_cpu}" in
|
||||||
|
x86_64)
|
||||||
AC_CACHE_CHECK([rdtscp support],
|
AC_CACHE_CHECK([rdtscp support],
|
||||||
[je_cv_rdtscp],
|
[je_cv_rdtscp],
|
||||||
AC_RUN_IFELSE([AC_LANG_PROGRAM(
|
AC_RUN_IFELSE([AC_LANG_PROGRAM(
|
||||||
@@ -619,23 +636,8 @@ typedef unsigned __int32 uint32_t;
|
|||||||
AC_DEFINE([JEMALLOC_HAVE_RDTSCP], [ ], [ ])
|
AC_DEFINE([JEMALLOC_HAVE_RDTSCP], [ ], [ ])
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
|
||||||
if test "x$LG_VADDR" = "xdetect"; then
|
|
||||||
AC_MSG_CHECKING([number of significant virtual address bits])
|
|
||||||
if test "x${LG_SIZEOF_PTR}" = "x3" ; then
|
|
||||||
LG_VADDR=64
|
|
||||||
elif test "x${LG_SIZEOF_PTR}" = "x2" ; then
|
|
||||||
LG_VADDR=32
|
|
||||||
elif test "x${LG_SIZEOF_PTR}" = "xLG_SIZEOF_PTR_WIN" ; then
|
|
||||||
LG_VADDR="(1U << (LG_SIZEOF_PTR_WIN+3))"
|
|
||||||
else
|
|
||||||
AC_MSG_ERROR([Unsupported lg(pointer size): ${LG_SIZEOF_PTR}])
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT([$LG_VADDR])
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
AC_DEFINE_UNQUOTED([LG_VADDR], [$LG_VADDR], [ ])
|
|
||||||
AC_CACHE_CHECK([asm volatile support],
|
AC_CACHE_CHECK([asm volatile support],
|
||||||
[je_cv_asm_volatile],
|
[je_cv_asm_volatile],
|
||||||
AC_RUN_IFELSE([AC_LANG_PROGRAM(
|
AC_RUN_IFELSE([AC_LANG_PROGRAM(
|
||||||
|
|||||||
Reference in New Issue
Block a user