diff options
-rw-r--r-- | fitz/fitz.h | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/fitz/fitz.h b/fitz/fitz.h index 1892bc5e..ee00b2ed 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -22,18 +22,10 @@ #include "memento.h" -/* - Some versions of setjmp/longjmp (notably MacOSX and ios) store/restore - signal handlers too. We don't alter signal handlers within mupdf, so - there is no need for us to store/restore - hence we use the - non-restoring variants. This makes a large speed difference. -*/ #ifdef __APPLE__ -#define fz_setjmp _setjmp -#define fz_longjmp _longjmp -#else -#define fz_setjmp setjmp -#define fz_longjmp longjmp +#define HAVE_SIGSETJMP +#elif defined(__unix) +#define HAVE_SIGSETJMP #endif #ifdef __ANDROID__ @@ -156,12 +148,30 @@ struct fz_alloc_context_s void (*free)(void *, void *); }; +/* + Where possible (i.e. on platforms on which they are provided), use + sigsetjmp/siglongjmp in preference to setjmp/longjmp. We don't alter + signal handlers within mupdf, so there is no need for us to + store/restore them - hence we use the non-restoring variants. This + makes a large speed difference on MacOSX (and probably other + platforms too. +*/ +#ifdef HAVE_SIGSETJMP +#define fz_setjmp(BUF) sigsetjmp(BUF, 0) +#define fz_longjmp(BUF,VAL) siglongjmp(BUF, VAL) +#define fz_jmp_buf sigjmp_buf +#else +#define fz_setjmp(BUF) setjmp(BUF) +#define fz_longjmp(BUF,VAL) longjmp(BUF,VAL) +#define fz_jmp_buf jmp_buf +#endif + struct fz_error_context_s { int top; struct { int code; - jmp_buf buffer; + fz_jmp_buf buffer; } stack[256]; char message[256]; }; @@ -169,6 +179,7 @@ struct fz_error_context_s void fz_var_imp(void *); #define fz_var(var) fz_var_imp((void *)&(var)) + /* Exception macro definitions. Just treat these as a black box - pay no attention to the man behind the curtain. |