m68k: avoid the signal-mask save in the bus error trap on BSD/Darwin
Hi there. First off, thanks for an amazing NeoGeo emulation lib! I'm currently using it my macOS+iOS NeoGeo frontend app call NeoBox. I had originally just supported macOS but recently just pushed a big 2.0 version with iOS support to. I found this issue during the port. This bus error trap was eating most of the frame rate on iOS devices. I tested both on my iPhone 15 Pro and on my iPad Pro 11 inch (M1).
- the trap gets armed with
setjmp()roughly 25k times per frame! - on macOS/BSD
setjmp()also saves the signal mask, so that's an additionalsigprocmask()syscall every time - profiled a frame: ~81% of it was
sigprocmask/sigaltstack, and not emulation setjmp()was 281 ns vs_setjmp()2.1 ns per call- frame time went from 8.5 ms to 1.65 ms with this change
The trap never needs the mask restored so skipping it should be safe. setjmp/longjmp have to match, so both spots change together.
I know the README says to avoid platform #ifdefs. I just copied what the address error trap already does a bit higher up in the same header _BSD_SETJMP_H. sigsetjmp isn't on Windows so I couldn't make it fully generic as far as I can tell. I also don't know much about Windows systems programming nor have access to one to easily test
FULL DISCLOSURE: I used Claude to help dig into the profile and draft the patch. I reviewed it and checked the numbers on my devices. If you feel like this MR doesn't make sense or don't accept LLM/AI driven changes totally fine
Thanks again! I have another fix that I used in NeoBox that I would love to contribute back if its cool with you.