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"

                       ".set\tnoreorder\n\t"

                       ".set\tnomacro\n\t"

                       "1:\n\t"

                        "ll\t%[result],0(%[mem])\n\t"

                       "bne\t%[result],%[with],2f\n\t"

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

                        "move\t%[result],%[mem]\n\t"

                        "sc\t%[result],0(%[mem])\n\t"

                        "beq\t%[result],$0,1b\n\t"

                        "nop\n\t" // delay slot

                        "2:\n\t"

                        ".set\tpop"

           : [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?

Regards,

Alap

________________________________
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 acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk