From 40f0327a83b31d3b95de7739e55b23f0977c84f9 Mon Sep 17 00:00:00 2001 From: roytam1 Date: Wed, 23 Mar 2022 01:36:36 +0800 Subject: [PATCH] pixman: restore XP hacks --- gfx/cairo/libpixman/src/moz.build | 3 +++ gfx/cairo/libpixman/src/pixman-compiler.h | 4 +++- gfx/cairo/libpixman/src/pixman-implementation.c | 12 ++++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/gfx/cairo/libpixman/src/moz.build b/gfx/cairo/libpixman/src/moz.build index 02e2582452..137993008d 100644 --- a/gfx/cairo/libpixman/src/moz.build +++ b/gfx/cairo/libpixman/src/moz.build @@ -67,6 +67,9 @@ LOCAL_INCLUDES += [ if CONFIG['MOZ_USE_PTHREADS']: DEFINES['HAVE_PTHREADS'] = True +if CONFIG['_MSC_VER']: + DEFINES['PIXMAN_USE_XP_DLL_TLS_WORKAROUND'] = True + DEFINES['PACKAGE'] = 'mozpixman' DEFINES['_USE_MATH_DEFINES'] = True diff --git a/gfx/cairo/libpixman/src/pixman-compiler.h b/gfx/cairo/libpixman/src/pixman-compiler.h index d852f93798..89426dad71 100644 --- a/gfx/cairo/libpixman/src/pixman-compiler.h +++ b/gfx/cairo/libpixman/src/pixman-compiler.h @@ -139,10 +139,12 @@ # define PIXMAN_GET_THREAD_LOCAL(name) \ (&name) -#elif defined(__MINGW32__) +#elif defined(__MINGW32__) || defined(PIXMAN_USE_XP_DLL_TLS_WORKAROUND) # define _NO_W32_PSEUDO_MODIFIERS # include +#undef IN +#undef OUT # define PIXMAN_DEFINE_THREAD_LOCAL(type, name) \ static volatile int tls_ ## name ## _initialized = 0; \ diff --git a/gfx/cairo/libpixman/src/pixman-implementation.c b/gfx/cairo/libpixman/src/pixman-implementation.c index 2c7de4c687..e8ff705ca9 100644 --- a/gfx/cairo/libpixman/src/pixman-implementation.c +++ b/gfx/cairo/libpixman/src/pixman-implementation.c @@ -90,7 +90,15 @@ _pixman_implementation_lookup_composite (pixman_implementation_t *toplevel, /* Check cache for fast paths */ cache = PIXMAN_GET_THREAD_LOCAL (fast_path_cache); - for (i = 0; i < N_CACHED_FAST_PATHS; ++i) + /* Bug 1324130 - For compatibility with Windows XP, we have to use Tls + * functions for the per-thread fast-path cache instead of the safer + * __declspec(thread) mechanism. If the Tls functions fail to set up + * the storage for some reason, cache will end up null here. As a + * temporary workaround, just check that cache is not null before + * using it. The implementation lookup will still function without the + * fast-path cache, however, it will incur a slow linear search. + */ + if (cache) for (i = 0; i < N_CACHED_FAST_PATHS; ++i) { const pixman_fast_path_t *info = &(cache->cache[i].fast_path); @@ -162,7 +170,7 @@ _pixman_implementation_lookup_composite (pixman_implementation_t *toplevel, return; update_cache: - if (i) + if (cache && i) { while (i--) cache->cache[i + 1] = cache->cache[i];