Boost logo

Boost :

Subject: Re: [boost] [Query] __sync_val_compare_and_swap_4
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2010-07-23 10:33:33


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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk