ci/woodpecker/push/woodpecker Pipeline was successfulDetails
On non-freestanding builds, including <ucontext.h> on an ARM Darwin
system will produce the following error:
In file included from include/libucontext/bits.h:6:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/
usr/include/ucontext.h:51:2: error: The deprecated
ucontext routines require _XOPEN_SOURCE to be defined
Defining this macro on Darwin systems will make the building pass.
The copy for bits.h ran in parallel with the initial CC. sometimes on
CI the build would fail as the file had not arrived by the time
needed. Fix matches meson build process.
ci/woodpecker/push/woodpecker Pipeline was successfulDetails
Some architecture-specific implementations of the FETCH_LINKPTR
(e.g. the one for x86) attempt to find the linkptr relative to the
stack pointer. Therefore, they make assumption about the value of
the SP at the point where the FETCH_LINKPTR code is executed. This
means that we don't want the C compiler to mess with our SP.
For this purpose, local variables in this function are currently
declared using the register storage specifier. Additionally, we
need to make sure that a frame pointer is /always/ omitted for
this function. On x86 Alpine, the frame pointer is presently not
omitted with GCC 13 when using -Os, therefore the tests segfault
with -Os on Alpine presently.
Fixes#52
The arm ABI defines that the value in register r0 is used as the return
value of a function. To indicate success for get/set/swapcontext (return
value of 0) the register r0 must contain zero at the end of the function
call. Thus set r0 to zero and store it in the context. This context
is restored later and indicate successful execution, because r0 is 0.
The order registers are stored has changed so that only one additional
instruction (mov r0, #0) needs to be added to fix the return value
bug for get/set/swapcontext.
Signed-off-by: Volker Christian <me@vchrist.at>
Add error checking test_libucontext and test_libucontext_posix
to test return values of get/set/swapcontext.
Modifications are inspired by the example program source in the
linux man page of swapcontext
Signed-off-by: Volker Christian <me@vchrist.at>
When installing a FREESTANDING build, the check for an empty variable
was not being honored because the empty string would evaluate to
nothing. Put the variable expansion in quotes so that we have an empty
string instead.
Changes:
1. `-soname` should be `-install_name` on Darwin
2. Version suffix should placed before extension suffix (libucontext.so.1 -> libucontext.1.dylib)
3. Check for architecture specific include directory, and include it while building
4. `EXPORT_UNPREFIXED` macro shouldn't be set since Darwin don't support aliases
5. Choose correct subdir for arm64
6. Use `-dynamiclib` instead of `-shared` on Darwin for adding version info (`-current_version` and `-compatibility_version`)