Boost logo

Boost :

Subject: Re: [boost] Help needed for shared_ptr issue on iPad2 (dualcore ARM)
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2011-03-28 13:56:13


Peter Dimov wrote:
> Phil Endecott wrote:
>> I've contributed ARM code for Boost.Atomic that knows about the different
>> architecture versions and will use ldrex/strex on ARMv7 (though it needs
>> some attention from someone who knows more than I do about memory
>> barriers, and it has had very little testing).
>
> Where can I see this code?

It's in Helge's repository -
http://git.chaoticmind.net/cgi-bin/cgit.cgi/boost.atomic/tree/boost/atomic/detail/gcc-armv6+.hpp

> How do you detect the ARMv7 architecture to
> enable ldrex/strex use?

The compiler defines a macro. Unfortunately it appears not to have a
simple "v6" or "v7" but instead something more detailed, and I'm not at
all convinced that this detects all of the variants:

// This list of ARM architecture versions comes from Apple's arm/arch.h header.
// I don't know how complete it is.
#elif defined(__GNUC__) && (defined(__ARM_ARCH_6__) ||
defined(__ARM_ARCH_6J__) \
                          || defined(__ARM_ARCH_6Z__) ||
defined(__ARM_ARCH_6ZK__) \
                          || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_7A__))

        #include <boost/atomic/detail/gcc-armv6+.hpp>

>> > how can we detect support for __sync intrinsics and use them.
>>
>> I believe that there is a macro something like
>> __GCC_HAVE_SYNC_COMPARE_AND_SWAP__.
>
> There should be __GCC_HAVE_COMPARE_AND_SWAP_4, but I'm not sure if it's
> actually defined by the whatever compiler people use for iOS development.

I'm using Apple's version of gcc 4.2, and it is NOT defined there - but
the intrinsic DOES exist:

#ifdef __GCC_HAVE_COMPARE_AND_SWAP_4
#warning "__GCC_HAVE_COMPARE_AND_SWAP_4 defined"
#else
#warning "__GCC_HAVE_COMPARE_AND_SWAP_4 NOT defined"
int a, b, c;
__sync_bool_compare_and_swap(&a,b,c);
#endif

That outputs the "NOT defined" warning, but compiles and links OK.

(From your other reply:)

> I'm not quite sure what exactly DSB and ISB can be used for - maybe one
> of those could be enough.

I think they are used when you've changed the page tables, and similar
things, and aren't appropriate here. What might be appropriate are
some of the options to the DMB instruction e.g. "DMB #ST"; I think they
might be new though. (I'm out of my depth here - I know just enough
about memory barriers to know that I don't understand them...)

Phil.


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