public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* C++11 atomic library notes V2 - updated
@ 2011-10-07 18:14 Andrew MacLeod
  0 siblings, 0 replies; only message in thread
From: Andrew MacLeod @ 2011-10-07 18:14 UTC (permalink / raw)
  To: GCC
  Cc: Lawrence Crowl, Jeffrey Yasskin, Richard Henderson,
	Aldy Hernandez, Benjamin Kosnik

After some discussions and further coding, the external library has been 
refined.

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)
{
   T tmp;
   __atomic_exchange (sizeof (T), mem, &val, &tmp, m);
   return tmp;
}

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.

2- Volatiles.

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.

Andrew

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-10-07 13:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-07 18:14 C++11 atomic library notes V2 - updated Andrew MacLeod

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).