Boost logo

Boost :

Subject: Re: [boost] [atomic] unconditional cmpxchg8b support
From: Jan Hudec (bulb_at_[hidden])
Date: 2012-10-23 18:03:30


On Tue, Oct 23, 2012 at 14:28:46 +0200, Tim Blechmann wrote:
> >>>> however on debian for example, the compiler defaults to generate code
> >>>> for i486. cmpxchg8b has been introduced with the p5 architecture,
> >>>> though, so compiling without specifying a -march flag won't generate the
> >>>> instruction.
> >>>
> >>> GCC will not let you use instructions outside of the target architecture.
> >>
> >> fyi, boost.atomic is using inline assembly
> >
> > While inline assembly may allow to circumvent that restriction, I do not
> > think it is a good idea to force a design that requires their usage.
>
> in a perfect world, we would not need boost.atomic, as all compilers,
> standard libraries would be c++11 compliant.
>
> helge might want to comment about his decision to use inline assembly,
> but iirc, gcc did not provide good support for atomic builtins until 4.4
> or so ... so portability would be a reason

gcc __sync functions were introduced in gcc 4.1. Some of them were introduced
later, but __sync_val_compare_and_swap is there from the start.

Developing for mobile platforms and thus non-intel architectures, I would
really prefer if boost used the __sync operations whenever available. That
would cover non-ancient gcc targeting either ancient (the Debian case) or
esoteric (the embedded case) CPUs.

-- 
						 Jan 'Bulb' Hudec <bulb_at_[hidden]>

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk