On Jun 23, 2014 11:32 PM, "Rich Felker" <dalias@libc.org> wrote:
> > Just to revive this post 1.0, it would be very nice indeed to have
> > set,get,swapcontext.
>
> One approach to setcontext would be using rt_sigreturn, but I've heard
> there are issues using it for setcontext involving the alternate
> signal stack. It's the only way to do resuming _async_ (i.e. the
> ucontext received by a signal handler for the state it interrupted)
> contexts though, so maybe there's some way to make it work. This issue
> was discussed recently on libc-alpha (the glibc list).

I am not interested in the async case not sure if other users are. If I read the glibc discussion correctly they are not supporting this any more?

> Otherwise, if async contexts don't need to be supported, these
> functions are essentially just mechanical transformations of
> sigsetjmp/siglongjmp. I think setcontext could be implemented just as
> a transformation of the mcontext_t register values into a jmp_buf,
> followed by a call to siglongjmp. For getcontext, you can't just wrap
> sigsetjmp since wrapping returns-twice functions is impossible. But
> maybe there's some way to make it work without code duplication.
>

This sounds promising. Will take a look at the code.

Justin