
14 Apr
2005
14 Apr
'05
5:44 p.m.
Rene Rivera wrote:
namespace boost {
namespace detail {
inline int atomic_exchange_and_add( int * pw, int dv ) { // int r = *pw; // *pw += dv; // return r;
asm { mov esi, [pw] mov eax, dv lock xadd [esi], eax } }
inline void atomic_increment( int * pw ) { //atomic_exchange_and_add( pw, 1 );
asm { mov esi, [pw] lock inc [esi] } }
Everything looks correct to me, except I'd put the lock prefix before the instruction. GCC needs it on its own line but the x86 way is 'lock inc [esi]'. Unless you can post a disassembly, I'm out of ideas. :-)