Re: restore_flags et al

Alan Cox (alan@lxorguk.ukuu.org.uk)
Tue, 4 Mar 1997 00:39:16 +0000 (GMT)


> #define restore_flags(x) \
> __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory")
>
> I wonder why we need a "memory" here. can anybody enlighten me?
> Getting rid of it would allow gcc to store
> the flags in a register instead of in a memory location.

So that gcc doesnt optimise something like

dosomething(*ptr)

cli();
a=*ptr;
*ptr=b;
sti();

Into using temporary values taken from before we turned interrupts off,
or storing values back to main memory after we turn them back on not
before. Its a store barrier