Closed osy closed 3 years ago
I think it would be better to just change the non-Meson build system to do -D_GNU_SOURCE on the commandline.
~Sure but there’s still a problem where if it’s used as a sub project and it inherits cflags from the parent (i.e. qemu) then it gets defined but if built standalone with meason it needs to be defined.~
EDIT: nvm I just realized there’s no problem with having -D_GNU_SOURCE twice.
Everything in here except for the clang assembler directive workaround should be merged (excluding the struct layout changes, I took a different approach there), please give the current head a go.
These changes are to get libucontext working with Apple Silicon as well as building as a subproject of QEMU. Additionally, there's a few bug fixes.
FETCH_LINKPTR
was defined to use both register and memory output. But for x86, arm, and arm64, the MOV instruction only accepts register outputs. This causes an assembler error if the compiler decides to use a memory output. To be safe, I changed all the archs to only use register outputs.FETCH_LINKPTR
had the wrong operands. Other than x86_64 (correct), I did not check any other archs._GNU_SOURCE
may be defined by the build system (i.e. when building with QEMU) so I added a guard to itmakecontext
should also be exported only whenEXPORT_UNPREFIXED
is defined.global func ; .align 2 ; func:
). This may be a bug but it means we cannot use preprocessor macros to output multiple directives as macros always expand to a single line regardless. Unfortunately this makes the arm64 functions out of place, so maybe there's a better solution (like a manual preprocess step that expands the newlines).bits.h
uses size_t which requires stddef.hbits.h
headers so-isystem
is not required. This allows Meson builds to work.-DLIBUCONTEXT_ASSEMBLY
.VERSION
file to keep track of the version number which is used by both Make and Meson_Static_assert
to verify that the offset matches what's in def.h. I would recommend this for the other archs as well.makecontext
says that each argument isint
type. In aarch64, this means 32 bit ints in 64 bit registers as well as 32 bit ints in the stack.