Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: compound assignment to atomic type |
| Date | 2016-11-11 16:04 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <8737iyovea.fsf@bsb.me.uk> (permalink) |
| References | <c023fb24-93f5-463d-8618-e19499f78f0a@googlegroups.com> |
spacewar@gmail.com writes: > I'm confused about C11 compound assignments with E1 (left hand side) > being an atomic type. > > §6.5.16.2 ¶3 states: > If E1 has an atomic type, compound assignment is a > read-modify-write operation with memory_order_seq_cst memory order > semantics. > > Footnote 113 says > Where a pointer to an atomic object can be formed and E1 and E2 have > integer type, this is equivalent to the following code sequence [...]" > with the code sequence using atomic_compare_exchange_strong(). > > On the other hand, §7.17.7.5 ¶5 states: > NOTE The operation of the atomic_fetch and modify generic functions are > nearly equivalent to the operation of the corresponding op= compound > assignment operators. The only differences are that the compound > assignment operators are not guaranteed to operate atomically, [...] > > Doesn't that directly contradict §6.5.16.2 ¶3 and footnote 113? This came up in a DR about the use of various terms relating to atomic types and atomic operations: http://www.open-std.org/jtc1/sc22/wg14/www/docs/summary.htm#dr_486 > GCC 6.2.1 generates atomic RMW code for compound assignments with > atomic LHS, but the NOTE in §7.17.7.5 makes me worry about that being > non-portable. The DR is under review, but I get the feeling the committee agrees that the wording is confusing. I think you can rely on x <op>= y having the RMW sematics described in 6.5.16.2 (along with the extensive footnote 113). -- Ben.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
compound assignment to atomic type spacewar@gmail.com - 2016-11-10 19:34 -0800
Re: compound assignment to atomic type Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-11-11 16:04 +0000
Re: compound assignment to atomic type supercat@casperkitty.com - 2016-11-11 09:01 -0800
Re: compound assignment to atomic type Tim Rentsch <txr@alumni.caltech.edu> - 2016-11-15 10:54 -0800
Re: compound assignment to atomic type spacewar@gmail.com - 2016-11-12 00:48 -0800
Re: compound assignment to atomic type Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-11-12 11:06 +0000
Re: compound assignment to atomic type supercat <flatfinger@casperkitty.com> - 2016-11-12 11:03 -0800
Re: compound assignment to atomic type Tim Rentsch <txr@alumni.caltech.edu> - 2016-11-13 10:57 -0800
Re: compound assignment to atomic type Tim Rentsch <txr@alumni.caltech.edu> - 2016-11-13 10:31 -0800
Re: compound assignment to atomic type "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-11-12 11:24 -0800
Re: compound assignment to atomic type Tim Rentsch <txr@alumni.caltech.edu> - 2016-11-13 10:59 -0800
Re: compound assignment to atomic type "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-11-13 17:34 -0800
Re: compound assignment to atomic type "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-11-13 17:48 -0800
Re: compound assignment to atomic type Tim Rentsch <txr@alumni.caltech.edu> - 2016-11-15 10:42 -0800
csiph-web