diff options
author | Robin Watts <robin.watts@artifex.com> | 2011-12-08 14:24:33 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2011-12-08 14:24:33 +0000 |
commit | 0e6931ad400fbf2780bd06530a3135653f8c9b4f (patch) | |
tree | 392572d681660f3af0749f30f1102b42ff6d51c7 /fitz | |
parent | 31d174bb39bfbde8861882c128dafd383a8fed7d (diff) | |
download | mupdf-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')
-rw-r--r-- | fitz/base_error.c | 5 | ||||
-rw-r--r-- | fitz/fitz.h | 3 |
2 files changed, 8 insertions, 0 deletions
diff --git a/fitz/base_error.c b/fitz/base_error.c index b844fb6a..bd6801eb 100644 --- a/fitz/base_error.c +++ b/fitz/base_error.c @@ -2,6 +2,11 @@ /* Warning context */ +void fz_var_imp(void *var) +{ + var = var; /* Do nothing */ +} + void fz_flush_warnings(fz_context *ctx) { if (ctx->warn->count > 1) 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)) \ |