set_bit() is broken on i386?
In-Reply-To: <[email protected]>
Quoted 4 lines · Andrew Morton
We need to somehow tell the compiler "this assembly statement altered memory and you can't cache memory contents across it". That's what "memory" (ie:
barrier()) does. I don't think there's a way of telling gcc _what_ memory was clobbered - just "all of memory".
I think you can do that by specifying an output operand that you never use in your assembler code, e.g. changing this:
| __asm__ __volatile__( "lock ; " | "btsl %1,%0" | :"=m" (ADDR) | :"Ir" (nr));
to this:
| #define LONGBITS (8 * sizeof(unsigned long)) | | __asm__ __volatile__( "lock ; " | "btsl %2,%1" | :"=m"(*(&ADDR + nr/LONGBITS)) | :"m" (ADDR), "Ir" (nr));
fixes my example program by telling the compiler what memory location is altered. (Note that %0 is never used inside the asm code.) So iff 'nr' is a constant you can clobber specific memory locations.
Signature · 2 lines
Chuck Currently reading: _Sun Of Suns_ by Karl Schroeder