[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Noah Misch
Date: Sun, 13 May 2007 20:00:47 -0700
User-agent: Mutt/1.5.9i

On Mon, May 14, 2007 at 12:55:36AM +0200, Bruno Haible wrote:
> The support of 'restrict' and '__restrict' is this:
>                 |  restrict    |   __restrict
> ----------------+--------------+---------------
> gcc             |    no        |       yes
> gcc -std=gnu99  |    yes       |       yes
> g++             |    no        |       yes

AC_C_RESTRICT currently tests `restrict' first.  If `restrict' is unavailable,
it tests various implementation-specific alternatives.  Let us prefer the
alternatives: they are more stable across front-ends and modes in GCC.  I expect
the same situation in other compiler collections.

This change does break AC_C_RESTRICT for C/C++ compiler sets with common support
for `restrict' but conflicting support for alternative names.  Is this a
configuration to worry about?

Bugs like this will arise so long as Autoconf tests compiler attribute with one
of several compilers, and applications use such results in input to compilers
other than the one tested.  These problems have not yet arisen enough to justify
testing features on each relevant compiler.


2007-05-13  Noah Misch  <address@hidden>

        * lib/autoconf/c.m4 (AC_C_RESTRICT): Check `restrict' last.

diff -Nurp -X dontdiff ac-clean/lib/autoconf/c.m4 ac-crestrict/lib/autoconf/c.m4
--- ac-clean/lib/autoconf/c.m4  2007-05-05 00:39:14.000000000 -0400
+++ ac-crestrict/lib/autoconf/c.m4      2007-05-13 22:38:57.000000000 -0400
@@ -1647,9 +1647,10 @@ fi
 # http://autoconf-archive.cryp.to/acx_restrict.html
 # Determine whether the C/C++ compiler supports the "restrict" keyword
-# introduced in ANSI C99, or an equivalent.  Do nothing if the compiler
-# accepts it.  Otherwise, if the compiler supports an equivalent,
-# define "restrict" to be that.  Here are some variants:
+# introduced in ANSI C99, or an equivalent.  Define "restrict" to the alternate
+# spelling, if any; these are more likely to work in both C and C++ compilers 
+# the same family, and in the presence of varying compiler options.  If only
+# plain "restrict" works, do nothing.  Here are some variants:
 # - GCC supports both __restrict and __restrict__
 # - older DEC Alpha C compilers support only __restrict
 # - _Restrict is the only spelling accepted by Sun WorkShop 6 update 2 C
@@ -1660,7 +1661,7 @@ AC_DEFUN([AC_C_RESTRICT],
    # Try the official restrict keyword, then gcc's __restrict, and
    # the less common variants.
-   for ac_kw in restrict __restrict __restrict__ _Restrict; do
+   for ac_kw in __restrict __restrict__ _Restrict restrict; do
       [[typedef int * int_ptr;
         int foo (int_ptr $ac_kw ip) {

reply via email to

[Prev in Thread] Current Thread [Next in Thread]