Turn context_save/context_restore into standard setjmp/longjmp. (#24)
commita35a3d819d4e2e4e35964eea617087b5c6431b02
authorJiří Zárevúcky <zarevucky.jiri@gmail.com>
Mon, 12 Mar 2018 17:13:46 +0000 (12 18:13 +0100)
committerGitHub <noreply@github.com>
Mon, 12 Mar 2018 17:13:46 +0000 (12 18:13 +0100)
treef104286d91e5cc3dcc179f87786fac0063f372e7
parentf3d47c976431122cd3b0844f80937c7fdb899b40
Turn context_save/context_restore into standard setjmp/longjmp. (#24)

Turn `context_save()`/`context_restore()` into semi-standard `__setjmp()`/`__longjmp()`.

The original `context_*` functions are similar to `setjmp()`/`longjmp()`, except that the return value is more restricted for the former, and with inverted meaning. This commit adopts the standard return value semantics and acknowledges that these functions are "standard `setjmp()`/`longjmp()` with additional implementation-specific properties" by changing the name. The only divergence from the standard is that `__longjmp()` causes `__setjmp()` to return its value unchanged, even if it is zero. This is just to avoid extra assembly, and `longjmp()` checks this in C.

Note that the original use of `context_save()`/`context_restore()` to implement context switching in fibril implementation has already been delegated to `context_create()`/`context_swap()`, which provide more natural control flow.
14 files changed:
uspace/lib/c/arch/abs32le/src/fibril.c
uspace/lib/c/arch/amd64/src/fibril.S
uspace/lib/c/arch/arm32/src/fibril.S
uspace/lib/c/arch/ia32/src/fibril.S
uspace/lib/c/arch/ia64/include/libarch/fibril.h
uspace/lib/c/arch/ia64/src/fibril.S
uspace/lib/c/arch/mips32/src/fibril.S
uspace/lib/c/arch/ppc32/src/fibril.S
uspace/lib/c/arch/riscv64/src/fibril.c
uspace/lib/c/arch/sparc64/src/fibril.S
uspace/lib/c/generic/context.c
uspace/lib/c/generic/setjmp.c
uspace/lib/c/include/context.h
uspace/lib/c/include/setjmp.h [copied from uspace/lib/c/arch/abs32le/src/fibril.c with 79% similarity]