1
0
mirror of https://https.git.savannah.gnu.org/git/gnulib.git synced 2026-04-28 06:33:36 +00:00
Files
gnulib/m4/aligned_alloc.m4
Bruno Haible b1f65faabb Use a warranty disclaimer in all-permissive license notices.
* etc/license-notices/unlimited: Add a short warranty disclaimer
sentence.
* m4/*.m4: Update.
* build-aux/prefix-gnulib-mk: Likewise.
* HACKING: Likewise.
2024-10-17 21:52:41 +02:00

55 lines
1.9 KiB
Plaintext

# aligned_alloc.m4
# serial 6
dnl Copyright (C) 2020-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
AC_DEFUN([gl_FUNC_ALIGNED_ALLOC],
[
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
dnl Persuade glibc and OpenBSD <stdlib.h> to declare aligned_alloc().
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
gl_CHECK_FUNCS_ANDROID([aligned_alloc], [[#include <stdlib.h>]])
if test $ac_cv_func_aligned_alloc = yes; then
dnl On macOS 11.1 and AIX 7.3.1, aligned_alloc returns NULL when the
dnl alignment argument is smaller than sizeof (void *).
AC_CACHE_CHECK([whether aligned_alloc works for small alignments],
[gl_cv_func_aligned_alloc_works],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[#include <stdlib.h>
]],
[[void *volatile p = aligned_alloc (2, 18);
return p == NULL;
]])
],
[gl_cv_func_aligned_alloc_works=yes],
[gl_cv_func_aligned_alloc_works=no],
[case "$host_os" in
# Guess no on AIX.
aix*) gl_cv_func_aligned_alloc_works="guessing no" ;;
# Guess no on macOS.
darwin*) gl_cv_func_aligned_alloc_works="guessing no" ;;
# If we don't know, obey --enable-cross-guesses.
*) gl_cv_func_aligned_alloc_works="$gl_cross_guess_normal" ;;
esac
])
])
case "$gl_cv_func_aligned_alloc_works" in
*yes) ;;
*) REPLACE_ALIGNED_ALLOC=1 ;;
esac
else
dnl The system does not have aligned_alloc.
HAVE_ALIGNED_ALLOC=0
case "$gl_cv_onwards_func_aligned_alloc" in
future*) REPLACE_ALIGNED_ALLOC=1 ;;
esac
fi
])