[uae] Bye bye stack magic

  • From: Richard Drummond <evilrich@xxxxxxxxxxxxxx>
  • To: uae@xxxxxxxxxxxxx
  • Date: Fri, 30 Sep 2005 14:23:43 -0400

Hi All

Been busy the last few days working on the replacement for UAE's stack magic 
code (this stuff is currently used in E-UAE's 'new' bsdsocket emulation, for 
instance). For those that don't know, the 'stack magic' code is a bunch of 
evilness that lets UAE call 68k code by creating a new stack frame and 
swapping between that and the main stack to allow the execution of 68k code 
to resume.

The problem with this 'stack magic' scheme is that on most operating systems 
it's generally not a good idea to manually create your own stack frame: you 
have to make lots of assumptions which will may not always be valid (for 
instance, the 32-bit OS X version won't currently work on a G5 machine); 
also, it's totally non-portable, requiring some ABI and compiler-specific 
assembly language voodoo as glue.

Anyway, I've cooked up a new scheme which is functionally similar but uses 
threads instead of the manual creation and swapping of stacks - in essence, 
the new stack is created by a new thread; a swap is effected by pausing one 
thread and allowing the other to run.

I think I've finally sussed all the thread synchronization problems that this 
solution creates, and I should have something for testing in a day or two.

The result of all this nonsense is that there will be a fully working 
bsdsocket (network) emulation on all platforms - not just a select few whose 
ABI we support with the stack magic stuff.

Cheers,
Rich

Other related posts: