This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Implement C11 _Atomic
- From: Hans-Peter Nilsson <hp at bitrange dot com>
- To: Andrew MacLeod <amacleod at redhat dot com>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 21 Nov 2013 10:20:38 -0500 (EST)
- Subject: Re: Implement C11 _Atomic
- Authentication-results: sourceware.org; auth=none
- References: <Pine dot LNX dot 4 dot 64 dot 1311052316480 dot 30260 at digraph dot polyomino dot org dot uk> <alpine dot BSF dot 2 dot 02 dot 1311210545480 dot 43309 at arjuna dot pair dot com> <528E1C0A dot 7020907 at redhat dot com>
On Thu, 21 Nov 2013, Andrew MacLeod wrote:
> > Or is that part also required for
> > anything-other-than-ordinary-C-type alignment for the target;
> > say, natural 4-byte alignment of 4-byte-types for targets where
> > alignment is otherwise "packed"; where only 1-byte alignment of
> > the basic type is ABI-mandated?
> >
> If I understand correctly, yes, it would be needed there as well.... if the
> compiler thinks alignof (int) is 1, then I believe it will set alignof(_Atomic
> int) to 1 as well, and that's probably not good.
Right.
> Basically, atomic_types are given their own type nodes in tree.c:
> atomicQI_type_node = build_atomic_base (unsigned_intQI_type_node);
> atomicHI_type_node = build_atomic_base (unsigned_intHI_type_node);
> atomicSI_type_node = build_atomic_base (unsigned_intSI_type_node);
> atomicDI_type_node = build_atomic_base (unsigned_intDI_type_node);
> atomicTI_type_node = build_atomic_base (unsigned_intTI_type_node);
It sounds like I should be able to hack that from the port in
some other tree initializer hook?
I'm trying to avoid ABI breakage of course. I'd rather not have
to ask people not to use _Atomic with 4.9 for CRIS ports using
official releases or have ABI breakage with the next release.
Maybe there's one other port in the same situation...
> and on the branch that code instead looks something like:
>
> #define SET_ATOMIC_TYPE_NODE(TYPE, MODE, DEFAULT) \
> (TYPE) = build_atomic_base (DEFAULT, targetm.atomic_align_for_mode (MODE));
>
> SET_ATOMIC_TYPE_NODE (atomicQI_type_node, QImode, unsigned_intQI_type_node);
> <...>
>
> which provides a target hook to override the default values and a target can
> set them to whatever it deems necessary.
Yah, that'd be nice. Doesn't sound like more than the target
hook and the patched lines above left for that to happen,
though? Or perhaps that's a too-naive assumption. I guess I
should have a look.
> There was insufficient time to test and fully flush this out, so it hasn't
> made it into mainline. Its only thanks to Josephs heroic efforts we have C11
> :-)
>
> I don't think its a lot of code if you wanted to fool with it for your port.
So, what would be needed in terms of testing and coding to get
that part into 4.9?
brgds, H-P