Alexander, good day.

Wed, Nov 11, 2009 at 11:04:59PM +0300, Alexander Churanov wrote:
> It seems that I have found a workaround. It is to store the address of
> the variable in a register and then issue the "CAS" instruction, which
> only accepts register for an address. I am currently testing it.

I hadn't seen the code you're testing, but it seems to me that the
attached patch should automatically take care of making the address to
be in some register (if it isn't already in the register).  It compiles
well, and even works as a stand-alone function, but I hadn't yet tested
if boost built with such a atomic primitive really works fine.  Have
some $JOB to do prior to the testing.

If you're storing the address in the register manually -- there is no
need for it: you can use assembly constraints; this also makes less
headache, because compiler decides what register should be allocated by
its own and typically it is doing this job well.  Anyway, I hadn't seen
your patch, so may be you already doing this.
-- 
Eygene
 _                ___       _.--.   #
 \`.|\..----...-'`   `-._.-'_.-'`   #  Remember that it is hard
 /  ' `         ,       __.--'      #  to read the on-line manual
 )/' _/     \   `-_,   /            #  while single-stepping the kernel.
 `-'" `"\_  ,_.-;_.-\_ ',  fsc/as   #
     _.-'_./   {_.'   ; /           #    -- FreeBSD Developers handbook
    {_.-``-'         {_/            #
--- boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp.orig	2009-03-02 11:22:16.000000000 -0500
+++ boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp	2009-11-12 09:51:25.000000000 -0500
@@ -30,10 +30,10 @@
 
 inline int32_t compare_and_swap( int32_t * dest_, int32_t compare_, int32_t swap_ )
 {
-    __asm__ __volatile__( "cas %0, %2, %1"
-                        : "+m" (*dest_), "+r" (swap_)
-                        : "r" (compare_)
-                        : "memory" );
+    __asm__ __volatile__( "casa [%3] 0x80, %2, %1"
+			: "=m" (*dest_), "=r" (swap_)
+			: "r" (compare_), "r" (dest_), "1" (swap_), "m" (*dest_)
+			: "memory" );
 
     return swap_;
 }
_______________________________________________
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"

Reply via email to