1 # Copyright 2008 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3, or (at your option)
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Boston, MA
18 AC_DEFUN([GR_CHECK_MEMALIGN],
20 AC_REQUIRE([AC_CANONICAL_HOST])
22 # Check for allocing memory alignment functions
23 # If 'posix_memalign' is available, use it solely.
24 AC_CHECK_FUNCS([posix_memalign],,[
25 # Otherwise, check for valloc and the
26 # (a-priori known) alignment of 'malloc'
27 AC_CHECK_FUNCS([valloc])
29 # 'malloc' is 16-byte aligned on (at least) Darwin 8 and 9
31 darwin8*) aligned_malloc=16 ;;
32 darwin9*) aligned_malloc=16 ;;
35 if test $aligned_malloc = 0; then
36 AC_MSG_RESULT([malloc has unknown alignment.])
38 AC_MSG_RESULT([malloc is $aligned_malloc-byte aligned.])
40 AC_DEFINE_UNQUOTED([ALIGNED_MALLOC],[$aligned_malloc],[Define as the alignment of malloc if known; otherwise 0.])