Re: Volatile magic

Alan Cox (alan@lxorguk.ukuu.org.uk)
Sun, 25 Jan 1998 18:43:06 +0000 (GMT)


> Hmm... So what is effect of
> (*(unsigned long *)&jiffies)++;
> when jiffies are volatile, anyway? I would expect that jiffies++; is
> just enough...

Nothing. The one thats the problem is when you try and be clever. Things like
iopl do stuff like

push %eax
call C_function
pop %eax

now gcc itself knows it generates

push %eax
call C_function
addq #4,%esp

Because the C compiler knows this it, and most other compilers use the
passed location on the stack in the called function to store changes to
the parameter variable. Thus in the first example you can use it to assign
stuff back to the assembler code

For those specific cases gcc 2.8.0 is very very clever and knowing it
kept the value in a register and the address is of a parameter that
will vanish when we return it never writes the value back, the assembler
magic never sees it and iopl breaks.

Alan