ax_func_aligned_alloc.m4 1.5 KB

1234567891011121314151617181920212223242526272829303132
  1. # AX_FUNC_ALIGNED_ALLOC
  2. # ---------------------
  3. #
  4. # Check if a specified machine type cannot handle misaligned data. That is, multi-byte data
  5. # types which are not properly aligned in memory fail. Many machines are happy to work with
  6. # misaligned data, but slowing down a bit. Other machines just won't tolerate such data.
  7. #
  8. # This is a simple lookup amongst machines known to the current autotools. So far we only deal
  9. # with the ARM and sparc.
  10. # A lookup is used, as many of the devices which cannot handled misaligned access are embedded
  11. # processors, for which the code normally be cross-compiled.
  12. #
  13. AC_DEFUN([AX_FUNC_ALIGNED_ALLOC],[
  14. saved_CFLAGS="$CFLAGS"
  15. CFLAGS="$CFLAGS -Werror"
  16. AC_CACHE_CHECK([checking for aligned_alloc],
  17. [ax_cv_func_aligned_alloc],
  18. [AC_LINK_IFELSE([AC_LANG_PROGRAM([
  19. #define _ISOC11_SOURCE
  20. #include <stdlib.h>
  21. ],
  22. [
  23. aligned_alloc(0,0);
  24. ])],
  25. [ax_cv_func_aligned_alloc=yes],
  26. [ax_cv_func_aligned_alloc=no])])
  27. if test "x${ax_cv_func_aligned_alloc}" = "xyes" ; then
  28. AC_DEFINE([HAVE_ALIGNED_ALLOC], [1], [Define to 1 if you have the aligned_alloc() function.])
  29. fi
  30. CFLAGS="$saved_CFLAGS"
  31. ])# AX_ALIGNED_ALLOC