bug-autoconf
[Top][All Lists]
Advanced

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

Re: AC_C_RESTRICT and AC_PROG_CC_STDC


From: Paul Eggert
Subject: Re: AC_C_RESTRICT and AC_PROG_CC_STDC
Date: Mon, 14 May 2007 09:58:55 -0700
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)

Noah Misch <address@hidden> writes:

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

Thanks, that makes sense to me.  I installed the patch enclosed at the
end of this message.

I noticed that there's similar kerfufflery in Autoconf for 'inline'.
The generated config.h currently contains something like this:

   /* Define to `__inline__' or `__inline' if that's what the C compiler
      calls it, or to nothing if 'inline' is not supported under any name.  */
   #ifndef __cplusplus
   /* #undef inline */
   #endif

Does this need to be reworked, to be consistent with 'restrict'?
Or are 'inline' and 'restrict' sufficiently different that we should
just leave 'inline' alone?  I don't use C++ much so I'm asking you C++ experts.


2007-05-14  Paul Eggert  <address@hidden>

        * NEWS: Document that AC_C_RESTRICT checks 'restrict' last.
        * doc/autoconf.texi (C Compiler): Likewise.

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

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

Index: NEWS
===================================================================
RCS file: /cvsroot/autoconf/autoconf/NEWS,v
retrieving revision 1.427
diff -u -p -r1.427 NEWS
--- NEWS        13 Apr 2007 07:52:58 -0000      1.427
+++ NEWS        14 May 2007 16:54:50 -0000
@@ -2,6 +2,10 @@

 ** AC_C_BIGENDIAN now supports universal binaries a la Mac OS X.

+** AC_C_RESTRICT now prefers to #define 'restrict' to a variant spelling
+   like '__restrict' if the variant spelling is available, as this is
+   more likely to work when mixing C and C++ code.
+
 ** AC_CHECK_ALIGNOF's type argument T is now documented better: it must
    be a string of tokens such that "T y;" is a valid member declaration
    in a struct.
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.1153
diff -u -p -r1.1153 autoconf.texi
--- doc/autoconf.texi   9 May 2007 11:40:27 -0000       1.1153
+++ doc/autoconf.texi   14 May 2007 16:54:50 -0000
@@ -6544,10 +6544,12 @@ New programs need not use this macro.
 @defmac AC_C_RESTRICT
 @acindex{C_RESTRICT}
 @cvindex restrict
-If the C compiler recognizes the @code{restrict} keyword, don't do anything.
-If it recognizes only a variant spelling (@code{__restrict},
address@hidden, or @code{_Restrict}), then define
address@hidden to that.
+If the C compiler recognizes a variant spelling for the @code{restrict}
+keyword (@code{__restrict}, @code{__restrict__}, or @code{_Restrict}),
+then define @code{restrict} to that; this is more likely to do the right
+thing with compilers that support language variants where plain
address@hidden is not a keyword.  Otherwise, if the C compiler
+recognizes the @code{restrict} keyword, don't do anything.
 Otherwise, define @code{restrict} to be empty.
 Thus, programs may simply use @code{restrict} as if every C compiler
 supported it; for those that do not, the makefile
Index: lib/autoconf/c.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/c.m4,v
retrieving revision 1.246
diff -u -p -r1.246 c.m4
--- lib/autoconf/c.m4   3 May 2007 14:47:12 -0000       1.246
+++ lib/autoconf/c.m4   14 May 2007 16:54:51 -0000
@@ -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 
of
+# 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],
   [ac_cv_c_restrict=no
    # 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
      AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
       [[typedef int * int_ptr;
         int foo (int_ptr $ac_kw ip) {




reply via email to

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