__SET_SIGCONTEXT(3)

NAME
__set_sigcontext - reading cpu state

SYNOPSIS
#include <signal.h>

__set_sigcontext(context)
	struct sigcontext *context;

DESCRIPTION
__set_sigcontext reads the current state of the cpu and the floating point emulator or coprocessor into a sigcontext structure. This structure is suitable as an argument to sigreturn (2) except for the sc_mask and sc_onstack fields which are not filled in.

The program counter value which is stored corresponds to the return address of the call to __set_sigcontext, thus calling sigreturn(2) with the sigcontext structure will result in execution continuing as though __set_sigcontext had just returned.

__set_sigcontext returns 0, however the value stored in the sc_cpu_regs[0] field of the sigcontext structure is that passed to __set_sigcontext (the address of the sigcontext structure - see aupcs(7)). Thus a normal return and the result of a call to sigreturn(2) can be distinguished.

__set_sigcontext is used internally to implement setjmp(3). It may also be used to examine the stack within a program (since it stores the values of the stack pointer and frame pointer).

RETURN VALUE

0 is returned on a normal return, a non zero value (the address of the sigcontext structure) on return via sigreturn(2).

SEE ALSO
sigvec(2), sigstack(2), signal(3), sigreturn(2), aupcs(7), afp(7)