Messages in this thread | | | Date | Sat, 21 Jan 2006 02:43:25 -0500 | From | Chuck Ebbert <> | Subject | Re: set_bit() is broken on i386? |
| |
In-Reply-To: <20060120183857.188ef516.akpm@osdl.org>
On Fri, 20 Jan 2006, Andrew Morton wrote:
> 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. -- Chuck Currently reading: _Sun Of Suns_ by Karl Schroeder - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |