Branch: Tag:

2015-11-27

2015-11-27 18:24:57 by Martin Nilsson <nilsson@fastmail.com>

setjmp and longjmp are standardized C89.

26:   #include "global.h"   #include <setjmp.h>    - #if defined(HAVE_SIGSETJMP) && defined(HAVE_SIGLONGJMP) - #define HAVE_AND_USE_SIGSETJMP - #define LOW_JMP_BUF sigjmp_buf - #define LOW_SETJMP(X) sigsetjmp(X, 0) - #define LOW_LONGJMP(X, Y) siglongjmp(X, Y) - #elif defined(HAVE__SETJMP) && defined(HAVE__LONGJMP) - #define HAVE_AND_USE__SETJMP - #define LOW_JMP_BUF jmp_buf - #define LOW_SETJMP(X) _setjmp(X) - #define LOW_LONGJMP(X, Y) _longjmp(X, Y) - #else - /* Assume we have setjmp and longjmp, they are after all defined by ANSI C. */ - #define HAVE_AND_USE_SETJMP - #define LOW_JMP_BUF jmp_buf - #define LOW_SETJMP(X) setjmp(X) - #define LOW_LONGJMP(X, Y) longjmp(X, Y) - #endif -  +    #if 1   PMOD_EXPORT extern const char msg_fatal_error[];   #define Pike_fatal \
105:   typedef struct JMP_BUF   {    struct JMP_BUF *previous; -  LOW_JMP_BUF recovery; +  jmp_buf recovery;    struct pike_frame *frame_pointer;    ptrdiff_t stack_pointer;    ptrdiff_t mark_sp;
146:   #endif      #define DEBUG_INIT_REC_ARGS , int on_stack, const char *location - #define SETJMP(X) LOW_SETJMP((init_recovery(&X, 0, 1, PERR_LOCATION())->recovery)) + #define SETJMP(X) setjmp(init_recovery(&X, 0, 1, PERR_LOCATION())->recovery)   #define SETJMP_SP(jmp, stack_pop_levels) \ -  LOW_SETJMP((init_recovery(&jmp, stack_pop_levels, 1, PERR_LOCATION())->recovery)) +  setjmp(init_recovery(&jmp, stack_pop_levels, 1, PERR_LOCATION())->recovery)   #else /* !PIKE_DEBUG */   #define DEBUG_INIT_REC_ARGS - #define SETJMP(X) LOW_SETJMP((init_recovery(&X, 0)->recovery)) + #define SETJMP(X) setjmp(init_recovery(&X, 0)->recovery)   #define SETJMP_SP(jmp, stack_pop_levels) \ -  LOW_SETJMP((init_recovery(&jmp, stack_pop_levels)->recovery)) +  setjmp(init_recovery(&jmp, stack_pop_levels)->recovery)   #define UNSETJMP(X) Pike_interpreter.recoveries=X.previous   #endif /* !PIKE_DEBUG */