comparison src/fftw-3.3.5/m4/ax_gcc_aligns_stack.m4 @ 42:2cd0e3b3e1fd

Current fftw source
author Chris Cannam
date Tue, 18 Oct 2016 13:40:26 +0100
parents
children
comparison
equal deleted inserted replaced
41:481f5f8c5634 42:2cd0e3b3e1fd
1 dnl @synopsis AX_GCC_ALIGNS_STACK([ACTION-IF-YES], [ACTION-IF-NO])
2 dnl @summary check whether gcc can align stack to 8-byte boundary
3 dnl @category Misc
4 dnl
5 dnl Check to see if we are using a version of gcc that aligns the stack
6 dnl (true in gcc-2.95+, which have the -mpreferred-stack-boundary flag).
7 dnl Also, however, checks whether main() is correctly aligned by the
8 dnl OS/libc/..., as well as for a bug in the stack alignment of gcc-2.95.x
9 dnl (see http://gcc.gnu.org/ml/gcc-bugs/1999-11/msg00259.html).
10 dnl
11 dnl ACTION-IF-YES/ACTION-IF-NO are shell commands to execute if we are
12 dnl using gcc and the stack is/isn't aligned, respectively.
13 dnl
14 dnl Requires macro: AX_CHECK_COMPILER_FLAGS, AX_GCC_VERSION
15 dnl
16 dnl @version 2005-05-30
17 dnl @license GPLWithACException
18 dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
19 AC_DEFUN([AX_GCC_ALIGNS_STACK],
20 [
21 AC_REQUIRE([AC_PROG_CC])
22 ax_gcc_aligns_stack=no
23 if test "$GCC" = "yes"; then
24 AX_CHECK_COMPILER_FLAGS(-mpreferred-stack-boundary=4, [
25 AC_MSG_CHECKING([whether the stack is at least 8-byte aligned by gcc])
26 save_CFLAGS="$CFLAGS"
27 CFLAGS="-O"
28 AX_CHECK_COMPILER_FLAGS(-malign-double, CFLAGS="$CFLAGS -malign-double")
29 AC_TRY_RUN([#include <stdlib.h>
30 # include <stdio.h>
31 struct yuck { int blechh; };
32 int one(void) { return 1; }
33 struct yuck ick(void) { struct yuck y; y.blechh = 3; return y; }
34 # define CHK_ALIGN(x) if ((((long) &(x)) & 0x7)) { fprintf(stderr, "bad alignment of " #x "\n"); exit(1); }
35 void blah(int foo) { double foobar; CHK_ALIGN(foobar); }
36 int main2(void) {double ok1; struct yuck y; double ok2; CHK_ALIGN(ok1);
37 CHK_ALIGN(ok2); y = ick(); blah(one()); return 0;}
38 int main(void) { if ((((long) (__builtin_alloca(0))) & 0x7)) __builtin_alloca(4); return main2(); }
39 ], [ax_gcc_aligns_stack=yes; ax_gcc_stack_align_bug=no],
40 ax_gcc_stack_align_bug=yes, [AX_GCC_VERSION(3,0,0, ax_gcc_stack_align_bug=no, ax_gcc_stack_align_bug=yes)])
41 CFLAGS="$save_CFLAGS"
42 AC_MSG_RESULT($ax_gcc_aligns_stack)
43 ])
44 fi
45 if test "$ax_gcc_aligns_stack" = yes; then
46 m4_default([$1], :)
47 else
48 m4_default([$2], :)
49 fi
50 ])