This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Add atomic type qualifier
- From: Andrew MacLeod <amacleod at redhat dot com>
- To: Andi Kleen <andi at firstfloor dot org>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>, hp at bitrange dot com
- Date: Fri, 26 Jul 2013 17:34:46 -0400
- Subject: Re: [PATCH] Add atomic type qualifier
- References: <51F2AEB1 dot 60408 at redhat dot com> <87ob9pm9gt dot fsf at tassilo dot jf dot intel dot com> <51F2CEFB dot 1040000 at redhat dot com> <87fvv1m3cs dot fsf at tassilo dot jf dot intel dot com>
On 07/26/2013 05:13 PM, Andi Kleen wrote:
Andrew MacLeod <amacleod@redhat.com> writes:
The way the standard is defined, any implicit operation like that is
seq_cst. If you want something other than seq-cst, you have to
explicitly call atomic_store (&x, 0, model).
Thanks.
This doesn't sound like a good default for x86. seq_cst requires
somewhat expensive extra barriers that most people most likely don't
need.
Its the only truly safe default for a multi-threaded environment.
These are the same defaults you get with C++11 as well if you don't
explicitly use a memory model in your atomic operations:
ie
__int_type load(memory_order __m = memory_order_seq_cst) const noexcept
So if you don't want seq-cst, you need to specify exactly what you do want.
Andrew