Skip to content

Commit

Permalink
Make the sigsetjmp change more robust. On systems that don't have
Browse files Browse the repository at this point in the history
sigsetjmp use setjmp.  Windows is of course weird in that it seems to
have sigsetjmp but not sigjmp_buf (??) so force it to use setjmp in
config.w32.h.in
  • Loading branch information
rlerdorf committed Mar 18, 2008
1 parent c9e0781 commit 10afe5d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Zend/Zend.m4
Expand Up @@ -109,7 +109,7 @@ dnl Checks for library functions.
AC_FUNC_VPRINTF
AC_FUNC_MEMCMP
AC_FUNC_ALLOCA
AC_CHECK_FUNCS(memcpy strdup getpid kill strtod strtol finite fpclass)
AC_CHECK_FUNCS(memcpy strdup getpid kill strtod strtol finite fpclass sigsetjmp)
AC_ZEND_BROKEN_SPRINTF
AC_CHECK_FUNCS(finite isfinite isinf isnan)
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend.c
Expand Up @@ -794,7 +794,7 @@ ZEND_API void _zend_bailout(char *filename, uint lineno) /* {{{ */
CG(unclean_shutdown) = 1;
CG(in_compilation) = EG(in_execution) = 0;
EG(current_execute_data) = NULL;
siglongjmp(*EG(bailout), FAILURE);
LONGJMP(*EG(bailout), FAILURE);
}
/* }}} */
END_EXTERN_C()
Expand Down
16 changes: 13 additions & 3 deletions Zend/zend.h
Expand Up @@ -520,13 +520,23 @@ END_EXTERN_C()

#define zend_bailout() _zend_bailout(__FILE__, __LINE__)

#ifdef HAVE_SIGSETJMP
# define SETJMP(a) sigsetjmp(a, 0)
# define LONGJMP(a,b) siglongjmp(a, b)
# define JMP_BUF sigjmp_buf
#else
# define SETJMP(a) setjmp(a)
# define LONGJMP(a,b) longjmp(a, b)
# define JMP_BUF jmp_buf
#endif

#define zend_try \
{ \
sigjmp_buf *__orig_bailout = EG(bailout); \
sigjmp_buf __bailout; \
JMP_BUF *__orig_bailout = EG(bailout); \
JMP_BUF __bailout; \
\
EG(bailout) = &__bailout; \
if (sigsetjmp(__bailout, 0)==0) {
if (SETJMP(__bailout)==0) {
#define zend_catch \
} else { \
EG(bailout) = __orig_bailout;
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_globals.h
Expand Up @@ -161,7 +161,7 @@ struct _zend_executor_globals {

HashTable included_files; /* files already included */

sigjmp_buf *bailout;
JMP_BUF *bailout;

int error_reporting;
int orig_error_reporting;
Expand Down
1 change: 1 addition & 0 deletions win32/build/config.w32.h.in
Expand Up @@ -54,6 +54,7 @@
#define NEED_ISBLANK 1
#define DISCARD_PATH 0
#undef HAVE_SETITIMER
#undef HAVE_SIGSETJMP
#undef HAVE_IODBC
#define HAVE_LIBDL 1
#define HAVE_GETTIMEOFDAY 1
Expand Down

0 comments on commit 10afe5d

Please sign in to comment.