Merged r9798:9801 from michaelld/memalign into trunk. Passes distcheck on Ubuntu...
[debian/gnuradio] / config / gr_check_memalign.m4
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   # Check for allocing memory alignment functions
21   # If 'posix_memalign' is available, use it solely.
22   AC_CHECK_FUNCS([posix_memalign],,[
23     # Otherwise, check for valloc and the
24     # (a-priori known) alignment of 'malloc'
25     AC_CHECK_FUNCS([valloc])
26     aligned_malloc=0
27     # 'malloc' is 16-byte aligned on (at least) Darwin 8 and 9
28     case "$host_os" in
29       darwin8*) aligned_malloc=16 ;;
30       darwin9*) aligned_malloc=16 ;;
31       *) ;;
32     esac
33     if test $aligned_malloc = 0; then
34       AC_MSG_RESULT([malloc has unknown alignment.])
35     else
36       AC_MSG_RESULT([malloc is $aligned_malloc-byte aligned.])
37     fi
38     AC_DEFINE_UNQUOTED([ALIGNED_MALLOC],[$aligned_malloc],[Define as the alignment of malloc if known; otherwise 0.])
39   ])
40 ])