summaryrefslogtreecommitdiff
path: root/config/gr_check_memalign.m4
blob: 109516aa35ab2e2199ba84d0fa019dc2b02e2db9 (plain)
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
# Copyright 2008 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Boston, MA
# 02110-1301, USA.

AC_DEFUN([GR_CHECK_MEMALIGN],
[
  AC_REQUIRE([AC_CANONICAL_HOST])

  # Check for allocing memory alignment functions
  # If 'posix_memalign' is available, use it solely.
  AC_CHECK_FUNCS([posix_memalign],,[
    # Otherwise, check for valloc and the
    # (a-priori known) alignment of 'malloc'
    AC_CHECK_FUNCS([valloc])
    aligned_malloc=0
    # 'malloc' is 16-byte aligned on (at least) Darwin 8 and 9
    case "$host_os" in
      darwin8*) aligned_malloc=16 ;;
      darwin9*) aligned_malloc=16 ;;
      *) ;;
    esac
    if test $aligned_malloc = 0; then
      AC_MSG_RESULT([malloc has unknown alignment.])
    else
      AC_MSG_RESULT([malloc is $aligned_malloc-byte aligned.])
    fi
    AC_DEFINE_UNQUOTED([ALIGNED_MALLOC],[$aligned_malloc],[Define as the alignment of malloc if known; otherwise 0.])
  ])
])