18#ifdef LIBXML_CATALOG_ENABLED
21#ifdef LIBXML_SCHEMAS_ENABLED
37#if defined(HAVE_POSIX_THREADS) && \
38 defined(__GLIBC__) && \
39 __GLIBC__ * 100 + __GLIBC_MINOR__ >= 234
49#include <sys/single_threaded.h>
51#define XML_IS_THREADED() (!__libc_single_threaded)
52#define XML_IS_NEVER_THREADED() 0
54#elif defined(HAVE_POSIX_THREADS) && \
55 defined(__GLIBC__) && \
72#pragma weak pthread_mutex_init
73#pragma weak pthread_mutex_destroy
74#pragma weak pthread_mutex_lock
75#pragma weak pthread_mutex_unlock
76#pragma weak pthread_cond_init
77#pragma weak pthread_cond_destroy
78#pragma weak pthread_cond_wait
79#pragma weak pthread_equal
80#pragma weak pthread_self
81#pragma weak pthread_cond_signal
83#define XML_PTHREAD_WEAK
84#define XML_IS_THREADED() libxml_is_threaded
85#define XML_IS_NEVER_THREADED() (!libxml_is_threaded)
87static int libxml_is_threaded = -1;
91#define XML_IS_THREADED() 1
92#define XML_IS_NEVER_THREADED() 0
106#ifdef HAVE_POSIX_THREADS
107 pthread_mutex_t
lock;
109 unsigned int waiters;
112#elif defined HAVE_WIN32_THREADS
130#ifdef HAVE_POSIX_THREADS
133#elif defined HAVE_WIN32_THREADS
168#ifdef HAVE_POSIX_THREADS
171#elif defined HAVE_WIN32_THREADS
205#ifdef HAVE_POSIX_THREADS
211 pthread_mutex_lock(&tok->lock);
212#elif defined HAVE_WIN32_THREADS
229#ifdef HAVE_POSIX_THREADS
231 pthread_mutex_unlock(&tok->lock);
232#elif defined HAVE_WIN32_THREADS
254#ifdef HAVE_POSIX_THREADS
256 pthread_mutex_init(&tok->lock,
NULL);
259 pthread_cond_init(&tok->cv,
NULL);
261#elif defined HAVE_WIN32_THREADS
279#ifdef HAVE_POSIX_THREADS
281 pthread_mutex_destroy(&tok->lock);
282 pthread_cond_destroy(&tok->cv);
284#elif defined HAVE_WIN32_THREADS
301#ifdef HAVE_POSIX_THREADS
305 pthread_mutex_lock(&tok->lock);
307 if (pthread_equal(tok->tid, pthread_self())) {
309 pthread_mutex_unlock(&tok->lock);
314 pthread_cond_wait(&tok->cv, &tok->lock);
318 tok->tid = pthread_self();
320 pthread_mutex_unlock(&tok->lock);
321#elif defined HAVE_WIN32_THREADS
337#ifdef HAVE_POSIX_THREADS
341 pthread_mutex_lock(&tok->lock);
343 if (tok->held == 0) {
345 pthread_cond_signal(&tok->cv);
346 memset(&tok->tid, 0,
sizeof(tok->tid));
348 pthread_mutex_unlock(&tok->lock);
349#elif defined HAVE_WIN32_THREADS
374#ifdef HAVE_POSIX_THREADS
384#elif defined HAVE_WIN32_THREADS
449#ifdef HAVE_POSIX_THREADS
450static pthread_mutex_t global_init_lock = PTHREAD_MUTEX_INITIALIZER;
451#elif defined HAVE_WIN32_THREADS
463#ifdef HAVE_POSIX_THREADS
465#ifdef XML_PTHREAD_WEAK
471 if (libxml_is_threaded == -1)
473 (pthread_mutex_init !=
NULL) &&
474 (pthread_mutex_destroy !=
NULL) &&
475 (pthread_mutex_lock !=
NULL) &&
476 (pthread_mutex_unlock !=
NULL) &&
477 (pthread_cond_init !=
NULL) &&
478 (pthread_cond_destroy !=
NULL) &&
479 (pthread_cond_wait !=
NULL) &&
485 (pthread_self !=
NULL) &&
486 (pthread_cond_signal !=
NULL);
491 pthread_mutex_lock(&global_init_lock);
493#elif defined HAVE_WIN32_THREADS
498 if (global_init_lock ==
NULL) {
502 "xmlGlobalInitMutexLock: out of memory\n");
508#ifdef InterlockedCompareExchangePointer
519 if (global_init_lock !=
cs) {
533#ifdef HAVE_POSIX_THREADS
535 pthread_mutex_unlock(&global_init_lock);
536#elif defined HAVE_WIN32_THREADS
537 if (global_init_lock !=
NULL)
550#ifdef HAVE_POSIX_THREADS
551#elif defined HAVE_WIN32_THREADS
552 if (global_init_lock !=
NULL) {
554 free(global_init_lock);
555 global_init_lock =
NULL;
579#if defined(_WIN32) && \
580 !defined(LIBXML_THREAD_ALLOC_ENABLED) && \
581 (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
591#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
596#ifdef LIBXML_OUTPUT_ENABLED
597 xmlRegisterDefaultOutputCallbacks();
637#ifdef LIBXML_CATALOG_ENABLED
640#ifdef LIBXML_SCHEMAS_ENABLED
641 xmlSchemaCleanupTypes();
642 xmlRelaxNGCleanupTypes();
648#ifdef LIBXML_OUTPUT_ENABLED
649 xmlCleanupOutputCallbacks();
667#if defined(HAVE_ATTRIBUTE_DESTRUCTOR) && \
668 !defined(LIBXML_THREAD_ALLOC_ENABLED) && \
669 !defined(LIBXML_STATIC) && \
int __cdecl atexit(void(__cdecl *)(void))
void xmlInitEncodingInternal(void)
void xmlCleanupCharEncodingHandlers(void)
#define InterlockedCompareExchangePointer
#define InterlockedCompareExchange
#define memcpy(s1, s2, n)
XML_HIDDEN void xmlInitXPathInternal(void)
ATTRIBUTE_NO_SANITIZE_INTEGER void xmlInitRandom(void)
void xmlCleanupDictInternal(void)
void xmlCleanupRandom(void)
void xmlInitDictInternal(void)
void * xmlGenericErrorContext
xmlGenericErrorFunc xmlGenericError
void xmlInitGlobalsInternal(void)
void xmlCleanupGlobalsInternal(void)
XML_HIDDEN void xmlCleanupMemoryInternal(void)
XML_HIDDEN void xmlInitMemoryInternal(void)
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
xmlMutexPtr xmlNewMutex(void)
void xmlLockLibrary(void)
static int xmlParserInitialized
static void xmlGlobalInitMutexUnlock(void)
xmlRMutexPtr xmlNewRMutex(void)
void xmlFreeRMutex(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
#define XML_IS_THREADED()
void xmlCleanupParser(void)
void xmlInitThreads(void)
void xmlUnlockLibrary(void)
static void xmlGlobalInitMutexDestroy(void)
void xmlCleanupMutex(xmlMutexPtr mutex)
static int xmlParserInnerInitialized
void xmlRMutexUnlock(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
void xmlInitMutex(xmlMutexPtr mutex)
void xmlMutexLock(xmlMutexPtr tok)
void xmlMutexUnlock(xmlMutexPtr tok)
static void xmlGlobalInitMutexLock(void)
static xmlRMutexPtr xmlLibraryLock
void xmlRMutexLock(xmlRMutexPtr tok)
#define XML_IS_NEVER_THREADED()
void xmlFreeMutex(xmlMutexPtr tok)
void xmlCleanupThreads(void)
DWORD WINAPI GetCurrentThreadId(void)
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
XMLPUBFUN void xmlRegisterDefaultInputCallbacks(void)
XML_GLOBALS_IO XMLPUBFUN void xmlCleanupInputCallbacks(void)