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`)
This helps with cross compile setups, where host_cpu != target_cpu
therefore detecting it on the fly will end up with wrong cpu to build
for
Signed-off-by: Khem Raj <raj.khem@gmail.com>
_GNU_SOURCE can be defined without defining REG_X macros so it is not a
good indicator. (QEMU for example defines it in the build system.) x86
and x86_64 should have consistant looking defs.h so ifndef guards are
added to each REG_X definition.