<div dir="ltr"><div><div class="gmail_extra"><div class="gmail_quote">On Thu, Dec 12, 2013 at 1:11 AM, Alex Christensen <span dir="ltr"><<a href="mailto:alex.christensen@flexsim.com" target="_blank">alex.christensen@flexsim.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">My coworker Anthony and I have been working on the WinCairo port of WebKit which includes pixman. We were having it crash when delay loading the dlls on Windows XP because of improper usage of __declspec(thread). We are using the MinGW code with Visual Studio. I'm not familiar with pixman coding style, but here's something similar to our fix. The windows.h stuff is a little hacky, but the important part is the removal of the __declspec(thread).</div>
</blockquote><div><br>It looks like you are hitting the issue I mentioned here:<br><a href="http://lists.freedesktop.org/archives/pixman/2013-October/003016.html" target="_blank">http://lists.freedesktop.org/archives/pixman/2013-October/003016.html</a><br>
<br></div><div>The patch fixes the issue by using the dynamic TLS allocation even on MSVC, but unfortunately the patch does not fix the long-standing issue of TLS leakage on win32: each thread that uses pixman would allocate a fast-path table, but it would never deallocate it.</div>
<div><a href="https://bugs.freedesktop.org/show_bug.cgi?id=34842" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=34842</a><br><br>I have a (somewhat outdated) branch which also provides TLS deallocation: <a href="http://cgit.freedesktop.org/~ranma42/pixman/log/?h=wip/simpleops-to-master">http://cgit.freedesktop.org/~ranma42/pixman/log/?h=wip/simpleops-to-master</a><br>
Shall I rebase it send in a patchset?<br>
</div><div>It depends on the simpleops header library, whose latest changes are in the c11 branch (which, as the name states, tries to have a C11-like API):<br><a href="http://cgit.freedesktop.org/~ranma42/simpleops/log/?h=c11" target="_blank">http://cgit.freedesktop.org/~ranma42/simpleops/log/?h=c11</a><br>
</div><div><br>I agree that the simpleops code is quite unconvenient to view manually, because it is mostly based on templates, but the library includes a view "utility" that can be used to compare different implementations (it aligns them and highlights the differences).<br>
For example, the TSS implementations can be seen here: <a href="http://people.freedesktop.org/~ranma42/simpleops/index.html?tss/impl/_dispatch.h" target="_blank">http://people.freedesktop.org/~ranma42/simpleops/index.html?tss/impl/_dispatch.h</a> or, if you checked out simpleops locally, opening file:///path/to/simpleops/index.html?atomic/impl/_dispatch.h<br>
</div><div>Added bonuses coming with simpleops are: the API is documented (ok, somewhat... threading is quite complicated and the C11 specification provides a much more extensive explanation of memory model etc) and there is a test suite ( <a href="http://cgit.freedesktop.org/~ranma42/simpleops-test/log/?h=c11" target="_blank">http://cgit.freedesktop.org/~ranma42/simpleops-test/log/?h=c11</a> ) which tries to set up some not-so-obvious configurations (combinations of static & dynamic linking, doing things at library load time, etc).<br>
</div><div><br>
</div><div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>
<br></div><div><a href="http://msdn.microsoft.com/en-us/library/yx1x886y.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/yx1x886y.aspx</a></div><div><a href="https://github.com/bfulgham/WinCairoRequirements" target="_blank">https://github.com/bfulgham/WinCairoRequirements</a></div>
<div><br></div><div>There are probably not many people using pixman on Windows XP with delay loaded dlls, but I think a fix similar to this ought to be upstreamed:<br><div><br></div><div><div>diff --git a/pixman-compiler.h b/pixman-compiler.h</div>
<div>--- a/pixman-compiler.h</div><div>+++ b/pixman-compiler.h</div><div>@@ -118,6 +118,6 @@</div><div> # define PIXMAN_GET_THREAD_LOCAL(name)<span style="white-space:pre-wrap"> </span>\</div><div> (&name)</div>
<div> </div><div>-#elif defined(__MINGW32__)</div><div>+#elif defined(__MINGW32__) || defined(_MSC_VER)</div><div> </div><div> # define _NO_W32_PSEUDO_MODIFIERS</div><div>@@ -122,3 +122,5 @@</div><div> </div><div> # define _NO_W32_PSEUDO_MODIFIERS</div>
<div>+</div><div>+#if !defined(_MSC_VER)</div><div> # include <windows.h></div><div>@@ -124,4 +126,5 @@</div><div> # include <windows.h></div><div>+#endif</div><div> </div><div> # define PIXMAN_DEFINE_THREAD_LOCAL(type, name)<span style="white-space:pre-wrap"> </span>\</div>
<div> static volatile int tls_ ## name ## _initialized = 0;<span style="white-space:pre-wrap"> </span>\</div><div>@@ -171,13 +174,6 @@</div><div> # define PIXMAN_GET_THREAD_LOCAL(name)<span style="white-space:pre-wrap"> </span>\</div>
<div> tls_ ## name ## _get ()</div><div> </div><div>-#elif defined(_MSC_VER)</div><div>-</div><div>-# define PIXMAN_DEFINE_THREAD_LOCAL(type, name)<span style="white-space:pre-wrap"> </span>\</div><div>- static __declspec(thread) type name</div>
<div>-# define PIXMAN_GET_THREAD_LOCAL(name)<span style="white-space:pre-wrap"> </span>\</div><div>- (&name)</div><div>-</div><div> #elif defined(HAVE_PTHREADS)</div><div> </div><div> #include <pthread.h></div>
<div>diff --git a/pixman-implementation.c b/pixman-implementation.c</div><div>--- a/pixman-implementation.c</div><div>+++ b/pixman-implementation.c</div><div>@@ -63,6 +63,10 @@</div><div> } cache [N_CACHED_FAST_PATHS];</div>
<div> } cache_t;</div><div> </div><div>+#if defined(_MSC_VER)</div><div>+# include <windows.h></div><div>+#endif</div><div>+</div><div> PIXMAN_DEFINE_THREAD_LOCAL (cache_t, fast_path_cache);</div><div> </div><div>
static void</div><div><br></div><div><br></div>-- <br><p> </p><p>Alex Christensen</p><p>FlexSim Software Products, Inc.</p><p><i><span style="font-size:10pt">1577 North Technology Way | Building A | Suite 2300 | Orem, Utah 84097</span></i></p>
<p><i><span style="font-size:10pt">Voice: <a value="+18012246914" style="color:rgb(17,85,204)">801-224-6914</a> | Fax: <a value="+18012246984" style="color:rgb(17,85,204)">801-224-6984</a></span></i></p><p><i><span style="font-size:10pt">Email:</span></i><span style="font-size:10pt"> </span><a href="mailto:kimw@flexsim.com" style="color:rgb(17,85,204)" target="_blank"><span style="font-size:10pt;color:blue">alexc@flexsim.com</span></a><span style="font-size:10pt"></span></p>
<p><i><span style="font-size:10pt">URL:</span></i><span style="font-size:10pt"> </span><a href="http://www.flexsim.com/" style="color:rgb(17,85,204)" target="_blank"><span style="font-size:10pt;color:blue">www.flexsim.com</span></a><span style="font-size:10pt"></span></p>
<p> </p><p><span style="font-size:10pt">----------------------------------------------------------------------------------------</span><span style="font-size:12pt"> <br></span><span style="font-size:10pt">This message may contain confidential information, and is</span><span style="font-size:12pt"> </span><span style="font-size:10pt">intended</span></p>
<p><span style="font-size:10pt">only for the use of the individual(s) to whom it is</span><span style="font-size:12pt"> </span><span style="font-size:10pt">addressed.</span><span style="font-size:12pt"> <br></span><span style="font-size:10pt">----------------------------------------------------------------------------------------</span></p>
</div></div></div>
<br>_______________________________________________<br>
Pixman mailing list<br>
<a href="mailto:Pixman@lists.freedesktop.org" target="_blank">Pixman@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/pixman" target="_blank">http://lists.freedesktop.org/mailman/listinfo/pixman</a><br>
<br></blockquote></div><br></div></div></div>