[HarfBuzz] [PATCH] Implement threading primitives on Windows; fix compile error and leak

Bradley Grainger bgrainger at logos.com
Mon Apr 25 10:01:23 PDT 2011


0001: This fixes a compile error with MS Visual C++ 2010, due to "hb_atomic_int_set" being implemented as a "do ... while(0)" block. (It's likely to be an error on other non-GLib platforms, too.)

0002: This adds a "hb_mutex_free" macro that is called by hb_blob_destroy  (to free the mutex object created in "hb_blob_create"). If GLib is available, this is defined as g_static_mutex_free.
This fixes a bug that leaks GStaticMutex objects; from http://developer.gnome.org/glib/unstable/glib-Threads.html#g-static-mutex-free: "if you have a GStaticMutex as a member of a structure and the structure is freed, you should also free the GStaticMutex."

0003: This implements the HB threading primitives for MSVC on Windows. The "hb_atomic_int_*" macros are defined to use various interlocked intrinsics supported by the compiler. The "hb_mutex_*" macros are implemented with some new functions that delegate to Initialize/Enter/DeleteCriticalSection. 
Note that "#include <Windows.h>" is not allowed in hb-private.hh because hb-open-type-private.hh (which includes it) redefines "LONG", "ULONG" and other standard Win32 data types with different meanings. (This naming conflict is rather unfortunate and makes it a little more difficult to port the library to Windows.)

Bradley
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-hb_atomic_int_set-usage-for-MSVC.patch
Type: application/octet-stream
Size: 1227 bytes
Desc: 0001-Fix-hb_atomic_int_set-usage-for-MSVC.patch
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20110425/542b3910/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Free-mutex-when-blob-is-destroyed.patch
Type: application/octet-stream
Size: 1902 bytes
Desc: 0002-Free-mutex-when-blob-is-destroyed.patch
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20110425/542b3910/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Implement-threading-primitives-on-Windows.patch
Type: application/octet-stream
Size: 3271 bytes
Desc: 0003-Implement-threading-primitives-on-Windows.patch
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20110425/542b3910/attachment-0002.obj>


More information about the HarfBuzz mailing list