472,135 Members | 1,359 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,135 software developers and data experts.

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 1582
"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 leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.