m68k problem and libstdc++
Nathan Myers
ncm-nospam@cantrip.org
Fri Jan 4 10:40:00 GMT 2002
On Fri, Jan 04, 2002 at 10:58:34AM -0500, Peter Barada wrote:
>
> >CAS is an indivisible instruction intended to allow synchronization
> >of multiple processors (the sequence above is straight out of one of
> >Motorola's examples). I don't think there's any way to get that
> >functionality on pre-68020 chips, so you'll have to conditionalize
> >it away somehow.
>
> Since the straight 68k and 5x0x don't support CAS, you could:
>
> #if defined(__mc68000__) || defined(__mcf5200__)
> " add%.l %2,%1;"
> " cmp%.l %0,%3;"
> #else
> " add%.l %2,%1;"
> " cas%.l %0,%1,%3;"
> #endif
This is not safe against interrupts -- i.e., between the add and
the cmp instructions, the counter may be incremented by another
thread. What we want is a single instruction that will decrement
the target and set a status bit based on the result.
Unfortunately the function interface is more general than such
an instruction is likely to be, despite that we only use this
function to decrement-by-one. That means we really need to change
the abstract interface provided in this file to something
supportable on more CPUs.
Nathan Myers
ncm at cantrip dot org
More information about the Libstdc++
mailing list