diff --git a/aclocal.m4 b/aclocal.m4 index 48285b21..89392505 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -86,6 +86,30 @@ AC_DEFUN([BIRD_CHECK_PTHREADS], CFLAGS="$bird_tmp_cflags" ]) +AC_DEFUN([BIRD_CHECK_MALLOPT], +[ + AC_CACHE_CHECK( + [for mallopt], + [bird_cv_mallopt], + [ + AC_COMPILE_IFELSE( + [ + AC_LANG_PROGRAM( + [ + #include + ], + [ + mallopt(M_ARENA_MAX, 1); + ] + ) + ], + [bird_cv_mallopt=yes], + [bird_cv_mallopt=no] + ) + ] + ) +]) + AC_DEFUN([BIRD_CHECK_MPLS_KERNEL], [ AC_CACHE_CHECK( diff --git a/configure.ac b/configure.ac index a9919452..ae7b9467 100644 --- a/configure.ac +++ b/configure.ac @@ -371,13 +371,17 @@ esac AC_CHECK_HEADERS_ONCE([alloca.h syslog.h stdatomic.h]) AC_CHECK_HEADER([sys/mman.h], [AC_DEFINE([HAVE_MMAP], [1], [Define to 1 if mmap() is available.])], have_mman=no) AC_CHECK_FUNC([aligned_alloc], [AC_DEFINE([HAVE_ALIGNED_ALLOC], [1], [Define to 1 if aligned_alloc() is available.])], have_aligned_alloc=no) -AC_CHECK_HEADER([malloc.h], [AC_DEFINE([HAVE_MALLOC_H], [1], [Define to 1 if malloc.h is available.])], have_malloc_h=no) -AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [], [#include ]) - if test "$have_aligned_alloc" = "no" && test "$have_mman" = "no" ; then AC_MSG_ERROR([No means of aligned alloc found. Need mmap() or aligned_alloc().]) fi +BIRD_CHECK_MALLOPT +if test "$bird_cv_mallopt" = "yes" ; then + AC_DEFINE([HAVE_MALLOPT], [1], [Define to 1 if mallopt() is available.]) +fi + +AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [], [#include ]) + AC_C_BIGENDIAN( [AC_DEFINE([CPU_BIG_ENDIAN], [1], [Define to 1 if cpu is big endian])], diff --git a/sysdep/unix/alloc.c b/sysdep/unix/alloc.c index 74618dfb..fcf85508 100644 --- a/sysdep/unix/alloc.c +++ b/sysdep/unix/alloc.c @@ -18,7 +18,7 @@ #include #include -#ifdef HAVE_MALLOC_H +#ifdef HAVE_MALLOPT # include #endif @@ -505,7 +505,7 @@ page_dump(struct dump_request *dreq) void resource_sys_init(void) { -#ifdef HAVE_MALLOC_H +#ifdef HAVE_MALLOPT if (!mallopt(M_ARENA_MAX, 1)) log(L_WARN "Failed to disable multiple malloc arenas, memory consumption may skyrocket."); #endif