Commit Graph

19 Commits (d81154a61c869e51bea3c1604c5e2f9edbcc68e4)

Author SHA1 Message Date
Ariadne Conill c10cde83da ppc: fix build with libucontext_ namespacing changes 2020-12-06 14:04:22 +00:00
Ariadne Conill c31decc3d4 build: use internal definitions to replace things pulled in from ucontext.h 2020-12-06 03:44:45 -06:00
Ariadne Conill e65e485630 everywhere: rename __swapcontext to libucontext_swapcontext 2020-12-06 03:04:22 -06:00
Ariadne Conill 37fe7afd5f everywhere: rename __setcontext to libucontext_setcontext 2020-12-06 03:03:07 -06:00
Ariadne Conill 99ed5bbe12 everywhere: rename __getcontext to libucontext_getcontext 2020-12-06 03:02:25 -06:00
Ariadne Conill 2f31efaa95 everywhere: rename __start_context to better descriptive libucontext_trampoline 2020-12-06 02:59:59 -06:00
Ariadne Conill c693dc663c rename __makecontext to libucontext_makecontext 2020-12-06 02:56:59 -06:00
Ariadne Conill b1ea2ae83b everywhere: use ucontext.h instead of signal.h for pulling in ucontext definitions
This allows building libucontext against newlib.
2020-12-04 11:19:02 -07:00
Ariadne Conill d31eaabbaf update copyright statements, add mailmap 2020-03-27 09:23:49 +00:00
Bobby Bingham 2610c7faa7 ppc32/64: rewrite get/set/swapcontext in assembly
getcontext cannot be correctly implemented in C.

If this calls another function, as it does to call syscall, it needs to
first spill its return address to the stack.  If, after getcontext returns,
its caller then calls other functions, this saved return address can be
clobbered.  When the context saved by getcontext is later restored, the
(now clobbered) return address will be reloaded from the stack, and the
second return from getcontext will return to the wrong location.

Because the powerpc swapcontext syscall allows either the old context or
new context pointers to be null, it is usable for implementing all of
get/set/swapcontext.

We therefore rewrite swapcontext in assembly, and get/setcontext as simple
assembly function wrappers around swapcontext.

The one piece we keep in C is the code to check the return value of the
system call and to set errno.  This code was actually unnecessary before --
libc does this within syscall.  However, now that the system call is made
directly in assembly, bypassing libc, it is truly necessary.  Because errno
is thread-local and the details of how to set it can vary by libc, this
code remains written in C.
2019-04-05 14:44:54 -05:00
Bobby Bingham 90ff6330e6 ppc32/64: update copyright 2019-04-05 14:18:20 -05:00
Bobby Bingham 29eac4259a ppc32/64: remove unused includes 2019-04-05 14:18:20 -05:00
Bobby Bingham 40d07758a5 ppc32/64: correct signature of function parameter to makecontext
Because makecontext can pass a set of integer arguments to the provided
function, it is incorrect to require that this function accept no
parameters.
2019-04-05 14:18:20 -05:00
Bobby Bingham 55168fcb18 ppc32/64: simplify storage of stack parameters
The switch statement is simpler as an if/else, and removing the argp
variable makes the code more symmetric between the register and stack
parameter cases.
2019-04-05 14:18:20 -05:00
Bobby Bingham b500b054c7 ppc32/64: don't store uc_link on the stack
This was previously stored either in the CR (ppc64) or LR (ppc32) save
area of the stack, or to one of the parameter save slots.

In either case, the saved value was unused.  This value is also passed
to __start_context via r31, so there's no need to pass it on the stack.
2019-04-05 14:15:49 -05:00
Bobby Bingham b9bd4045fb ppc32/64: fix back chain pointer
The ABI states that sp[0] should point to the previous stack frame, or be
zero if there is no previous stack frame.  makecontext previously set this
slot to point to the __start_context function, rather than to a valid
stack frame.
2019-04-05 14:15:49 -05:00
Bobby Bingham b6a9b5e279 ppc32: fix stack alignment
The stack should be 16-byte aligned, not 8 mod 16.
2019-04-05 14:15:44 -05:00
William Pitcock f4d92bb7bd ppc: trampoline: cleanups 2018-02-15 04:36:36 +00:00
William Pitcock f3fe8ea781 arch: ppc: new port 2018-02-02 18:46:21 +00:00