Is your system polluted?

Piercarlo Grandi pcg at rupert.cs.aber.ac.uk
Tue Dec 26 08:50:18 AEST 1989


In article <259323F0.15070 at paris.ics.uci.edu> rfg at ics.uci.edu (Ron Guilmette) writes:

   Since people generally seem to be so lazy about this particular aspect
   of "good" coding, I was thinking of suggesting a -fdefault-static option
   for GCC which would make the default linkage (or "storage-class", as you
   prefer) in the absence of an explicit specification "static" rather than
   "extern".  This could even be useful for old code because you could compile
   a given system with it, and then try to link.  The linker would tell you
   which items ought to be explicitly declared as extern, and you could then
   go and fix *just* those declaration up to be explicitly extern and recompile
   again with -fdefault-static, thereby minimizing extern visible symbols.

I agree 100%. I agree so much that then I can propose the
equivalently safe, but almost 100% backward trick that makes the
ridiculous volatile keyword useless without virtually loss in
optimization ability and with abosulte safety:

have an option to make "register" the *default* storage class for
block local variables. The only variables that need to be
explicitly declared "auto" are then those whose address is taken,
and the compiler will without any problem flag them out for you.

If you have instead the equivalent trick of having variables
unvolatile by default, you need to manually tag as volatile those
that need be, and if you don't, you get nasty bugs.

I reckon that an option to disable volatile and make register the
default storage class for locals would provide virtually all the
benefits as to optimization (caching globals is virtually
irrelevant), without any risk, and would make it very easy to
develop or upgrade existing programs that relied on Classic C
semantics (e.g. the Unix kernel) in a multithreaded environment.

Consider GNU C under Mach...

--
Piercarlo "Peter" Grandi           | ARPA: pcg%cs.aber.ac.uk at nsfnet-relay.ac.uk
Dept of CS, UCW Aberystwyth        | UUCP: ...!mcvax!ukc!aber-cs!pcg
Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg at cs.aber.ac.uk



More information about the Comp.unix.wizards mailing list