[kaffe] COMPARE_AND_EXCHANGE with m68k

Tony Wyatt wyattaw at optusnet.com.au
Mon Feb 24 20:15:01 PST 2003


I've been playing with the m68k Amiga version of kaffe. There is a problem
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 the
"casl" instruction to perform an atomic compare and exchange - this requires 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 first
two calls, which work OK. However, the compiler uses address registers in the
third macro expansion, with the result that the assembler throws a tantrum
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 snapping
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 the
compiler is expecting a uint in the macro argument. This ought to be "sizeof
(void *)" and is then non-portable because of differing address sizes on different machines.

Any suggestions?

tony





More information about the kaffe mailing list