Fixed lwm_gcc, had the same bug as atomic_count_gcc (Tyson Whitehead)

[SVN r23367]
This commit is contained in:
Peter Dimov
2004-07-06 10:52:06 +00:00
parent 7361e476b8
commit 9c67a59d43

View File

@ -37,7 +37,7 @@ private:
public: public:
lightweight_mutex(): a_(1) lightweight_mutex(): a_(0)
{ {
} }
@ -57,16 +57,16 @@ public:
explicit scoped_lock(lightweight_mutex & m): m_(m) explicit scoped_lock(lightweight_mutex & m): m_(m)
{ {
while( !__exchange_and_add(&m_.a_, -1) ) while( __exchange_and_add(&m_.a_, 1) )
{ {
__atomic_add(&m_.a_, 1); __atomic_add(&m_.a_, -1);
sched_yield(); sched_yield();
} }
} }
~scoped_lock() ~scoped_lock()
{ {
__atomic_add(&m_.a_, 1); __atomic_add(&m_.a_, -1);
} }
}; };
}; };