Re: [xml] [patch] make libxml2 slightly more thread-friendly



Ted Phelps wrote:
+       /* Swap it into the global_init_lock */
+       InterlockedCompareExchangePointer(&global_init_lock, cs, NULL);
+
This causes the builds to fail under VC6 now. I have attached a patch that will call InterlockedCompareExchange if InterlockedCompareExchangePointer is not defined. Ted, since you made the original change and understand it all, can you check this change to make sure its correct? I basically took this from another project that ran into the same issue.

Another minor change in this patch is to use XMLCALL for the xmlDllMain function rather than WINAPI so the calling convention is correct.

Rob
Index: threads.c
===================================================================
--- threads.c   (revision 3585)
+++ threads.c   (working copy)
@@ -441,7 +441,11 @@
        InitializeCriticalSection(cs);
 
        /* Swap it into the global_init_lock */
+#ifdef InterlockedCompareExchangePointer
        InterlockedCompareExchangePointer(&global_init_lock, cs, NULL);
+#else  /* Use older void* version */
+    InterlockedCompareExchange((void**)&global_init_lock, (void*)cs, NULL);
+#endif /* InterlockedCompareExchangePointer */
 
        /* If another thread successfully recorded its critical
         * section in the global_init_lock then discard the one
@@ -912,7 +916,7 @@
  */
 #if defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || 
defined(LIBXML_STATIC_FOR_DLL))
 #if defined(LIBXML_STATIC_FOR_DLL)
-BOOL WINAPI xmlDllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 
+BOOL XMLCALL xmlDllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 
 #else
 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]