1 # aligned_alloc.m4 serial 2
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_ALIGNED_ALLOC],
9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
12 dnl Persuade glibc and OpenBSD <stdlib.h> to declare aligned_alloc().
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
15 AC_CHECK_FUNCS_ONCE([aligned_alloc])
16 if test $ac_cv_func_aligned_alloc = yes; then
17 dnl On AIX 7.2, aligned_alloc returns NULL when the alignment argument is
18 dnl smaller than sizeof (void *).
19 AC_CACHE_CHECK([whether aligned_alloc works for small alignments],
20 [gl_cv_func_aligned_alloc_works],
25 [[return aligned_alloc (2, 18) == NULL;
28 [gl_cv_func_aligned_alloc_works=yes],
29 [gl_cv_func_aligned_alloc_works=no],
32 aix*) gl_cv_func_aligned_alloc_works="guessing no" ;;
33 # If we don't know, obey --enable-cross-guesses.
34 *) gl_cv_func_aligned_alloc_works="$gl_cross_guess_normal" ;;
38 case "$gl_cv_func_aligned_alloc_works" in
40 *) REPLACE_ALIGNED_ALLOC=1 ;;
43 dnl The system does not have aligned_alloc.