diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-06-11 20:07:07 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2012-06-11 20:20:05 +0100 |
commit | 9d1f0ac1e19d55cf020960ab95ef1750fd8915a8 (patch) | |
tree | d30855a0820288af1506c57bb444dc5dad66417f | |
parent | 4fddb35e247a2d81b9b78ca3543b97da9e9fce45 (diff) | |
download | mupdf-9d1f0ac1e19d55cf020960ab95ef1750fd8915a8.tar.xz |
Move to using sigsetjmp/siglongjmp on more platforms.
Previously we used to have a special case hack in for MacOS. Now
we call sigsetjmp/siglongjmp on all platforms that define __unix.
(i.e. pretty much all of them except windows).
-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. |