Boost logo

Boost-Build :

Subject: Re: [Boost-build] __sync_val_compare_and_swap_4
From: Vladimir Prus (ghost_at_[hidden])
Date: 2010-07-23 03:35:46


On Friday 23 July 2010 11:22:49 Madhukar Sandi wrote:

> Hi All,
>
> Thanks for your support.
>
> We found the solution here. Whether it is all the test cases correct or not please verify?
>
> We 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;
> }
>
>
> Any body Please verify?

Please bring this question up on the boost_at_[hidden] mailing list. This
mailing list is about Boost.Build system, and at this point, you're talking
not about setting up a compiler, but already about writing a code being
compiled.

Thanks,

--
Vladimir Prus
http://vladimir_prus.blogspot.com
Boost.Build: http://boost.org/boost-build2

Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk