This is the mail archive of the mailing list for the GCC 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  <>
>             Jonathan Wakely  <>
> 	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++/ Same.
> 	* libsupc++/ Same.
> 	* libsupc++/ Same.
> 	* libsupc++/ Same.
> 	* configure: Regenerated.
> 	* testsuite/20_util/shared_ptr/cons/ Adjust line numbers.
> 	* testsuite/tr1/2_general_utilities/shared_ptr/cons/ 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

            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.



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]