[Boost-bugs] [Boost C++ Libraries] #3750: atomic_cas32 not working for Sun Solaris 10

Subject: [Boost-bugs] [Boost C++ Libraries] #3750: atomic_cas32 not working for Sun Solaris 10
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-12-11 06:37:29


#3750: atomic_cas32 not working for Sun Solaris 10
-------------------------------------------------------------+--------------
 Reporter: SAURABH PANDEY <saurabh.pandey@…> | Owner: igaztanaga
     Type: Bugs | Status: new
Milestone: Boost 1.42.0 | Component: interprocess
  Version: Boost 1.40.0 | Severity: Problem
 Keywords: atomic_cas32 on Sun solaris 10 |
-------------------------------------------------------------+--------------
 #include <iostream>
 #include "boost/interprocess/detail/atomic.hpp"

 boost::uint32_t m_contextId = 0;
 long rtIncrContextId()
 {
         boost::uint32_t contextId = -1;
         boost::uint32_t oldValue = -1;
         do
         {
                 oldValue = m_contextId;
                 contextId = m_contextId + 1;
                 if(boost::interprocess::detail::atomic_cas32((volatile
 boost::uint32_t *)&m_contextId,contextId,oldValue) == oldValue)
                         break;
         }while (true);
         return contextId;
 }

 int main()
 {
         std::cout << " \n Value of m_contextId " << m_contextId;

         rtIncrContextId();

         std::cout << " \n Value of m_contextId " << m_contextId <<
 std::endl;
 }
 '''
 The above program is not working on sun solaris 10 using sparc.
 g++ version is 4.4.2 and because of this sun sparc specific atomic
 operation are not being used . Instead following function is used'''
 ''#elif defined(__GNUC__) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 401 )

 --------------------------------
 ------------------------------

 inline boost::uint32_t atomic_cas32
    (volatile boost::uint32_t *mem, boost::uint32_t with, boost::uint32_t
 cmp)
 { return __sync_val_compare_and_swap(const_cast<boost::uint32_t *>(mem),
 with, cmp); }''

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3750>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:02 UTC