Boost logo

Boost :

Subject: [boost] [Query] __sync_val_compare_and_swap_4
From: Alapkumar Sinha (Alapkumar.Sinha_at_[hidden])
Date: 2010-07-23 07:43:09

Hi ,

I am trying to use the Boost Interposes, specifically the message queue.

When Im doing cross compiling boost libraries on Cronus mips board, I am getting below error

undefined reference to `__sync_val_compare_and_swap_4'

Upon analysis we found that in boost/interprocess/details/atomic.hpp, was throwing this error.

I found the solution.

I replaced this returned statement ( __sync_val_compare_and_swap_4 ) and included assembly language code in atomic.hpp.

(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), cmp, with);*/

   boost::uint32_t result;

  asm volatile(".set\tpush\n\t"






                        "move\t%[result],$0\n\t" // delay slot




                        "nop\n\t" // delay slot



           : [result] "=&r" (result)

           : [mem] "r" (mem), [cmp] "r" (cmp), [with] "r"(with)

           : "memory");

return result;


After this I was able to execute the message queue program successfully on the mips platform.

Can someone confirm if this is the right solution?



This Email may contain confidential or privileged information for the intended recipient (s) If you are not the intended recipient, please do not use or disseminate the information, notify the sender and delete it from your system.


Boost list run by bdawes at, gregod at, cpdaniel at, john at