This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: PATCH (volatile support)


 > From: Jeffrey A Law <law@cygnus.com>
 > 
 >   In message <19980505110009.39202@dot.cygnus.com>you write:
 >   > Autoconf has a test (not currently being used by gcc, but we ought)
 >   > to determine if `const' is available.  We should use the same sort
 >   > of test to determine if `volatile' is available.
 > Yup.  Our motto should be "if it's a host/build feature it should
 > be an autoconf check if at all possible".
 > 
 > My recommendation would be to put the test in gcc's aclocal.m4 --
 > nobody knows when there'll actually be another autoconf release.
 > 
 > Once we've got an autoconf test, I don't see a reason why the
 > patch can't be installed.
 > jeff

	I don't see why we need an autoconf check here.  Isn't
volatile generally only helpful for curing problems when the optimizer
is turned on?  We don't optimize in stage1.  So merely checking
__STDC__ (plus a check against another macro to override like jfc
requested) should be enough to activate volatile in stage2 or later.

	If there is some reason we need autoconf which I don't see,
you could use the following untested snippets as a starting point.

		--Kaveh



In aclocal.m4 add:

dnl See whether the stage1 host compiler accepts the volatile keyword.
AC_DEFUN(GCC_C_VOLATILE,
[AC_CACHE_CHECK([for volatile], gcc_cv_c_volatile,
[AC_TRY_COMPILE(, [volatile int foo;],
	gcc_cv_c_volatile=yes, gcc_cv_c_volatile=no)])
if test $gcc_cv_c_volatile = yes ; then
  AC_DEFINE(HAVE_VOLATILE)
fi
])



In configure.in add:

GCC_C_VOLATILE



In system.h, (now that we're using an autoconf test...) add:

/* HAVE_VOLATILE only refers to the stage1 compiler.  We also check
   __STDC__ and assume gcc sets it and has volatile in stage >=2. */
#if !defined(HAVE_VOLATILE) && !defined(__STDC__) && !defined(volatile)
#define volatile
#endif
--
Kaveh R. Ghazi			Project Manager / Custom Development
ghazi@caip.rutgers.edu		Icon CMT Corp.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]