This is the mail archive of the
mailing list for the GCC project.
C++11 atomic library notes V2 - updated
- From: Andrew MacLeod <amacleod at redhat dot com>
- To: GCC <gcc at gcc dot gnu dot org>
- Cc: Lawrence Crowl <crowl at google dot com>, Jeffrey Yasskin <jyasskin at google dot com>, Richard Henderson <rth at redhat dot com>, Aldy Hernandez <aldyh at redhat dot com>, Benjamin Kosnik <bkoz at redhat dot com>
- Date: Fri, 07 Oct 2011 09:56:46 -0400
- Subject: C++11 atomic library notes V2 - updated
After some discussions and further coding, the external library has been
I've updated the document at http://gcc.gnu.org/wiki/Atomic/GCCMM/LIbrary
In a nutshell, the changes are:
1 - generic routines
The generic version routines for arbitrary sized objects were
unimplementable as stated. The new generic interface now works on a
'slab of memory', and any required memory is passed in by the caller.
void __atomic_exchange (size_t obj_size_in_bytes, void *mem, const void
*value, void *return_value, enum memory_model model)
and is utilized like:
template class <T>
T exchange (T *mem, T val, memory_order m)
__atomic_exchange (sizeof (T), mem, &val, &tmp, m);
The compiler can recognize compile constants in the size parameter and
map the call to one of the 5 built-in optimized sizes. Optimization
then folds away all the temporaries, address taken flags, and extra
copies. This has the added benefit of mapping structures of 8 bytes to
an optimized built-in for 8 byte objects, which was missing before.
http://gcc.gnu.org/ml/gcc/2011-10/msg00072.html pretty conclusively
demonstrates to me that the volatility of an object isn't grounds to
segregate the implementation. As such, the library remains as originally
stated with no mention of volatile versions or anything like that.