Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - __cpu_membarrier implementation: (2 Items)
   
__cpu_membarrier implementation  
In trunk/lib/c/public/x86/cpuinline.h __cpu_membarrier defined as 

# define __cpu_membarrier()												\
	({																	\
		/* check for X86_CPU_SSE2 */									\
		if (__cpu_flags & (1 << 15)) {									\
			__asm__ __volatile__ ("mfence");							\
		} else {														\
			__asm__ __volatile__ ("lock; orb $0,0(%esp)");				\
		}																\
	})



In trunk/lib/c/public/x86/smpxchg.h _smp_xchg defined as 

static __inline int __attribute__((__unused__)) _smp_xchg(volatile unsigned *__dst, unsigned __src) {
	__asm__ __volatile__(
		"xchgl %0,%1"
		:"=r" (__src)
		:"m" (__atomic_fool_gcc(__dst)), "0" (__src)
		:"memory");
	return __src;
}


A question is: is not "memory" required in clobber list for __cpu_membarrier? As far as I understand that makes sure 
compiler does not reuse values evaluated from memory across the assembler block.
Re: __cpu_membarrier implementation  
Hi Oleh,

Funny you should mention it.  This was corrected recently on the trunk
(r249886) as part of PR 60043.  Thank you for the bug report though.

Regards,
Neil