summaryrefslogtreecommitdiff
path: root/src/cairo-compiler-private.h
diff options
context:
space:
mode:
authorJeff Muizelaar <jmuizelaar@mozilla.com>2009-02-19 13:31:55 -0500
committerJeff Muizelaar <jmuizelaar@mozilla.com>2009-02-19 13:31:55 -0500
commit126824f5e6279f56dab0c040394b6c326b848cf7 (patch)
tree13bb505ec4977205515d96bb3a1a881a2d145bd7 /src/cairo-compiler-private.h
parentd4227fc9126ffbb3a967aea1bc9795e7e64ee8e1 (diff)
downloadcairo-126824f5e6279f56dab0c040394b6c326b848cf7.tar.gz
Add CAIRO_ENSURE_UNIQUE macro and use it in _cairo_error()
When using MSVC, _cairo_error() can be folded into other identical functions. If that happens, _cairo_error isn't really useful anymore. Using the CAIRO_ENSURE_UNIQUE macro makes sure this doesn't happen.
Diffstat (limited to 'src/cairo-compiler-private.h')
-rw-r--r--src/cairo-compiler-private.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/cairo-compiler-private.h b/src/cairo-compiler-private.h
index bd7cccd9b..236246e66 100644
--- a/src/cairo-compiler-private.h
+++ b/src/cairo-compiler-private.h
@@ -172,6 +172,30 @@
#define inline __inline
#endif
+#ifdef _MSC_VER
+/* When compiling with /Gy and /OPT:ICF identical functions will be folded in together.
+ The CAIRO_ENSURE_UNIQUE macro ensures that a function is always unique and
+ will never be folded into another one. Something like this might eventually
+ be needed for GCC but it seems fine for now. */
+#define CAIRO_ENSURE_UNIQUE \
+ do { \
+ char func[] = __FUNCTION__; \
+ char file[] = __FILE__; \
+ __asm { \
+ jmp __internal_skip_line_no; \
+ _emit (__LINE__ & 0xff); \
+ _emit ((__LINE__>>8) & 0xff); \
+ _emit ((__LINE__>>16) & 0xff); \
+ _emit ((__LINE__>>24) & 0xff); \
+ lea eax, func; \
+ lea eax, file; \
+ __internal_skip_line_no: \
+ }; \
+ } while (0)
+#else
+#define CAIRO_ENSURE_UNIQUE do { } while (0)
+#endif
+
#ifdef __STRICT_ANSI__
#undef inline
#define inline __inline__