From: Ben Elliston Date: Fri, 24 Sep 1999 05:30:05 +0000 (+0000) Subject: 1999-09-24 Jim Blandy X-Git-Tag: trunk-pre-merge-trunk-into-experimental-1999-10-01~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6fc36753a3e01dea775d8e3cb7fbeec53c65448;p=thirdparty%2Fautoconf.git 1999-09-24 Jim Blandy * acspecific.m4 (AC_C_VOLATILE): New test. * acconfig.h: Add new entry for `volatile'. * autoconf.texi (C Compiler Characteristics): Document it. --- diff --git a/ChangeLog b/ChangeLog index 7a454443..e282f332 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +1999-09-24 Jim Blandy + + * 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 * autoreconf.sh: Do not run autoheader if AC_CONFIG_HEADER is diff --git a/acconfig.h b/acconfig.h index fdcbec25..bdfa25a6 100644 --- a/acconfig.h +++ b/acconfig.h @@ -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 diff --git a/acspecific.m4 b/acspecific.m4 index 7b83756c..1ade191c 100644 --- a/acspecific.m4 +++ b/acspecific.m4 @@ -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]) diff --git a/autoconf.texi b/autoconf.texi index 3e92d9b5..a917a339 100644 --- a/autoconf.texi +++ b/autoconf.texi @@ -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 diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 3e92d9b5..a917a339 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -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 diff --git a/lib/autoconf/specific.m4 b/lib/autoconf/specific.m4 index 7b83756c..1ade191c 100644 --- a/lib/autoconf/specific.m4 +++ b/lib/autoconf/specific.m4 @@ -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])