[kaffe] COMPARE_AND_EXCHANGE with m68k
Tony Wyatt
wyattaw@optushome.com.au
Mon Feb 24 20:15:01 2003
I've been playing with the m68k Amiga version of kaffe. There is a proble=
m
with the 1.0.7 release for the Amiga m68k (for Linux m68k also):
The COMPARE_AND_EXCHANGE macro as defined in /config/m68k/common.h uses t=
he
"casl" instruction to perform an atomic compare and exchange - this requi=
res the old and new
data to be in data registers. There are three calls to this macro, all in=
/kaffevm/locks.c: two of them use constants as macro arguments, the third=
uses pointers.
The compiler optimisation generates code using data registers for the fir=
st
two calls, which work OK. However, the compiler uses address registers in=
the
third macro expansion, with the result that the assembler throws a tantru=
m
with an "illegal address mode".
To get over the problem, I tried casting the pointers to uint32, but the
compiler still left the addresses in data registers. To get it running, I=
then split up the macro into two macros of different names, to be used in=
the two contexts. I defined two macros in the m68k config only.
Clearly this can not be put into the source tree, and with Dalibor snappi=
ng
at my heels to post my patches, I am asking for help. I can see two ways =
out
of this, can anyone suggest the best way?
(1) Alter the macro so that the arguments are always forced into data
registers. I have tried a couple of ways, but the compiler seems to
re-allocate registers as it sees fit.
(2) Alter the macro calls (perhaps with a function prototype?) so that th=
e
compiler is expecting a uint in the macro argument. This ought to be "siz=
eof
(void *)" and is then non-portable because of differing address sizes on =
different machines.
Any suggestions?
tony