Re: [Linux-ia64] use of setcontext()/getcontext()

David Mosberger
2001-09-27T17:38:34Z

>>>>> On Thu, 27 Sep 2001 09:31:25 +0200 (CEST), stefan <stefan@lkcc.org> said:

stefan> Some more details about the pseudo code:

stefan> [snip]

stefan> Does this explain it better ?

Yes, I understand now what you're trying to do.

stefan> I guess I can't just read r9 for the above purpose ?

I suppose you could. Since the solution will be platform-dependent no
matter how you slice it, you might just as well rely on the ia64 linux
specific behavior of getcontext(). Below is a code fragment that shows
how swapcontext() can be implemented on ia64 linux. You can use the
same approach for your case.

--david

struct rv
{
long retval;
long first_return;
};

int
swapcontext (ucontext_t *oucp, const ucontext_t *ucp)
{
struct rv rv = getcontext (oucp);
if (rv.first_return)
setcontext (ucp);
return 0;
}