11 Aug
2014
11 Aug
'14
12:34 p.m.
Lars Hagström wrote:
inline void atomic_write32(volatile boost::uint32_t *mem, boost::uint32_t val) { __asm__ __volatile__ ( "" ::: "memory" ); __asm__ ( "xchgl %0, %1" : "+r" (val), "+m" (*mem) ); __asm__ __volatile__ ( "" ::: "memory" ); }
This will work, but it's more verbose than it needs to be. You can put the __volatile__ and "memory" on the xchg asm statement and take out the two others. You'll also need to fix atomic_read32: { uint32 r = *mem; __asm__ __volatile__ ( "" ::: "memory" ); return r; }