469,097 Members | 1,583 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,097 developers. It's quick & easy.

What is it that setjmp stores??

JS
I have this struct:
struct pcb {
void *(*start_routine) (void *);
void *arg;
jmp_buf state;
int stak[1024];
};
when I make a call to setjmp somwehere in my code what is it excately that
setjmp store in "state"?

setjmp(state)

I guess its registers and other "invisible" things that I don't explict
write in the code myself.
Nov 14 '05 #1
2 1461
"JS" <dsa.@asdf.com> wrote:
I have this struct:

struct pcb {
void *(*start_routine) (void *);
void *arg;
jmp_buf state;
int stak[1024];
};

when I make a call to setjmp somwehere in my code what is it excately that
setjmp store in "state"?


Whatever it needs to. The Standard doesn't specify the details, only
that a jmp_buf is an array and that it holds whatever information
setjmp() and longjmp() need to do their job - and that this includes
only the state necessary to make the jump, not the state of floating
point flags, open files, et cetera. This may include a stack pointer (in
fact, it will need to include _some_ kind of stack pointer, just not
necessarily the processor's SP register), and may include other details.

Richard
Nov 14 '05 #2
JS said the following, on 03/25/05 06:39:
I have this struct:
struct pcb {
void *(*start_routine) (void *);
void *arg;
jmp_buf state;
int stak[1024];
};

I think you need to:
#include <setjmp.h>
to get the standard things stored.

when I make a call to setjmp somwehere in my code what is it excately that
setjmp store in "state"?

setjmp(state)

I guess its registers and other "invisible" things that I don't explict
write in the code myself.


It also may store the phase of the moon, the dinner menu at your most
recent birthday party, the detailed contents of the entrails of various
local fowls, and other "magic stuff" that makes setjmp / longjmp work.

The standard tells you what you are entitled to expect. With respect to
any particular implementation, of course, you may know more -- but you
should not count on it if you want to write portable code.

--
Rich Gibbs
rg****@alumni.princeton.edu
Nov 14 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Jrferguson | last post: by
18 posts views Thread by Peter Smithson | last post: by
20 posts views Thread by JS | last post: by
4 posts views Thread by Sreekanth | last post: by
53 posts views Thread by jaso | last post: by
15 posts views Thread by rover8898 | last post: by
4 posts views Thread by Richard Jones | last post: by
4 posts views Thread by Gestorm | last post: by
reply views Thread by kglaser89 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.