From 9c67a59d43f5f92ba98eb5e3ee4a62409be1fc94 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 6 Jul 2004 10:52:06 +0000 Subject: [PATCH] Fixed lwm_gcc, had the same bug as atomic_count_gcc (Tyson Whitehead) [SVN r23367] --- include/boost/detail/lwm_gcc.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/detail/lwm_gcc.hpp b/include/boost/detail/lwm_gcc.hpp index bf8a09a..a77b26d 100644 --- a/include/boost/detail/lwm_gcc.hpp +++ b/include/boost/detail/lwm_gcc.hpp @@ -37,7 +37,7 @@ private: public: - lightweight_mutex(): a_(1) + lightweight_mutex(): a_(0) { } @@ -57,16 +57,16 @@ public: 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(); } } ~scoped_lock() { - __atomic_add(&m_.a_, 1); + __atomic_add(&m_.a_, -1); } }; };