Boost logo

Boost :

Subject: Re: [boost] [interprocess] atomic_write32 on GCC/x86/x68_64 lacksmemory barrier
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2014-08-08 11:20:21


El 08/08/2014 14:58, Peter Dimov escribió:

> The problem with the current implementation is not the lack of a
> hardware memory barrier, but the lack of a compiler memory barrier. On
> GCC, it's __asm__ __volatile__ ( "" ::: "memory" ). For release
> semantics, it ought to go before the store.

Thanks. That might be the case in many other platforms provided by users
(AIX, OSF on Alpha) where the atomic write is implemented without any
barrier.

> Nowadays on GCC it might be best to use the built-in atomic intrinsics:
>
> https://gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/_005f_005fatomic-Builtins.html
>
> std::atomic would be even better but I don't think it works in C++03 mode.

Interprocess supports quite old GCCs (from 4.0, I think) that might not
have atomic builtins. I expect Boost.Atomic to provide assembler code
for those platforms.

Best,

Ion


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