|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-04-14 12:44:41
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. :-)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk