
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. ______________________________________________________________________

On 07/23/2010 03:43 PM, Alapkumar Sinha wrote:
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.
The unresolved symbol is actually a hook GCC provides to implement the atomic operation. So the right solution would be to put your assembly code into that function, defined in your application. On the other hand, if the atomic operation is possible on this architecture, then GCC should implement it itself. The fact it doesn't may mean one of the following: * The implementation you came up with is not compatible with the hardware GCC targets to. In this case, the problem can be solved by specifying a target architecture in the build options. * It is not yet implemented in GCC. In that case I would suggest contacting GCC developers and see if it can be added to the compiler. Note that I'm not a MIPS expert and I cannot judge if the suggested assembly is correct.
participants (2)
-
Alapkumar Sinha
-
Andrey Semashev