www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - what is jmp_buf / __JUMP_BUFFER

↑ ↓ ← some where.com writes:
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;
====================================================================
Apr 29 2004
↑ ↓ "Kar G Lim" <klim machealth.com.au> writes:
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

 I got the following output (see below).

 My question is: is it true that in SC/DMC, jmp_buf is defined as just

 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;
 ====================================================================

Apr 29 2004
↑ ↓ some where.com writes:
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.
Apr 29 2004
↑ ↓ → "Walter" <newshound digitalmars.com> writes:
<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

 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

 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.
Apr 30 2004