On 07/26/2013 07:21 PM, Joseph S. Myers wrote:
On Fri, 26 Jul 2013, Andrew MacLeod wrote:

This patch adds an atomic type qualifier to GCC.   It can be accessed via
__attribute__((atomic)) or in C11 mode via the _Atomic keyword.
Why the attribute - why not just the keyword?
2 reasons:
1 - we currently have at least one target who cannot express their alignment requirements for an atomic value (ie, a short with 4 byte alignment). Use of__attribute((atomic)) will allow proper expression and usage within the atomic built-ins without using C11. 2 - compatibility with C11 and C++11. Ultimately, the atomic object can be "upsized" (ie,a 6 byte object sized up to be 8 bytes). _Atomic would do that for C11, but we cant really use _Atomic within the c++11 template files, so __attribute__((atomic)) seemed pretty natural. As well, this will allow c++ atomic templates to work on aforementioned target(s).



I'll review the patch in detail later (which will involve checking each
reference to "atomic" or "qualified" in the language part of C11, checking
for appropriate implementation and complaining if it appears to be
missing, and checking for appropriate testcases and complaining if those
appear to be missing).  But some comments now:

* pedwarns for using a C11 feature in previous standard modes should as
per usual practice be pedwarns-if-pedantic.

* I don't see anything obvious in the parser changes to implement the
_Atomic ( type-name ) version of the syntax for atomic types (6.7.2.4).

* When C11 refers to qualified types, by default it does not include
atomic types (6.2.5#27).  What's your rationale for including "atomic" in
TYPE_QUALS rather than making it separate?  With either approach, a review
of every reference to qualifiers in the front end is needed to determine
what's correct for "atomic"; did you find that including "atomic" in
qualifiers in the implementation made for fewer changes?

I'm not good at front ends... don't really know them at all. Parsing and syntax and semantics scare me. This was my initial attempt to enable _Atomic and hoped for help with the rest from those who do :-) observation and changes welcome.


Andrew

Reply via email to