Adding the memory and cc will certainly do no harm, and someone tried to remove them as an optimization. I wouldn't change the input and output lines - the differences are mainly syntactic sugar.
Brian On Feb 10, 2010, at 7:04 AM, Ake Sandgren wrote: > On Wed, 2010-02-10 at 08:21 -0500, Jeff Squyres wrote: >> On Feb 10, 2010, at 7:47 AM, Ake Sandgren wrote: >> >>> According to people who knows asm statements fairly well (compiler >>> developers), it should be >> >>> static inline int opal_atomic_cmpset_32( volatile int32_t *addr, >>> int32_t oldval, int32_t newval) >>> { >>> unsigned char ret; >>> __asm__ __volatile__ ( >>> SMPLOCK "cmpxchgl %3,%2 \n\t" >>> "sete %0 \n\t" >>> : "=qm" (ret), "=a" (oldval), "=m" (*addr) >>> : "q"(newval), "2"(*addr), "1"(oldval) >>> : "memory", "cc"); >>> >>> return (int)ret; >>> } >> >> Disclaimer: I know almost nothing about assembly. >> >> I know that OMPI's asm is a carefully crafted set of assembly that works >> across a broad range of compilers. So what might not be "quite right" for >> one compiler may actually be there because another compiler needs it. >> >> That being said, if the changes above are for correctness, not >> neatness/style/etc., I can't speak for that... > > The above should be correct for gcc style unless i misunderstood them. > > Quoting from their reply: > 'it should be "memory", "cc" since you also have to tell gcc you're > clobbering the EFLAGS' > > And i don't know asm either so...