This is the mail archive of the gcc-patches@gcc.gnu.org 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: Implement C11 _Atomic


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]