mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-24 13:33:01 +03:00
If DllMain is used, rely on it working as expected. The old code seemed to attempt to free global state of other threads if, for some reason, the DllMain mechanism didn't work. In a static build, register a destructor with RegisterWaitForSingleObject. Make public functions xmlGetGlobalState and xmlInitializeGlobalState no-ops. Move initialization and registration of global state objects to xmlInitGlobalState. Lookup global state with xmlGetThreadLocalStorage which can be inlined nicely. Also cleanup global state when using TLS. xmlLastError must be reset.
36 lines
687 B
C
36 lines
687 B
C
#ifndef XML_THREADS_H_PRIVATE__
|
|
#define XML_THREADS_H_PRIVATE__
|
|
|
|
#include <libxml/threads.h>
|
|
|
|
#ifdef LIBXML_THREAD_ENABLED
|
|
#ifdef HAVE_PTHREAD_H
|
|
#include <pthread.h>
|
|
#define HAVE_POSIX_THREADS
|
|
#elif defined(_WIN32)
|
|
#define WIN32_LEAN_AND_MEAN
|
|
#include <windows.h>
|
|
#define HAVE_WIN32_THREADS
|
|
#endif
|
|
#endif
|
|
|
|
/*
|
|
* xmlMutex are a simple mutual exception locks
|
|
*/
|
|
struct _xmlMutex {
|
|
#ifdef HAVE_POSIX_THREADS
|
|
pthread_mutex_t lock;
|
|
#elif defined HAVE_WIN32_THREADS
|
|
CRITICAL_SECTION cs;
|
|
#else
|
|
int empty;
|
|
#endif
|
|
};
|
|
|
|
XML_HIDDEN void
|
|
xmlInitMutex(xmlMutexPtr mutex);
|
|
XML_HIDDEN void
|
|
xmlCleanupMutex(xmlMutexPtr mutex);
|
|
|
|
#endif /* XML_THREADS_H_PRIVATE__ */
|