Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Maxwell <greg@xiph.org>2012-05-14 09:58:05 +0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2012-05-16 00:24:12 +0400
commit8ecba1ad26d4e75fc26a176f3e3eaca92c1d049b (patch)
tree7fc690a5b109d1e8730e5757be6d581b0882ff62
parent6c83b0bd965ef5ec2bf0bf131f1168d5ebe47bb4 (diff)
Make vararray and restrict checks fail GCC 2.95.3's broken implementation.
-rw-r--r--configure.ac45
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