> At a quick read, it appears that `const' and `volatile' are treated as
> `garbage type qualifiers' and ignored.
Const is ignored. Volatile is not ignored anymore.
/sys/src/cmd/cc/dcl.c:768 or so inserts USED(&x)
if you declare volatile int x;, presumably so that
the compiler will not registerize x. This is occasionally
necessary in the kernel because of waserror().
For example:
x = 0;
if(waserror()){
print("x=%d\n", x);
nexterror();
}
x = 1;
x = f(x);
If f errors, then the waserror might print 0 if the compiler
has chosen not to store the 1 (it's not used after the call
to f -- it will be overwritten once f returns).
This happens in namec in /sys/src/9/port/chan.c. Rob defined
an empty function saveregisters() and called it to force the
compiler to write the new value of x to memory before calling f
(in this case, devtab[c->type]->open). It could be replaced
by making c volatile now, though I'd rather not.
Russ