From: chas williams <chas@cmf.nrl.navy.mil>
To: linux-ia64@vger.kernel.org
Subject: [Linux-ia64] setjmp/longjmp redux
Date: Thu, 14 Jun 2001 19:15:09 +0000 [thread overview]
Message-ID: <marc-linux-ia64-105590693005732@msgid-missing> (raw)
hi, new to the list but i did a little reading of the archives and it seems
that setjmp/longjmp cant do what i need -- switch the stack.
why do i want to do this? i am working on porting openafs which provides
its own thread library (called lwp) that is implemented with setjmp/longjmp.
what needs to be done in order to make this work? based on my reading
it seems that ar.rnat (???) need to be saved between the context switches?
i dont know much about the ia64 architecture so if someone could give me
some pointers i would be grateful.
the following code works, but only under cc -g. using cc -O fails. i assume
that i am getting 'lucky' using -g.
#include <stdio.h>
#include <setjmp.h>
#include <stdlib.h>
static int rc;
static jmp_buf env;
dump_jmp_buf(jmp_buf a)
{
int i;
long *ptr = (long *)a;
for ( i=0; i < 70; i++)
if (ptr[i] != 0) printf("(%d) 0x%lx\n",i, ptr[i]);
}
main()
{
char *altstack;
unsigned long *patcher;
int stacksize = 16*1024;
altstack = malloc(192*1024);
printf("altstack = %p\n", altstack);
printf("&rc = %p\n", &rc);
rc = setjmp(env);
printf("rc = %d\n", rc);
if (rc = 1)
{
printf("return from longjmp\n");
exit(0);
}
((unsigned long *)env)[0] = (unsigned long *)(altstack + stacksize - 32);
dump_jmp_buf(env);
printf("about to longjmp()...\n");
longjmp(env, 1);
}
next reply other threads:[~2001-06-14 19:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-06-14 19:15 chas williams [this message]
2001-06-14 20:06 ` [Linux-ia64] setjmp/longjmp redux 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-105590693005732@msgid-missing \
--to=chas@cmf.nrl.navy.mil \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.