Statistics
| Branch: | Tag: | Revision:

root / config / gr_check_memalign.m4 @ 10477754

History | View | Annotate | Download (1.5 kB)

1
# Copyright 2008 Free Software Foundation, Inc.
2
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)
6
# any later version.
7
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.
12
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
16
# 02110-1301, USA.
17
18
AC_DEFUN([GR_CHECK_MEMALIGN],
19
[
20
  AC_REQUIRE([AC_CANONICAL_HOST])
21
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])
28
    aligned_malloc=0
29
    # 'malloc' is 16-byte aligned on (at least) Darwin 8 and 9
30
    case "$host_os" in
31
      darwin8*) aligned_malloc=16 ;;
32
      darwin9*) aligned_malloc=16 ;;
33
      *) ;;
34
    esac
35
    if test $aligned_malloc = 0; then
36
      AC_MSG_RESULT([malloc has unknown alignment.])
37
    else
38
      AC_MSG_RESULT([malloc is $aligned_malloc-byte aligned.])
39
    fi
40
    AC_DEFINE_UNQUOTED([ALIGNED_MALLOC],[$aligned_malloc],[Define as the alignment of malloc if known; otherwise 0.])
41
  ])
42
])