summaryrefslogtreecommitdiff
path: root/fitz/fitz.h
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2011-12-08 14:24:33 +0000
committerRobin Watts <robin.watts@artifex.com>2011-12-08 14:24:33 +0000
commit0e6931ad400fbf2780bd06530a3135653f8c9b4f (patch)
tree392572d681660f3af0749f30f1102b42ff6d51c7 /fitz/fitz.h
parent31d174bb39bfbde8861882c128dafd383a8fed7d (diff)
downloadmupdf-0e6931ad400fbf2780bd06530a3135653f8c9b4f.tar.xz
Move from volatile to fz_var.
When using exceptions (which are implemented using setjmp/longjmp), we need to be careful to ensure that variable values get written back before any exception happens. Previously we've done that using volatile, but that produces nasty warnings (and unduly limits the compilers freedom to optimise). Here we introduce a new macro fz_var that passes the address of the variable out of scope. This means that the compiler has to ensure that any changes to its value are written back to memory before calling any out of scope function.
Diffstat (limited to 'fitz/fitz.h')
-rw-r--r--fitz/fitz.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/fitz/fitz.h b/fitz/fitz.h
index 70d14086..09c12c14 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -162,6 +162,9 @@ struct fz_error_context_s
char message[256];
};
+void fz_var_imp(void *);
+#define fz_var(var) fz_var_imp((void *)&(var))
+
#define fz_try(ctx) \
if (fz_push_try(ctx->error), \
!setjmp(ctx->error->stack[ctx->error->top].buffer)) \