This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [v3] libstdc++/51798


On 02/09/2012 03:24 PM, Benjamin Kosnik wrote:
> This is the rest of 51798, completing the conversion to C++11 atomics
> in libstdc++. This is now a complete transition, modulo documentation
> which I plan to finish as a separate patch once I am back from the ISO
> C++ meeting.
> 
> tested x86_64/linux
> 
> -benjamin
> 
> 
> 20120209-2.patch
> 
> 
> 2012-02-09  Benjamin Kosnik  <bkoz@redhat.com>
>             Jonathan Wakely  <jwakely.gcc@gmail.com>
> 
> 	PR libstdc++/51798 continued.
> 	* acinclude.m4 (GLIBCXX_ENABLE_ATOMIC_BUILTINS): Use __atomic_*
> 	builtins instead of __sync_* builtins for atomic functionality.
> 	* include/bits/shared_ptr_base.h: Same.
> 	* include/parallel/compatibility.h: Same.
> 	* include/profile/impl/profiler_state.h: Same.
> 	* include/tr1/shared_ptr.h: Same.
> 	* libsupc++/eh_ptr.cc: Same.
> 	* libsupc++/eh_throw.cc: Same.
> 	* libsupc++/eh_tm.cc: Same.
> 	* libsupc++/guard.cc: Same.
> 	* configure: Regenerated.
> 	* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Adjust line numbers.
> 	* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc: Same.

The patch uses the weak version of compare_exchange universally, which
is incorrect in a number of cases.  You wouldn't see this on x86_64;
you'd have to use a ll/sc target such as powerpc.

In addition to changing several uses to strong compare_exchange, I also
optimize the idiom

	do
	  {
            var = *m;
	    newval = ...;
	  }
	while (!atomic_compare_exchange(m, &var, newval, ...));

With the new builtins, VAR is updated with the current value of the 
memory (regardless of the weak setting), so the initial read from *M
can be hoisted outside the loop.

Ok?


r~

Attachment: z
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]