Volatile is stupid
Robert Firth
firth at sei.cmu.edu
Fri Jun 10 00:36:23 AEST 1988
I'm on Chris' side in this debate. The cue word "volatile" is
unnecessary, stupid, and anyway insufficient for the job.
The only way a programmer can know that an address is volatile is
if he has read some document that says so:
"the time-of-day register is 16#fffffeeb#, and when read will return
the current time-of-day in millicatnaps since last Tuesday"
Or, alternatively, he has built the hardware himself, stuffed it into
the chassis, and scribbled a few notes in magic marker on the side.
Either way, the programmer now has to do something special to all
the programs (or all their header files) that reference that new
hardware.
Would it not be far simpler, and far safer, for the compiler to read
a single "target memory definition file", or similar, that says
00000000..0003ffff is ROM
00040000..00ffffff is RAM
fffffeeb is volatile
and so on, and so on? If anyone changes the physical target, they edit
the target memory definition file. The complier simply reads this file
whenever it compiles a program, and does the right thing. If you are
writing code for such a target, you have an environment variable or
whatever that points to "/usr/targets/mc68000/TESTBENCH5.mdf", or some
such.
Not only does this work, it is amenable to decent verification, management,
configuration control, and maintenance. "Volatile" is a hacker's answer.
More information about the Comp.lang.c
mailing list