]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
1999-09-24 Jim Blandy <jimb@zwingli.cygnus.com>
authorBen Elliston <bje+keyword+gnu.7caf74@air.net.au>
Fri, 24 Sep 1999 05:30:05 +0000 (05:30 +0000)
committerBen Elliston <bje+keyword+gnu.7caf74@air.net.au>
Fri, 24 Sep 1999 05:30:05 +0000 (05:30 +0000)
* acspecific.m4 (AC_C_VOLATILE): New test.
* acconfig.h: Add new entry for `volatile'.
* autoconf.texi (C Compiler Characteristics): Document it.

ChangeLog
acconfig.h
acspecific.m4
autoconf.texi
doc/autoconf.texi
lib/autoconf/specific.m4

index 7a454443e428054bd0e02ec0fc792b1fee3c22a2..e282f3322101e9abb3d88b94a6b2e92f6c3ab6a4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+1999-09-24  Jim Blandy  <jimb@zwingli.cygnus.com>
+
+       * acspecific.m4 (AC_C_VOLATILE): New test.
+       * acconfig.h: Add new entry for `volatile'.
+       * autoconf.texi (C Compiler Characteristics): Document it.
+
 1999-09-24  Ben Elliston  <bje@cygnus.com>
 
        * autoreconf.sh: Do not run autoheader if AC_CONFIG_HEADER is
index fdcbec257f53bec6a4d65d41a82c39f7daf9293c..bdfa25a64ff04135f1fb5472a9e7736017df2a8d 100644 (file)
@@ -35,6 +35,9 @@
 /* Define to empty if the keyword does not work.  */
 #undef const
 
+/* Define to empty if the volatile keyword does not work.  */
+#undef volatile
+
 /* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
    This function is required for alloca.c support on those systems.  */
 #undef CRAY_STACKSEG_END
index 7b83756caa3cf549e96e3c32c46b62ebee67cf37..1ade191c625913c61e2a40a77700dae87acadc6e 100644 (file)
@@ -2110,6 +2110,28 @@ if test $ac_cv_c_const = no; then
 fi
 ])
 
+dnl   Note that, unlike const, #defining volatile to be the empty
+dnl   string can actually turn a correct program into an incorrect
+dnl   one, since removing uses of volatile actually grants the
+dnl   compiler permission to perform optimizations that could break
+dnl   the user's code.  So, do not #define volatile away unless it is
+dnl   really necessary to allow the user's code to compile cleanly.
+dnl   Benign compiler failures should be tolerated.
+AC_DEFUN(AC_C_VOLATILE,
+[AC_CACHE_CHECK([for working volatile], ac_cv_c_volatile,
+[AC_TRY_COMPILE(,
+changequote(<<, >>)dnl
+<<
+volatile int x;
+int * volatile y;
+>>,
+changequote([, ])dnl
+ac_cv_c_volatile=yes, ac_cv_c_volatile=no)])
+if test $ac_cv_c_volatile = no; then
+  AC_DEFINE(volatile, )
+fi
+])
+
 AC_DEFUN(AC_C_STRINGIZE, [
 AC_REQUIRE([AC_PROG_CPP])
 AC_MSG_CHECKING([for preprocessor stringizing operator])
index 3e92d9b523815999f1d0be5589af65d5134fb729..a917a339440e907e730f169b852b8a474cddef67 100644 (file)
@@ -2721,6 +2721,28 @@ that don't, the @file{Makefile} or configuration header file will define
 it as empty.
 @end defmac
 
+@defmac AC_C_VOLATILE
+@maindex C_VOLATILE
+@cvindex volatile
+If the C compiler does not understand the keyword @code{volatile},
+define @code{volatile} to be empty.  Programs can simply use
+@code{volatile} as if every C compiler supported it; for those that do
+not, the @file{Makefile} or configuration header will define it as
+empty.
+
+If the correctness of your program depends on the semantics of
+@code{volatile}, simply defining it to be empty does, in a sense, break
+your code.  However, given that the compiler does not support
+@code{volatile}, you are at its mercy anyway.  At least your
+program will compile, when it wouldn't before.
+
+In general, the @code{volatile} keyword is a feature of ANSI C, so you
+might expect that @code{volatile} is available only when @code{__STDC__}
+is defined.  However, Ultrix 4.3's native compiler does support
+volatile, but does not defined @code{__STDC__}.
+@end defmac
+
+
 @defmac AC_C_INLINE
 @maindex C_INLINE
 @cvindex inline
index 3e92d9b523815999f1d0be5589af65d5134fb729..a917a339440e907e730f169b852b8a474cddef67 100644 (file)
@@ -2721,6 +2721,28 @@ that don't, the @file{Makefile} or configuration header file will define
 it as empty.
 @end defmac
 
+@defmac AC_C_VOLATILE
+@maindex C_VOLATILE
+@cvindex volatile
+If the C compiler does not understand the keyword @code{volatile},
+define @code{volatile} to be empty.  Programs can simply use
+@code{volatile} as if every C compiler supported it; for those that do
+not, the @file{Makefile} or configuration header will define it as
+empty.
+
+If the correctness of your program depends on the semantics of
+@code{volatile}, simply defining it to be empty does, in a sense, break
+your code.  However, given that the compiler does not support
+@code{volatile}, you are at its mercy anyway.  At least your
+program will compile, when it wouldn't before.
+
+In general, the @code{volatile} keyword is a feature of ANSI C, so you
+might expect that @code{volatile} is available only when @code{__STDC__}
+is defined.  However, Ultrix 4.3's native compiler does support
+volatile, but does not defined @code{__STDC__}.
+@end defmac
+
+
 @defmac AC_C_INLINE
 @maindex C_INLINE
 @cvindex inline
index 7b83756caa3cf549e96e3c32c46b62ebee67cf37..1ade191c625913c61e2a40a77700dae87acadc6e 100644 (file)
@@ -2110,6 +2110,28 @@ if test $ac_cv_c_const = no; then
 fi
 ])
 
+dnl   Note that, unlike const, #defining volatile to be the empty
+dnl   string can actually turn a correct program into an incorrect
+dnl   one, since removing uses of volatile actually grants the
+dnl   compiler permission to perform optimizations that could break
+dnl   the user's code.  So, do not #define volatile away unless it is
+dnl   really necessary to allow the user's code to compile cleanly.
+dnl   Benign compiler failures should be tolerated.
+AC_DEFUN(AC_C_VOLATILE,
+[AC_CACHE_CHECK([for working volatile], ac_cv_c_volatile,
+[AC_TRY_COMPILE(,
+changequote(<<, >>)dnl
+<<
+volatile int x;
+int * volatile y;
+>>,
+changequote([, ])dnl
+ac_cv_c_volatile=yes, ac_cv_c_volatile=no)])
+if test $ac_cv_c_volatile = no; then
+  AC_DEFINE(volatile, )
+fi
+])
+
 AC_DEFUN(AC_C_STRINGIZE, [
 AC_REQUIRE([AC_PROG_CPP])
 AC_MSG_CHECKING([for preprocessor stringizing operator])