Greetings! I am actively working on porting x64 code to Apple Silicon now that the time is nigh and part of the fundamentals of our software is a coroutine library for handling cooperative multitasking of GUI operations on the main thread. I was hoping to get the locations of the stack pointer and frame pointer in jmp_buf so, after setjmp() can redirect them to the primary handling routines in our coroutine library that handles the cooperative scheduling (which replaced and ported the old classic MP routines) which worked for PowerPC, i386 and x64.
Any thoughts on where in the jmp_buf these might be located? I didn't see anything in the XNU open source.
Any advice would be much obliged instead of having to dive in and re-implement these routines in assembly myself!
Keep in mind that Apple platforms only guarantee binary compatibility at System framework layer. The layout of jmp_buf
is not in the macOS SDK. Rather, this structure is always manipulated by System framework functions (setjmp
, longjmp
, and friends). That means that the layout could change without breaking apps in general. If you reverse engineer that layout from open source, you open yourself up to binary compatibility problems if that layout ever changes.
Now, I’d be surprised if it actually changed often [1], and so the maintenance workload associated with this path may well be less than the maintenance workload of doing this stuff yourself in assembly language. This is one of those tricking trade-offs that crop up all the time in engineering.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] Within the same architecture. This stuff obviously changes when you change architecture.