version 1.1.1.1, 2012/02/21 23:37:57
|
version 1.1.1.2, 2014/06/15 19:53:29
|
Line 146 struct _xmlRMutex {
|
Line 146 struct _xmlRMutex {
|
static pthread_key_t globalkey; |
static pthread_key_t globalkey; |
static pthread_t mainthread; |
static pthread_t mainthread; |
static pthread_once_t once_control = PTHREAD_ONCE_INIT; |
static pthread_once_t once_control = PTHREAD_ONCE_INIT; |
|
static pthread_once_t once_control_init = PTHREAD_ONCE_INIT; |
static pthread_mutex_t global_init_lock = PTHREAD_MUTEX_INITIALIZER; |
static pthread_mutex_t global_init_lock = PTHREAD_MUTEX_INITIALIZER; |
#elif defined HAVE_WIN32_THREADS |
#elif defined HAVE_WIN32_THREADS |
#if defined(HAVE_COMPILER_TLS) |
#if defined(HAVE_COMPILER_TLS) |
Line 251 xmlMutexLock(xmlMutexPtr tok)
|
Line 252 xmlMutexLock(xmlMutexPtr tok)
|
#ifdef DEBUG_THREADS |
#ifdef DEBUG_THREADS |
xmlGenericError(xmlGenericErrorContext, |
xmlGenericError(xmlGenericErrorContext, |
"xmlMutexLock():BeOS:Couldn't aquire semaphore\n"); |
"xmlMutexLock():BeOS:Couldn't aquire semaphore\n"); |
exit(); |
|
#endif |
#endif |
} |
} |
tok->tid = find_thread(NULL); |
tok->tid = find_thread(NULL); |
Line 439 __xmlGlobalInitMutexLock(void)
|
Line 439 __xmlGlobalInitMutexLock(void)
|
/* Make sure the global init lock is initialized and then lock it. */ |
/* Make sure the global init lock is initialized and then lock it. */ |
#ifdef HAVE_PTHREAD_H |
#ifdef HAVE_PTHREAD_H |
/* The mutex is statically initialized, so we just lock it. */ |
/* The mutex is statically initialized, so we just lock it. */ |
if (pthread_mutex_lock) | if (pthread_mutex_lock != NULL) |
pthread_mutex_lock(&global_init_lock); |
pthread_mutex_lock(&global_init_lock); |
#elif defined HAVE_WIN32_THREADS |
#elif defined HAVE_WIN32_THREADS |
LPCRITICAL_SECTION cs; |
LPCRITICAL_SECTION cs; |
Line 499 __xmlGlobalInitMutexLock(void)
|
Line 499 __xmlGlobalInitMutexLock(void)
|
#ifdef DEBUG_THREADS |
#ifdef DEBUG_THREADS |
xmlGenericError(xmlGenericErrorContext, |
xmlGenericError(xmlGenericErrorContext, |
"xmlGlobalInitMutexLock():BeOS:Couldn't acquire semaphore\n"); |
"xmlGlobalInitMutexLock():BeOS:Couldn't acquire semaphore\n"); |
exit(); |
|
#endif |
#endif |
} |
} |
#endif |
#endif |
Line 509 void
|
Line 508 void
|
__xmlGlobalInitMutexUnlock(void) |
__xmlGlobalInitMutexUnlock(void) |
{ |
{ |
#ifdef HAVE_PTHREAD_H |
#ifdef HAVE_PTHREAD_H |
if (pthread_mutex_unlock) | if (pthread_mutex_unlock != NULL) |
pthread_mutex_unlock(&global_init_lock); |
pthread_mutex_unlock(&global_init_lock); |
#elif defined HAVE_WIN32_THREADS |
#elif defined HAVE_WIN32_THREADS |
if (global_init_lock != NULL) { |
if (global_init_lock != NULL) { |
Line 915 xmlCleanupThreads(void)
|
Line 914 xmlCleanupThreads(void)
|
#ifdef HAVE_PTHREAD_H |
#ifdef HAVE_PTHREAD_H |
if ((libxml_is_threaded) && (pthread_key_delete != NULL)) |
if ((libxml_is_threaded) && (pthread_key_delete != NULL)) |
pthread_key_delete(globalkey); |
pthread_key_delete(globalkey); |
|
once_control = once_control_init; |
#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)) |
#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)) |
if (globalkey != TLS_OUT_OF_INDEXES) { |
if (globalkey != TLS_OUT_OF_INDEXES) { |
xmlGlobalStateCleanupHelperParams *p; |
xmlGlobalStateCleanupHelperParams *p; |
Line 954 xmlOnceInit(void)
|
Line 954 xmlOnceInit(void)
|
#ifdef HAVE_PTHREAD_H |
#ifdef HAVE_PTHREAD_H |
(void) pthread_key_create(&globalkey, xmlFreeGlobalState); |
(void) pthread_key_create(&globalkey, xmlFreeGlobalState); |
mainthread = pthread_self(); |
mainthread = pthread_self(); |
|
__xmlInitializeDict(); |
#elif defined(HAVE_WIN32_THREADS) |
#elif defined(HAVE_WIN32_THREADS) |
if (!run_once.done) { |
if (!run_once.done) { |
if (InterlockedIncrement(&run_once.control) == 1) { |
if (InterlockedIncrement(&run_once.control) == 1) { |
Line 961 xmlOnceInit(void)
|
Line 962 xmlOnceInit(void)
|
globalkey = TlsAlloc(); |
globalkey = TlsAlloc(); |
#endif |
#endif |
mainthread = GetCurrentThreadId(); |
mainthread = GetCurrentThreadId(); |
|
__xmlInitializeDict(); |
run_once.done = 1; |
run_once.done = 1; |
} else { |
} else { |
/* Another thread is working; give up our slice and |
/* Another thread is working; give up our slice and |
Line 974 xmlOnceInit(void)
|
Line 976 xmlOnceInit(void)
|
globalkey = tls_allocate(); |
globalkey = tls_allocate(); |
tls_set(globalkey, NULL); |
tls_set(globalkey, NULL); |
mainthread = find_thread(NULL); |
mainthread = find_thread(NULL); |
|
__xmlInitializeDict(); |
} else |
} else |
atomic_add(&run_once_init, -1); |
atomic_add(&run_once_init, -1); |
#endif |
#endif |