Commit 8040e28b authored by Luca Boccassi's avatar Luca Boccassi

Problem: posix_memalign autoconf check broken on some platforms

Solution: import macro from autoconf-archive that works better
than AC_CHECK_FUNCS
parent 4a0c83fb
...@@ -19,6 +19,7 @@ m4_include([m4/ax_cxx_compile_stdcxx_11.m4]) ...@@ -19,6 +19,7 @@ m4_include([m4/ax_cxx_compile_stdcxx_11.m4])
m4_include([m4/ax_code_coverage.m4]) m4_include([m4/ax_code_coverage.m4])
m4_include([m4/ax_valgrind_check.m4]) m4_include([m4/ax_valgrind_check.m4])
m4_include([m4/ax_check_vscript.m4]) m4_include([m4/ax_check_vscript.m4])
m4_include([m4/ax_func_posix_memalign.m4])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
# This lets us use PACKAGE_VERSION in Makefiles # This lets us use PACKAGE_VERSION in Makefiles
...@@ -78,6 +79,7 @@ AC_LIBTOOL_WIN32_DLL ...@@ -78,6 +79,7 @@ AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL AC_PROG_LIBTOOL
AX_VALGRIND_CHECK AX_VALGRIND_CHECK
AX_CHECK_VSCRIPT AX_CHECK_VSCRIPT
AX_FUNC_POSIX_MEMALIGN
AC_ARG_ENABLE([force-CXX98-compat], AC_ARG_ENABLE([force-CXX98-compat],
[AS_HELP_STRING([--enable-force-CXX98-compat], [force C++98 build [default=disabled]])]) [AS_HELP_STRING([--enable-force-CXX98-compat], [force C++98 build [default=disabled]])])
...@@ -670,7 +672,7 @@ AC_LANG_POP([C++]) ...@@ -670,7 +672,7 @@ AC_LANG_POP([C++])
# Checks for library functions. # Checks for library functions.
AC_TYPE_SIGNAL AC_TYPE_SIGNAL
AC_CHECK_FUNCS(perror gettimeofday clock_gettime memset socket getifaddrs freeifaddrs fork posix_memalign mkdtemp accept4) AC_CHECK_FUNCS(perror gettimeofday clock_gettime memset socket getifaddrs freeifaddrs fork mkdtemp accept4)
AC_CHECK_HEADERS([alloca.h]) AC_CHECK_HEADERS([alloca.h])
# pthread_setname is non-posix, and there are at least 4 different implementations # pthread_setname is non-posix, and there are at least 4 different implementations
......
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_func_posix_memalign.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_FUNC_POSIX_MEMALIGN
#
# DESCRIPTION
#
# Some versions of posix_memalign (notably glibc 2.2.5) incorrectly apply
# their power-of-two check to the size argument, not the alignment
# argument. AX_FUNC_POSIX_MEMALIGN defines HAVE_POSIX_MEMALIGN if the
# power-of-two check is correctly applied to the alignment argument.
#
# LICENSE
#
# Copyright (c) 2008 Scott Pakin <pakin@uiuc.edu>
#
# 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 9
AC_DEFUN([AX_FUNC_POSIX_MEMALIGN],
[AC_CACHE_CHECK([for working posix_memalign],
[ax_cv_func_posix_memalign_works],
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdlib.h>
int
main ()
{
void *buffer;
/* Some versions of glibc incorrectly perform the alignment check on
* the size word. */
exit (posix_memalign (&buffer, sizeof(void *), 123) != 0);
}
]])],
[ax_cv_func_posix_memalign_works=yes],
[ax_cv_func_posix_memalign_works=no],
[ax_cv_func_posix_memalign_works=no])])
if test "$ax_cv_func_posix_memalign_works" = "yes" ; then
AC_DEFINE([HAVE_POSIX_MEMALIGN], [1],
[Define to 1 if `posix_memalign' works.])
fi
])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment