This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: m68k problem and libstdc++


On Sat, Jan 12, 2002 at 07:03:30PM +0100, Andreas Schwab wrote:
> Craig Rodrigues <rodrigc@mediaone.net> writes:
> 
> |> -static inline _Atomic_word 
> |> +static inline _Atomic_word
> |>  __attribute__ ((__unused__))
> |>  __exchange_and_add (volatile _Atomic_word *__mem, int __val)
> |>  {
> |>    register _Atomic_word __result = *__mem;
> |> +
> |> +#if defined(__mcpu32__) || defined(__mcf5400__)
> |> +  static char __lock = 0;	// needs to be a byte
> |> +
> |> +  // tas method
> |> +  __asm__ __volatile__ ( "1: tas %1;"
> |> +		 	 "   jbne 1b;"
> |> +			 "   move%.l %3, %0;"
> |> +			 "   add%.l %2, %3;"
> |> +			 "   clrb %1;"
> |> +			 : "=d" (__result), "=m" (__lock)
> |> +			 : "d" (__val), "m" (*__mem), "0" (__result)
> |> +			 : "memory");
> 
> This does not work.  The spinlock must be part of _Atomic_word.

by _Atomic_word I assume you mean __result?  I don't understand what you
mean by "a part of".  the point of the routine is to atomically
increment *__mem by __val and return the old value of *__mem, yes?

since we don't have cas, we have to make the whole sequence atomic by
using tas.

from a disassembly of locale.o:

     44a:       4af9 0000 0000  tas 0 <_Z12__atomic_addPVii>
     450:       66f8            bnes 44a <_ZNSt6localeC2EPKc+0x116>
     452:       2010            movel %a0@,%d0
     454:       d390            addl %d1,%a0@
     456:       4239 0000 0000  clrb 0 <_Z12__atomic_addPVii>

this looks correct to me.  what am I missing?

-- 
  Aaron J. Grier  |   Frye Electronics, Tigard, OR   |  aaron@frye.com
     "In a few thousand years people will be scratching their heads
       wondering how on earth the first computer was invented and
          bootstrapped without a prior computer to do it with."
                    --  Chris Malcolm, on comp.arch


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]