diff -Naur ../boost_1_38_0.orig/boost/interprocess/detail/atomic.hpp boost/interprocess/detail/atomic.hpp --- ../boost_1_38_0.orig/boost/interprocess/detail/atomic.hpp 2008-10-13 19:36:50.000000000 +0000 +++ boost/interprocess/detail/atomic.hpp 2009-04-08 10:58:13.000000000 +0000 @@ -461,6 +461,98 @@ } //namespace interprocess{ } //namespace boost{ +#elif defined(__IBMCPP__) && (__IBMCPP__ >= 800) && defined(_AIX) + +#include + +namespace boost { +namespace interprocess { +namespace detail{ + +//first define boost::uint32_t versions of __lwarx and __stwcx to avoid poluting +//all the functions with casts + +//! From XLC documenation : +//! This function can be used with a subsequent stwcxu call to implement a +//! read-modify-write on a specified memory location. The two functions work +//! together to ensure that if the store is successfully performed, no other +//! processor or mechanism can modify the target doubleword between the time +//! lwarxu function is executed and the time the stwcxu functio ncompletes. +//! "mem" : pointer to the object +//! Returns the value at pointed to by mem +inline boost::uint32_t lwarxu(volatile boost::uint32_t *mem) +{ + return static_cast(__lwarx(reinterpret_cast(mem))); +} + +//! "mem" : pointer to the object +//! "val" : the value to store +//! Returns true if the update of mem is successful and false if it is +//!unsuccessful +inline bool stwcxu(volatile boost::uint32_t* mem, boost::uint32_t val) +{ + return (__stwcx(reinterpret_cast(mem), static_cast(val)) != 0); +} + +//! "mem": pointer to the object +//! "val": amount to add +//! Returns the old value pointed to by mem +inline boost::uint32_t atomic_add32 +(volatile boost::uint32_t *mem, boost::uint32_t val) +{ + boost::uint32_t oldValue; + do + { + oldValue = lwarxu(mem); + }while (!stwcxu(mem, oldValue+val)); + return oldValue; +} + +//! Atomically increment an apr_uint32_t by 1 +//! "mem": pointer to the object +//! Returns the old value pointed to by mem +inline boost::uint32_t atomic_inc32(volatile boost::uint32_t *mem) +{ return atomic_add32(mem, 1); } + +//! Atomically decrement an boost::uint32_t by 1 +//! "mem": pointer to the atomic value +//! Returns the old value pointed to by mem +inline boost::uint32_t atomic_dec32(volatile boost::uint32_t *mem) +{ return atomic_add32(mem, (boost::uint32_t)-1); } + +//! Atomically read an boost::uint32_t from memory +inline boost::uint32_t atomic_read32(volatile boost::uint32_t *mem) +{ return *mem; } + +//! Compare an boost::uint32_t's value with "cmp". +//! If they are the same swap the value with "with" +//! "mem": pointer to the value +//! "with" what to swap it with +//! "cmp": the value to compare it to +//! Returns the old value of *mem +inline boost::uint32_t atomic_cas32 +(volatile boost::uint32_t *mem, boost::uint32_t with, boost::uint32_t cmp) +{ + boost::uint32_t oldValue; + boost::uint32_t valueToStore; + do + { + oldValue = lwarxu(mem); + } while (!stwcxu(mem, (oldValue == with) ? cmp : oldValue)); + + return oldValue; +} + +//! Atomically set an boost::uint32_t in memory +//! "mem": pointer to the object +//! "param": val value that the object will assume +inline void atomic_write32(volatile boost::uint32_t *mem, boost::uint32_t val) +{ *mem = val; } + +} //namespace detail +} //namespace interprocess +} //namespace boost + #else #error No atomic operations implemented for this platform, sorry! diff -Naur ../boost_1_38_0.orig/boost/interprocess/detail/os_thread_functions.hpp boost/interprocess/detail/os_thread_functions.hpp --- ../boost_1_38_0.orig/boost/interprocess/detail/os_thread_functions.hpp 2008-12-20 19:50:13.000000000 +0000 +++ boost/interprocess/detail/os_thread_functions.hpp 2009-04-08 11:03:14.000000000 +0000 @@ -98,7 +98,7 @@ } inline bool equal_thread_id(OS_thread_id_t id1, OS_thread_id_t id2) -{ return 0 != ::pthread_equal(id1, id2); } +{ return 0 != pthread_equal(id1, id2); } inline void thread_yield() { ::sched_yield(); } @@ -111,7 +111,7 @@ inline bool equal_systemwide_thread_id(const OS_systemwide_thread_id_t &id1, const OS_systemwide_thread_id_t &id2) { - return (0 != ::pthread_equal(id1.tid, id2.tid)) && (id1.pid == id2.pid); + return (0 != pthread_equal(id1.tid, id2.tid)) && (id1.pid == id2.pid); } inline OS_systemwide_thread_id_t get_invalid_systemwide_thread_id()