2021-06-03 08:37:05 +02:00
|
|
|
# SPDX-License-Identifier: FSFAP
|
|
|
|
#
|
Use system allocator when jemalloc is unavailable
This commit adds support for systems where the jemalloc library is not
available as a package, here's the quick summary:
* On Linux - the jemalloc is usually available as a package, if
configured --without-jemalloc, the shim would be used around
malloc(), free(), realloc() and malloc_usable_size()
* On macOS - the jemalloc is available from homebrew or macports, if
configured --without-jemalloc, the shim would be used around
malloc(), free(), realloc() and malloc_size()
* On FreeBSD - the jemalloc is *the* system allocator, we just need
to check for <malloc_np.h> header to get access to non-standard API
* On NetBSD - the jemalloc is *the* system allocator, we just need to
check for <jemalloc/jemalloc.h> header to get access to non-standard
API
* On a system hostile to users and developers (read OpenBSD) - the
jemalloc API is emulated by using ((size_t *)ptr)[-1] field to hold
the size information. The OpenBSD developers care only for
themselves, so why should we care about speed on OpenBSD?
2021-05-25 12:46:00 +02:00
|
|
|
# ===========================================================================
|
|
|
|
# https://gitlab.isc.org/isc-projects/autoconf-archive/ax_jemalloc.html
|
|
|
|
# ===========================================================================
|
|
|
|
#
|
|
|
|
# SYNOPSIS
|
|
|
|
#
|
|
|
|
# AX_CHECK_JEMALLOC([, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
|
|
|
#
|
|
|
|
# DESCRIPTION
|
|
|
|
#
|
|
|
|
# Test for the jemalloc library in a path
|
|
|
|
#
|
|
|
|
# LICENSE
|
|
|
|
#
|
|
|
|
# Copyright (c) 2021 Internet Systems Consortium
|
|
|
|
#
|
|
|
|
# Copying and distribution of this file, with or without modification, are
|
|
|
|
# permitted in any medium without royalty provided the copyright notice
|
|
|
|
# and this notice are preserved. This file is offered as-is, without any
|
|
|
|
# warranty.
|
|
|
|
|
|
|
|
#serial 1
|
|
|
|
|
|
|
|
#
|
|
|
|
AC_DEFUN([AX_CHECK_JEMALLOC], [
|
|
|
|
found=false
|
|
|
|
PKG_CHECK_MODULES(
|
|
|
|
[JEMALLOC], [jemalloc],
|
|
|
|
[
|
|
|
|
found=true
|
|
|
|
], [
|
|
|
|
AC_CHECK_HEADERS([malloc_np.h jemalloc/jemalloc.h],
|
|
|
|
[
|
|
|
|
save_LIBS="$LIBS"
|
|
|
|
save_LDFLAGS="$LDFLAGS"
|
|
|
|
save_CPPFLAGS="$CPPFLAGS"
|
|
|
|
AC_SEARCH_LIBS([mallocx], [jemalloc],
|
|
|
|
[
|
|
|
|
found=true
|
|
|
|
AS_IF([test "$ac_cv_search_mallocx" != "none required"],
|
|
|
|
[JEMALLOC_LIBS="$ac_cv_search_mallocx"])
|
|
|
|
])
|
|
|
|
CPPFLAGS="$save_CPPFLAGS"
|
|
|
|
LDFLAGS="$save_LDFLAGS"
|
|
|
|
LIBS="$save_LIBS"
|
|
|
|
])
|
|
|
|
])
|
|
|
|
|
|
|
|
AS_IF([$found], [$1], [$2])
|
|
|
|
|
|
|
|
AC_SUBST([JEMALLOC_CFLAGS])
|
|
|
|
AC_SUBST([JEMALLOC_LIBS])
|
|
|
|
])
|