--- mstools/posix/h/setjmp.h 2018/08/09 18:22:18 1.1 +++ mstools/posix/h/setjmp.h 2018/08/09 18:24:35 1.1.1.2 @@ -9,10 +9,16 @@ * declarations for those routines. * [ANSI/System V] * +* The setjmp() that will be used by those who include this file +* is _setjmpex, which is safe for use with try/except/finally, +* but is slow. See and for more. +* ****/ #ifndef _INC_SETJMP +#include + #ifndef __cplusplus @@ -48,6 +54,12 @@ #endif /* + * Posix programs use _setjmpex by default. + */ + +#define setjmp _setjmpex + +/* * Definitions specific to particular setjmp implementations. */ #ifdef _M_IX86 @@ -55,8 +67,23 @@ /* * MS C8-32 or older MS C6-386 compilers */ -#define setjmp _setjmp #define _JBLEN 8 +#define _JBTYPE int + +/* + * Define jump buffer layout for x86 setjmp/longjmp + */ + +typedef struct __JUMP_BUFFER { + unsigned long Ebp; + unsigned long Ebx; + unsigned long Edi; + unsigned long Esi; + unsigned long Esp; + unsigned long Eip; + unsigned long Registration; + unsigned long TryLevel; +} _JUMP_BUFFER; #else @@ -69,18 +96,60 @@ #endif -#if ( defined(_M_RX000) || defined(M_MRX000) || defined(MIPS) || defined(MIPS) ) +#if ( defined(_M_RX000) || defined(_MIPS_) ) /* - * All MIPS implementation need _JBLEN of 2 + * All MIPS implementations need _JBLEN of 16 */ -#define _JBLEN 2 +#define _JBLEN 16 +#define _JBTYPE double + +/* + * Define jump buffer layout for MIPS setjmp/longjmp. + */ + +typedef struct __JUMP_BUFFER { + unsigned long FltF20; + unsigned long FltF21; + unsigned long FltF22; + unsigned long FltF23; + unsigned long FltF24; + unsigned long FltF25; + unsigned long FltF26; + unsigned long FltF27; + unsigned long FltF28; + unsigned long FltF29; + unsigned long FltF30; + unsigned long FltF31; + unsigned long IntS0; + unsigned long IntS1; + unsigned long IntS2; + unsigned long IntS3; + unsigned long IntS4; + unsigned long IntS5; + unsigned long IntS6; + unsigned long IntS7; + unsigned long IntS8; + unsigned long Type; + unsigned long Fir; +} _JUMP_BUFFER; + +#endif + +#if defined(_ALPHA_) + +/* + * All ALPHA implementations need _JBLEN of 2 + */ + +#define _JBLEN 2 +#define _JBTYPE double #endif /* define the buffer type for holding the state information */ #ifndef _JMP_BUF_DEFINED -typedef int jmp_buf[_JBLEN]; +typedef _JBTYPE jmp_buf[_JBLEN]; #define _JMP_BUF_DEFINED #endif @@ -89,16 +158,15 @@ typedef int jmp_buf[_JBLEN]; /* * sigjmp buf is just a jmp_buf plus an int to say whether the sigmask * is saved or not, and a sigmask_t for the mask if it is saved. - */ + */ -typedef unsigned long sigjmp_buf[_JBLEN + 2]; +typedef _JBTYPE sigjmp_buf[_JBLEN + 2]; #endif /* _SIGJMP_BUF_DEFINED */ -#define sigsetjmp(env, save) \ - (((save) ? ((env)[_JBLEN] = 1, sigprocmask(SIG_SETMASK, \ - &(env)[_JBLEN + 1], 0)) \ - : ((env)[_JBLEN] = 0)), \ - setjmp(&(env)[0])) +extern _JBTYPE * _CRTAPI1 _sigjmp_store_mask(sigjmp_buf, int); + +#define sigsetjmp(_env, _save) \ + setjmp(_sigjmp_store_mask((_env), (_save))) /* function prototypes */