Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Nov 2009 17:55:05 +0300
From:      Eygene Ryabinkin <rea-fbsd@codelabs.ru>
To:        Alexander Churanov <alexanderchuranov@gmail.com>
Cc:        ports@freebsd.org, Mark Linimon <linimon@lonesome.com>, Boris Kochergin <spawk@acm.poly.edu>
Subject:   Re: Issues with devel/boost-* on Sparc64
Message-ID:  <kj9hWbiy3K1JoISAmw2pddy6yTk@7ANLw7WpNQUEViOFvqmcIRbmcl4>
In-Reply-To: <3cb459ed0911111204n4579090fif954f59305e07457@mail.gmail.com>
References:  <3cb459ed0911071747y11e5ace3gca92c9814a11d139@mail.gmail.com> <4AF628EC.3030404@acm.poly.edu> <BTAsGXLMP5aSX1%2BqQS%2BY4/eJCnU@SNwcwk2DeGhgeFqjLEiQrEAOiKg> <Ky7FV1nJOTSLuSXuD6IIFR9MNeY@SNwcwk2DeGhgeFqjLEiQrEAOiKg> <3cb459ed0911091628k499507ffl13a1970d270c921d@mail.gmail.com> <3cb459ed0911091634g1fe5792bu5f41960bbe344999@mail.gmail.com> <3cb459ed0911111204n4579090fif954f59305e07457@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--Pd0ReVV5GZGQvF3a
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

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
    {_.-``-'         {_/            #

--Pd0ReVV5GZGQvF3a
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="boost-cas.diff"

--- 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_;
 }

--Pd0ReVV5GZGQvF3a--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?kj9hWbiy3K1JoISAmw2pddy6yTk>