[Patch] Use __GCC_HAVE_SYNC_COMPARE_AND_SWAP_*

Paolo Carlini pcarlini@suse.de
Mon May 28 13:17:00 GMT 2007


Peter Dimov wrote:

> There is an alternative; supply the __sync_..._{1,2,4,8} functions (as 
> weak symbols maybe?) for i386 and similar targets, implemented with a 
> spinlock pool, as suggested in N2145. This will have the advantage of 
> making user code "just work". One downside would be that some users 
> may not realize that they're getting an emulation.

I see. In fact, as you may remember, I have been asking for an 
infrastructure providing an emulation layer transparent to the users for 
*years*... Now, mid of 2007, with x86_64 becoming more and more common 
and old Sparcs less and less common, I'm not sure the effort still makes 
sense...

> FWIW, in Boost for x86 I silently assume 486 and above and switch to a 
> separate inline assembly implementation, bypassing __sync_*.

Interesting. If you can strive for best performance without too many 
concerns for ABI stability, binary compatibility and so on, there is a 
lot you can do to improve performance... Luckily with x86_64 and the new 
arches most of those contortions will not be necessary anymore and 
everything will just work.

Paolo.



More information about the Libstdc++ mailing list