Thread overview
what is jmp_buf / __JUMP_BUFFER
Apr 30, 2004
some
Apr 30, 2004
Kar G Lim
Re: what is the difference btw jmp_buf / __JUMP_BUFFER
Apr 30, 2004
some
Apr 30, 2004
Walter
April 30, 2004
using sc foo.c -e -l (where foo.c only contains a line #include <setjmp.h>)

I got the following output (see below).

My question is: is it true that in SC/DMC, jmp_buf is defined as just defined as
array: int[16] which is used in func setjmp(...) and longjmp(...)?

Then what is __JUMP_BUFFER ? is it used by any function at all?

Thanks.

================================================================ typedef int jmp_buf[16];

...

int __cdecl _setjmp(jmp_buf);
int __cdecl setjmp(jmp_buf);
void __cdecl longjmp(jmp_buf,int);

int __cdecl _inline_setjmp(jmp_buf);

..

typedef struct __JUMP_BUFFER {
unsigned long Ebp;
unsigned long Ebx;
unsigned long Edi;
unsigned long Esi;
unsigned long Esp;
unsigned long Eip;
unsigned long Except_Registration;
unsigned long TryLevel;
unsigned long Reserved;
unsigned long Unwind_Handler;
unsigned long ExceptData[6];
} _JUMP_BUFFER;
====================================================================


April 30, 2004
It is like taking a snapshot of all the registers up to the point of execution, store it somewhere, except one (AX/EAX) so that you can comeback to it as if nothing had happened.  In the Ix86 architecture, jmp_buf can be implemented as int[16].  The __JUMP_BUFFER is for the 32-bit stuff.

It can be used error recoveries, program restarts, or multithreadings.

See: S. Kofoed, Doctor Dobb's Journal Nov. 1995 for an implementation of that which is portable on Win32, Dos, Dosx and etc.


<some@where.com> wrote in message news:c6s623$2l5$1@digitaldaemon.com...
>
> using sc foo.c -e -l (where foo.c only contains a line #include
<setjmp.h>)
>
> I got the following output (see below).
>
> My question is: is it true that in SC/DMC, jmp_buf is defined as just
defined as
> array: int[16] which is used in func setjmp(...) and longjmp(...)?
>
> Then what is __JUMP_BUFFER ? is it used by any function at all?
>
> Thanks.
>
> ================================================================ typedef int jmp_buf[16];
>
> ...
>
> int __cdecl _setjmp(jmp_buf);
> int __cdecl setjmp(jmp_buf);
> void __cdecl longjmp(jmp_buf,int);
>
> int __cdecl _inline_setjmp(jmp_buf);
>
> ..
>
> typedef struct __JUMP_BUFFER {
> unsigned long Ebp;
> unsigned long Ebx;
> unsigned long Edi;
> unsigned long Esi;
> unsigned long Esp;
> unsigned long Eip;
> unsigned long Except_Registration;
> unsigned long TryLevel;
> unsigned long Reserved;
> unsigned long Unwind_Handler;
> unsigned long ExceptData[6];
> } _JUMP_BUFFER;
> ====================================================================
>
>


April 30, 2004
In article <c6sgcg$hj5$1@digitaldaemon.com>, Kar G Lim says...
>
>In the Ix86 architecture, jmp_buf can be
>implemented as int[16].  The __JUMP_BUFFER is for the 32-bit stuff.

Thanks for your reply.  I know the functionality of setjmp/longjmp and jmp_buf.

What I don't understand in SC/DMC is the difference between jmp_buf / __JUMP_BUFFER. (Maybe I should phrase my question more clearly.)

My system is Win2K.  So why both are defined when I run "dmc setjmp.h -e -l"? And __JUMP_BUFFER is not being used at all?

Thanks.


April 30, 2004
<some@where.com> wrote in message news:c6spl0$10bv$1@digitaldaemon.com...
> In article <c6sgcg$hj5$1@digitaldaemon.com>, Kar G Lim says...
> >
> >In the Ix86 architecture, jmp_buf can be
> >implemented as int[16].  The __JUMP_BUFFER is for the 32-bit stuff.
>
> Thanks for your reply.  I know the functionality of setjmp/longjmp and
jmp_buf.
>
> What I don't understand in SC/DMC is the difference between jmp_buf / __JUMP_BUFFER. (Maybe I should phrase my question more clearly.)
>
> My system is Win2K.  So why both are defined when I run "dmc
setjmp.h -e -l"?
> And __JUMP_BUFFER is not being used at all?

__JUMP_BUFFER can be mapped onto the anonymous contents of jmp_buf[_JBLEN] if you wanted to examine the register contents. Note that they are the same size.