C++ memory model... What to do with libatomic

Andrew MacLeod amacleod@redhat.com
Wed Nov 30 21:53:00 GMT 2011


Libstdc++-v3 use to provide a locked implementation of classes for sizes 
which didn't have lock-free support.  That was removed for this release 
as it caused a program compiled with a specific version of GCC to be 
locked into that implementation.  The design criteria for the new 
__atomic builtins required that when the compiler cannot provide a lock 
free routine for some object, a call to an external library would be 
made.  This allows legacy code to be "upgraded" at a later date by 
providing a new library with improved support.  It will also facilitate 
a standard library to be used for C1x as well without requiring C++.

The desire is that this library *not* be an integral part of the 
compiler, but be provided by the OS or some application layer.  Until 
this has been around a while and the library standardized/accepted there 
isn't going to be such a generally available library.   Until one is 
available, there should be something which is easily accessible which 
can be built as required.

I've made a rough initial implementation  of libatomic which can built 
and linked in to a program which satisfies all the ABI requirements of 
http://gcc.gnu.org/wiki/Atomic/GCCMM/LIbrary

My question is, what do I do with it :-P   The thoughts that first come 
to mind are:

- It could be added into the gcc build tree, and optionally configured 
and built so that if anyone needs it, its there.
- It could be a separate project hosted outside the gcc source tree.  
Where would the best place be?
- simply make it a part of libgcc for now and worry about separating it 
later.
- It could just be a source file available for download from the GCC 
wiki, or elsewhere.

I imagine there are other options too...

Thoughts?

Andrew

PS.  Reflecting upon it, I wonder if it could be a part of the gcc 
libraries like libgomp or libitm are.   During configuration we could 
check to see if there is an existing libatomic in the system, and if 
there is NOT, enable building libatomic...      Maybe that would be 
best?  then it would "just work" for all gcc users.  Or at least the 
vast majority.

A bit late in the game for this release, so an easily downloadable 
source file would probably have to do this time around for anyone that 
happens to need it for non-lockfree atomics...




More information about the Gcc mailing list