0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00

Fix mallopt configure checks

Some systems do have malloc.h but don't have mallopt.
This commit is contained in:
Maria Matejka 2024-12-16 09:50:20 +01:00
parent d373d48377
commit b67db7c97d
3 changed files with 33 additions and 5 deletions

24
aclocal.m4 vendored
View File

@ -86,6 +86,30 @@ AC_DEFUN([BIRD_CHECK_PTHREADS],
CFLAGS="$bird_tmp_cflags" CFLAGS="$bird_tmp_cflags"
]) ])
AC_DEFUN([BIRD_CHECK_MALLOPT],
[
AC_CACHE_CHECK(
[for mallopt],
[bird_cv_mallopt],
[
AC_COMPILE_IFELSE(
[
AC_LANG_PROGRAM(
[
#include <malloc.h>
],
[
mallopt(M_ARENA_MAX, 1);
]
)
],
[bird_cv_mallopt=yes],
[bird_cv_mallopt=no]
)
]
)
])
AC_DEFUN([BIRD_CHECK_MPLS_KERNEL], AC_DEFUN([BIRD_CHECK_MPLS_KERNEL],
[ [
AC_CACHE_CHECK( AC_CACHE_CHECK(

View File

@ -371,13 +371,17 @@ esac
AC_CHECK_HEADERS_ONCE([alloca.h syslog.h stdatomic.h]) 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_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_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 <sys/socket.h>])
if test "$have_aligned_alloc" = "no" && test "$have_mman" = "no" ; then 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().]) AC_MSG_ERROR([No means of aligned alloc found. Need mmap() or aligned_alloc().])
fi 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 <sys/socket.h>])
AC_C_BIGENDIAN( AC_C_BIGENDIAN(
[AC_DEFINE([CPU_BIG_ENDIAN], [1], [Define to 1 if cpu is big endian])], [AC_DEFINE([CPU_BIG_ENDIAN], [1], [Define to 1 if cpu is big endian])],

View File

@ -18,7 +18,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#ifdef HAVE_MALLOC_H #ifdef HAVE_MALLOPT
# include <malloc.h> # include <malloc.h>
#endif #endif
@ -505,7 +505,7 @@ page_dump(struct dump_request *dreq)
void void
resource_sys_init(void) resource_sys_init(void)
{ {
#ifdef HAVE_MALLOC_H #ifdef HAVE_MALLOPT
if (!mallopt(M_ARENA_MAX, 1)) if (!mallopt(M_ARENA_MAX, 1))
log(L_WARN "Failed to disable multiple malloc arenas, memory consumption may skyrocket."); log(L_WARN "Failed to disable multiple malloc arenas, memory consumption may skyrocket.");
#endif #endif