|
Boost : |
From: Howard Hinnant (hinnant_at_[hidden])
Date: 2005-08-21 15:56:57
On Aug 21, 2005, at 4:28 PM, Steve Ramsey wrote:
> I've had a number of programs crash after recompiling with the 1.33.0
> release and eventually tracked the problems down to shared_ptr,
> specifically the atomic_decrement function provided in
> sp_counted_base_cw_ppc.hpp.
Try these:
inline void atomic_increment( register long * pw )
{
register int a;
asm
{
loop:
lwarx a, 0, pw
addi a, a, 1
stwcx. a, 0, pw
bne- loop
}
}
inline long atomic_decrement( register long * pw )
{
register int a;
asm
{
sync
loop:
lwarx a, 0, pw
addi a, a, -1
stwcx. a, 0, pw
bne- loop
isync
}
return a;
}
inline long atomic_conditional_increment( register long * pw )
{
register int a;
asm
{
loop:
lwarx a, 0, pw
cmpwi a, 0
beq store
addi a, a, 1
store:
stwcx. a, 0, pw
bne- loop
}
return a;
}
-Howard
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk