Re:Cooperative Threading
by saagarjha on Wednesday November 13, 2019 @12:46AM
(#21521436)
What’s with them mprotect here: https://github.com/byuu/bsnes/blob/master/libco/x86.c ?
[ Parent
| on HN ]
Good question. https://github.com/byuu/bsnes/blob/bd8e94a7c7cbfdf7ac0b7f24c... suggests there are reasons why the section(text) approach might not work, and https://github.com/byuu/bsnes/blob/6b7e6e01bb025bf5cbeb92e65... explicitly says it doesn't work with clang, though I don't see why there's not some way of solving this without mprotect that works everywhere.
but why is it not simply using a separate asm file instead of embedding the preassembled binary as a constant?
Because for many years libco has supported all C89 compilers. I didn't want a dependency on GNU as on Windows, nor did I want to write an MSVC variant. There is no technical reason it cannot be inline now, especially now that we have Clang with a compatible asm syntax.