2 dnl Copyright (C) 2020-2021 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_FUNC_MEMALIGN],
9 AC_REQUIRE([gl_MALLOC_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
12 AC_CHECK_FUNCS_ONCE([memalign])
13 if test $ac_cv_func_memalign = yes; then
14 dnl On Solaris 11, memalign (2, n) always returns NULL.
15 AC_CACHE_CHECK([whether memalign works for small alignments],
16 [gl_cv_func_memalign_works],
23 if (memalign (1, 1) == NULL)
25 if (memalign (2, 1) == NULL)
30 [gl_cv_func_memalign_works=yes],
31 [gl_cv_func_memalign_works=no],
33 # Guess no on Solaris.
34 solaris*) gl_cv_func_memalign_works="guessing no" ;;
35 # If we don't know, obey --enable-cross-guesses.
36 *) gl_cv_func_memalign_works="$gl_cross_guess_normal" ;;
40 case "$gl_cv_func_memalign_works" in
42 *) REPLACE_MEMALIGN=1 ;;
45 dnl The system does not have memalign.