public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: stefan <stefan@lkcc.org>
To: linux-ia64@vger.kernel.org
Subject: Re: [Linux-ia64] use of setcontext()/getcontext()
Date: Thu, 27 Sep 2001 07:31:25 +0000	[thread overview]
Message-ID: <marc-linux-ia64-105590698805266@msgid-missing> (raw)
In-Reply-To: <marc-linux-ia64-105590698805251@msgid-missing>

On Wed, 26 Sep 2001, David Mosberger wrote:

> >From this description, it sounds like you'd want to use swapcontext().
> I don't quite understand your pseudo-code though (what's are
> save_both_stacks()/restore_both_stacks() supposed to do?).
> 
> I do agree though that it would be nice to have a portable and
> thread-safe way of determining whether or not a getcontext() is
> returning for the first time.  On ia64, I made getcontext() return
> this information in register r9, but that's obviously not a portable
> solution.

Some more details about the pseudo code:

save_both_stacks:
  ucontext_t ctx;
  long size;
  void *backing_store, *stack;
  getcontext (&ctx);

  /* save backing store */
  size = ctx.uc_mcontext.sc_ar_bsp -
         __libc_ia64_resgister_backing_store_base;
  backing_store = malloc (size);
  memcpy (backing_store, __libc_ia64_register_backing_store_base, size);

  /* save stack */
  size = top_of_stack - (long) &ctx;
  stack = malloc (size);
  memcpy (stack, &ctx, size);

restore_both_stacks:
  /* does the opposite; puts the save data back onto same addresses */

Does this explain it better ?

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

Cheers,
	stefan@lkcc.org



  parent reply	other threads:[~2001-09-27  7:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-25 19:35 [Linux-ia64] use of setcontext()/getcontext() stefan
2001-09-26 22:24 ` David Mosberger
2001-09-27  7:31 ` stefan [this message]
2001-09-27 17:38 ` David Mosberger
2001-09-29 16:53 ` stefan
2001-10-09  6:01 ` stefan
2001-10-10 22:17 ` David Mosberger
2001-10-11 11:26 ` stefan
2001-10-11 11:33 ` stefan
2001-10-15 18:16 ` David Mosberger
2001-10-15 18:19 ` David Mosberger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=marc-linux-ia64-105590698805266@msgid-missing \
    --to=stefan@lkcc.org \
    --cc=linux-ia64@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox