Hash :
d8de841b
Author :
Date :
2020-11-04T02:22:33
aligned_alloc: New module. * lib/stdlib.in.h (aligned_alloc): New declaration. * lib/aligned_alloc.c: New file. * m4/aligned_alloc.m4: New file. * m4/stdlib_h.m4 (gl_STDLIB_H): Test whether aligned_alloc is declared. (gl_STDLIB_H_DEFAULTS): Initialize GNULIB_ALIGNED_ALLOC, HAVE_ALIGNED_ALLOC, REPLACE_ALIGNED_ALLOC. * modules/stdlib (Makefile.am): Substitute GNULIB_ALIGNED_ALLOC, HAVE_ALIGNED_ALLOC, REPLACE_ALIGNED_ALLOC. * modules/aligned_alloc: New file. * tests/test-stdlib-c++.cc (aligned_alloc): Check signature. * doc/posix-functions/aligned_alloc.texi: Mention the new module and the AIX bug.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
# aligned_alloc.m4 serial 1
dnl Copyright (C) 2020 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.
AC_DEFUN([gl_FUNC_ALIGNED_ALLOC],
[
AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
dnl Persuade glibc <stdlib.h> to declare aligned_alloc().
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
AC_CHECK_FUNCS_ONCE([aligned_alloc])
if test $ac_cv_func_aligned_alloc = yes; then
dnl On AIX 7.2, aligned_alloc returns NULL when the alignment argument is
dnl 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>
]],
[[return aligned_alloc (2, 18) == 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" ;;
# 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
fi
])