What is it that setjmp stores??

J

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.
 
R

Richard Bos

JS said:
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
 
R

Rich Gibbs

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:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top