diff options
author | Gregory Maxwell <greg@xiph.org> | 2012-05-14 09:58:05 +0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2012-05-16 00:24:12 +0400 |
commit | 8ecba1ad26d4e75fc26a176f3e3eaca92c1d049b (patch) | |
tree | 7fc690a5b109d1e8730e5757be6d581b0882ff62 /configure.ac | |
parent | 6c83b0bd965ef5ec2bf0bf131f1168d5ebe47bb4 (diff) |
Make vararray and restrict checks fail GCC 2.95.3's broken implementation.
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac index df65008c..1e3068fc 100644 --- a/configure.ac +++ b/configure.ac @@ -51,15 +51,50 @@ AC_PROG_CC_C99 AC_C_BIGENDIAN AC_C_CONST AC_C_INLINE -AC_C_RESTRICT + +#Use a hacked up version of autoconf's AC_C_RESTRICT because it's not +#strong enough a test to detect old buggy versions of GCC (e.g. 2.95.3) +AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict, + [ac_cv_c_restrict=no + # The order here caters to the fact that C++ does not require restrict. + for ac_kw in __restrict __restrict__ _Restrict restrict; do + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[typedef int * int_ptr; + int foo (int_ptr $ac_kw ip, int * $ac_kw baz[]) { + return ip[0]; + }]], + [[int s[1]; + int * $ac_kw t = s; + t[0] = 0; + return foo(t, (void *)0)]])], + [ac_cv_c_restrict=$ac_kw]) + test "$ac_cv_c_restrict" != no && break + done + ]) + AH_VERBATIM([restrict], +[/* Define to the equivalent of the C99 'restrict' keyword, or to + nothing if this is not supported. Do not define if restrict is + supported directly. */ +#undef restrict +/* Work around a bug in Sun C++: it does not support _Restrict or + __restrict__, even though the corresponding Sun C compiler ends up with + "#define restrict _Restrict" or "#define restrict __restrict__" in the + previous line. Perhaps some future version of Sun C++ will work with + restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ +#if defined __SUNPRO_CC && !defined __RESTRICT +# define _Restrict +# define __restrict__ +#endif]) + case $ac_cv_c_restrict in + restrict) ;; + no) AC_DEFINE([restrict], []) ;; + *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; + esac AC_DEFINE([OPUS_BUILD], [], [This is a build of OPUS]) AC_MSG_CHECKING(for C99 variable-size arrays) -AC_TRY_COMPILE( , [ -int foo=10; -int array[foo]; -], +AC_TRY_COMPILE( [], [static int x; char a[++x]; a[sizeof a - 1] = 0; int N; return a[0];], [has_var_arrays=yes;AC_DEFINE([VAR_ARRAYS], [], [Use C99 variable-size arrays]) ], has_var_arrays=no |