diff --git a/android/native/libxml2/globals.c b/android/native/libxml2/globals.c index 111993a2c2..1f70dbc1c2 100644 --- a/android/native/libxml2/globals.c +++ b/android/native/libxml2/globals.c @@ -28,11 +28,7 @@ /* * Helpful Macro */ -#ifdef LIBXML_THREAD_ENABLED -#define IS_MAIN_THREAD (xmlIsMainThread()) -#else #define IS_MAIN_THREAD 1 -#endif /* * Mutex to protect "ForNewThreads" variables @@ -574,58 +570,6 @@ __xmlLastError(void) { return (&xmlGetGlobalState()->xmlLastError); } -/* - * The following memory routines were apparently lost at some point, - * and were re-inserted at this point on June 10, 2004. Hope it's - * the right place for them :-) - */ -#if defined(LIBXML_THREAD_ALLOC_ENABLED) && defined(LIBXML_THREAD_ENABLED) -#undef xmlMalloc -xmlMallocFunc * -__xmlMalloc(void){ - if (IS_MAIN_THREAD) - return (&xmlMalloc); - else - return (&xmlGetGlobalState()->xmlMalloc); -} - -#undef xmlMallocAtomic -xmlMallocFunc * -__xmlMallocAtomic(void){ - if (IS_MAIN_THREAD) - return (&xmlMallocAtomic); - else - return (&xmlGetGlobalState()->xmlMallocAtomic); -} - -#undef xmlRealloc -xmlReallocFunc * -__xmlRealloc(void){ - if (IS_MAIN_THREAD) - return (&xmlRealloc); - else - return (&xmlGetGlobalState()->xmlRealloc); -} - -#undef xmlFree -xmlFreeFunc * -__xmlFree(void){ - if (IS_MAIN_THREAD) - return (&xmlFree); - else - return (&xmlGetGlobalState()->xmlFree); -} - -xmlStrdupFunc * -__xmlMemStrdup(void){ - if (IS_MAIN_THREAD) - return (&xmlMemStrdup); - else - return (&xmlGetGlobalState()->xmlMemStrdup); -} - -#endif - /* * Everything starting from the line below is * Automatically generated by build_glob.py. diff --git a/android/native/libxml2/libxml/globals.h b/android/native/libxml2/libxml/globals.h index bf60e7df2b..4f2b6c7a46 100644 --- a/android/native/libxml2/libxml/globals.h +++ b/android/native/libxml2/libxml/globals.h @@ -187,73 +187,14 @@ XMLPUBFUN xmlOutputBufferCreateFilenameFunc XMLCALL XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLCALL xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func); -/** DOC_DISABLE */ -/* - * In general the memory allocation entry points are not kept - * thread specific but this can be overridden by LIBXML_THREAD_ALLOC_ENABLED - * - xmlMalloc - * - xmlMallocAtomic - * - xmlRealloc - * - xmlMemStrdup - * - xmlFree - */ - -#ifdef LIBXML_THREAD_ALLOC_ENABLED -#ifdef LIBXML_THREAD_ENABLED -XMLPUBFUN xmlMallocFunc * XMLCALL __xmlMalloc(void); -#define xmlMalloc \ -(*(__xmlMalloc())) -#else -XMLPUBVAR xmlMallocFunc xmlMalloc; -#endif - -#ifdef LIBXML_THREAD_ENABLED -XMLPUBFUN xmlMallocFunc * XMLCALL __xmlMallocAtomic(void); -#define xmlMallocAtomic \ -(*(__xmlMallocAtomic())) -#else -XMLPUBVAR xmlMallocFunc xmlMallocAtomic; -#endif - -#ifdef LIBXML_THREAD_ENABLED -XMLPUBFUN xmlReallocFunc * XMLCALL __xmlRealloc(void); -#define xmlRealloc \ -(*(__xmlRealloc())) -#else -XMLPUBVAR xmlReallocFunc xmlRealloc; -#endif - -#ifdef LIBXML_THREAD_ENABLED -XMLPUBFUN xmlFreeFunc * XMLCALL __xmlFree(void); -#define xmlFree \ -(*(__xmlFree())) -#else -XMLPUBVAR xmlFreeFunc xmlFree; -#endif - -#ifdef LIBXML_THREAD_ENABLED -XMLPUBFUN xmlStrdupFunc * XMLCALL __xmlMemStrdup(void); -#define xmlMemStrdup \ -(*(__xmlMemStrdup())) -#else -XMLPUBVAR xmlStrdupFunc xmlMemStrdup; -#endif - -#else /* !LIBXML_THREAD_ALLOC_ENABLED */ XMLPUBVAR xmlMallocFunc xmlMalloc; XMLPUBVAR xmlMallocFunc xmlMallocAtomic; XMLPUBVAR xmlReallocFunc xmlRealloc; XMLPUBVAR xmlFreeFunc xmlFree; XMLPUBVAR xmlStrdupFunc xmlMemStrdup; -#endif /* LIBXML_THREAD_ALLOC_ENABLED */ XMLPUBFUN xmlError * XMLCALL __xmlLastError(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlLastError \ -(*(__xmlLastError())) -#else XMLPUBVAR xmlError xmlLastError; -#endif /* * Everything starting from the line below is @@ -263,217 +204,92 @@ XMLPUBVAR xmlError xmlLastError; XMLPUBFUN int * XMLCALL __oldXMLWDcompatibility(void); -#ifdef LIBXML_THREAD_ENABLED -#define oldXMLWDcompatibility \ -(*(__oldXMLWDcompatibility())) -#else XMLPUBVAR int oldXMLWDcompatibility; -#endif XMLPUBFUN xmlBufferAllocationScheme * XMLCALL __xmlBufferAllocScheme(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlBufferAllocScheme \ -(*(__xmlBufferAllocScheme())) -#else XMLPUBVAR xmlBufferAllocationScheme xmlBufferAllocScheme; -#endif XMLPUBFUN xmlBufferAllocationScheme XMLCALL xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v); XMLPUBFUN int * XMLCALL __xmlDefaultBufferSize(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlDefaultBufferSize \ -(*(__xmlDefaultBufferSize())) -#else XMLPUBVAR int xmlDefaultBufferSize; -#endif XMLPUBFUN int XMLCALL xmlThrDefDefaultBufferSize(int v); XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __xmlDefaultSAXHandler(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlDefaultSAXHandler \ -(*(__xmlDefaultSAXHandler())) -#else XMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler; -#endif XMLPUBFUN xmlSAXLocator * XMLCALL __xmlDefaultSAXLocator(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlDefaultSAXLocator \ -(*(__xmlDefaultSAXLocator())) -#else XMLPUBVAR xmlSAXLocator xmlDefaultSAXLocator; -#endif XMLPUBFUN int * XMLCALL __xmlDoValidityCheckingDefaultValue(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlDoValidityCheckingDefaultValue \ -(*(__xmlDoValidityCheckingDefaultValue())) -#else XMLPUBVAR int xmlDoValidityCheckingDefaultValue; -#endif XMLPUBFUN int XMLCALL xmlThrDefDoValidityCheckingDefaultValue(int v); XMLPUBFUN xmlGenericErrorFunc * XMLCALL __xmlGenericError(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlGenericError \ -(*(__xmlGenericError())) -#else XMLPUBVAR xmlGenericErrorFunc xmlGenericError; -#endif XMLPUBFUN xmlStructuredErrorFunc * XMLCALL __xmlStructuredError(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlStructuredError \ -(*(__xmlStructuredError())) -#else XMLPUBVAR xmlStructuredErrorFunc xmlStructuredError; -#endif XMLPUBFUN void * * XMLCALL __xmlGenericErrorContext(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlGenericErrorContext \ -(*(__xmlGenericErrorContext())) -#else XMLPUBVAR void * xmlGenericErrorContext; -#endif XMLPUBFUN void * * XMLCALL __xmlStructuredErrorContext(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlStructuredErrorContext \ -(*(__xmlStructuredErrorContext())) -#else XMLPUBVAR void * xmlStructuredErrorContext; -#endif XMLPUBFUN int * XMLCALL __xmlGetWarningsDefaultValue(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlGetWarningsDefaultValue \ -(*(__xmlGetWarningsDefaultValue())) -#else XMLPUBVAR int xmlGetWarningsDefaultValue; -#endif XMLPUBFUN int XMLCALL xmlThrDefGetWarningsDefaultValue(int v); XMLPUBFUN int * XMLCALL __xmlIndentTreeOutput(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlIndentTreeOutput \ -(*(__xmlIndentTreeOutput())) -#else XMLPUBVAR int xmlIndentTreeOutput; -#endif XMLPUBFUN int XMLCALL xmlThrDefIndentTreeOutput(int v); XMLPUBFUN const char * * XMLCALL __xmlTreeIndentString(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlTreeIndentString \ -(*(__xmlTreeIndentString())) -#else XMLPUBVAR const char * xmlTreeIndentString; -#endif XMLPUBFUN const char * XMLCALL xmlThrDefTreeIndentString(const char * v); XMLPUBFUN int * XMLCALL __xmlKeepBlanksDefaultValue(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlKeepBlanksDefaultValue \ -(*(__xmlKeepBlanksDefaultValue())) -#else XMLPUBVAR int xmlKeepBlanksDefaultValue; -#endif XMLPUBFUN int XMLCALL xmlThrDefKeepBlanksDefaultValue(int v); XMLPUBFUN int * XMLCALL __xmlLineNumbersDefaultValue(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlLineNumbersDefaultValue \ -(*(__xmlLineNumbersDefaultValue())) -#else XMLPUBVAR int xmlLineNumbersDefaultValue; -#endif XMLPUBFUN int XMLCALL xmlThrDefLineNumbersDefaultValue(int v); XMLPUBFUN int * XMLCALL __xmlLoadExtDtdDefaultValue(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlLoadExtDtdDefaultValue \ -(*(__xmlLoadExtDtdDefaultValue())) -#else XMLPUBVAR int xmlLoadExtDtdDefaultValue; -#endif XMLPUBFUN int XMLCALL xmlThrDefLoadExtDtdDefaultValue(int v); XMLPUBFUN int * XMLCALL __xmlParserDebugEntities(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlParserDebugEntities \ -(*(__xmlParserDebugEntities())) -#else XMLPUBVAR int xmlParserDebugEntities; -#endif XMLPUBFUN int XMLCALL xmlThrDefParserDebugEntities(int v); XMLPUBFUN const char * * XMLCALL __xmlParserVersion(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlParserVersion \ -(*(__xmlParserVersion())) -#else XMLPUBVAR const char * xmlParserVersion; -#endif XMLPUBFUN int * XMLCALL __xmlPedanticParserDefaultValue(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlPedanticParserDefaultValue \ -(*(__xmlPedanticParserDefaultValue())) -#else XMLPUBVAR int xmlPedanticParserDefaultValue; -#endif XMLPUBFUN int XMLCALL xmlThrDefPedanticParserDefaultValue(int v); XMLPUBFUN int * XMLCALL __xmlSaveNoEmptyTags(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlSaveNoEmptyTags \ -(*(__xmlSaveNoEmptyTags())) -#else XMLPUBVAR int xmlSaveNoEmptyTags; -#endif XMLPUBFUN int XMLCALL xmlThrDefSaveNoEmptyTags(int v); XMLPUBFUN int * XMLCALL __xmlSubstituteEntitiesDefaultValue(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlSubstituteEntitiesDefaultValue \ -(*(__xmlSubstituteEntitiesDefaultValue())) -#else XMLPUBVAR int xmlSubstituteEntitiesDefaultValue; -#endif XMLPUBFUN int XMLCALL xmlThrDefSubstituteEntitiesDefaultValue(int v); XMLPUBFUN xmlRegisterNodeFunc * XMLCALL __xmlRegisterNodeDefaultValue(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlRegisterNodeDefaultValue \ -(*(__xmlRegisterNodeDefaultValue())) -#else XMLPUBVAR xmlRegisterNodeFunc xmlRegisterNodeDefaultValue; -#endif XMLPUBFUN xmlDeregisterNodeFunc * XMLCALL __xmlDeregisterNodeDefaultValue(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlDeregisterNodeDefaultValue \ -(*(__xmlDeregisterNodeDefaultValue())) -#else XMLPUBVAR xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue; -#endif XMLPUBFUN xmlParserInputBufferCreateFilenameFunc * XMLCALL __xmlParserInputBufferCreateFilenameValue(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlParserInputBufferCreateFilenameValue \ -(*(__xmlParserInputBufferCreateFilenameValue())) -#else XMLPUBVAR xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue; -#endif XMLPUBFUN xmlOutputBufferCreateFilenameFunc * XMLCALL __xmlOutputBufferCreateFilenameValue(void); -#ifdef LIBXML_THREAD_ENABLED -#define xmlOutputBufferCreateFilenameValue \ -(*(__xmlOutputBufferCreateFilenameValue())) -#else XMLPUBVAR xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue; -#endif #ifdef __cplusplus } diff --git a/android/native/libxml2/libxml/xmlversion.h b/android/native/libxml2/libxml/xmlversion.h index 0aa421b1c7..0cf5068979 100644 --- a/android/native/libxml2/libxml/xmlversion.h +++ b/android/native/libxml2/libxml/xmlversion.h @@ -85,18 +85,6 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version); #define WITH_TRIO 1 #endif /* VMS */ -/** - * LIBXML_THREAD_ENABLED: - * - * Whether the thread support is configured in - */ -#if 0 -#if defined(_REENTRANT) || defined(__MT__) || \ - (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE - 0 >= 199506L)) -#define LIBXML_THREAD_ENABLED -#endif -#endif - /** * LIBXML_TREE_ENABLED: * diff --git a/android/native/libxml2/parser.c b/android/native/libxml2/parser.c index c2f6d392ff..fc8e038b1a 100644 --- a/android/native/libxml2/parser.c +++ b/android/native/libxml2/parser.c @@ -761,11 +761,7 @@ xmlHasFeature(xmlFeature feature) { switch (feature) { case XML_WITH_THREAD: -#ifdef LIBXML_THREAD_ENABLED - return(1); -#else return(0); -#endif case XML_WITH_TREE: #ifdef LIBXML_TREE_ENABLED return(1); @@ -12818,10 +12814,6 @@ xmlInitParser(void) { if (xmlParserInitialized != 0) return; -#ifdef LIBXML_THREAD_ENABLED - __xmlGlobalInitMutexLock(); - if (xmlParserInitialized == 0) { -#endif xmlInitThreads(); xmlInitGlobals(); if ((xmlGenericError == xmlGenericErrorDefaultFunc) || @@ -12835,10 +12827,6 @@ xmlInitParser(void) { xmlRegisterDefaultOutputCallbacks(); #endif /* LIBXML_OUTPUT_ENABLED */ xmlParserInitialized = 1; -#ifdef LIBXML_THREAD_ENABLED - } - __xmlGlobalInitMutexUnlock(); -#endif } /** diff --git a/android/native/libxml2/threads.c b/android/native/libxml2/threads.c index 1eeac0e176..564d9b3fea 100644 --- a/android/native/libxml2/threads.c +++ b/android/native/libxml2/threads.c @@ -42,8 +42,6 @@ #include #endif -/* #define DEBUG_THREADS */ - #ifdef HAVE_PTHREAD_H static int libxml_is_threaded = -1; @@ -172,9 +170,6 @@ static vint32 global_init_count = 0; static xmlRMutexPtr xmlLibraryLock = NULL; -#ifdef LIBXML_THREAD_ENABLED -static void xmlOnceInit(void); -#endif /** * xmlNewMutex: @@ -248,11 +243,6 @@ xmlMutexLock(xmlMutexPtr tok) WaitForSingleObject(tok->mutex, INFINITE); #elif defined HAVE_BEOS_THREADS if (acquire_sem(tok->sem) != B_NO_ERROR) { -#ifdef DEBUG_THREADS - xmlGenericError(xmlGenericErrorContext, - "xmlMutexLock():BeOS:Couldn't aquire semaphore\n"); - exit(); -#endif } tok->tid = find_thread(NULL); #endif @@ -496,11 +486,6 @@ __xmlGlobalInitMutexLock(void) /* Acquire the chosen semaphore */ if (acquire_sem(global_init_lock) != B_NO_ERROR) { -#ifdef DEBUG_THREADS - xmlGenericError(xmlGenericErrorContext, - "xmlGlobalInitMutexLock():BeOS:Couldn't acquire semaphore\n"); - exit(); -#endif } #endif } @@ -545,55 +530,6 @@ __xmlGlobalInitMutexDestroy(void) * * ************************************************************************/ -#ifdef LIBXML_THREAD_ENABLED -#ifdef xmlLastError -#undef xmlLastError -#endif - -/** - * xmlFreeGlobalState: - * @state: a thread global state - * - * xmlFreeGlobalState() is called when a thread terminates with a non-NULL - * global state. It is is used here to reclaim memory resources. - */ -static void -xmlFreeGlobalState(void *state) -{ - xmlGlobalState *gs = (xmlGlobalState *) state; - - /* free any memory allocated in the thread's xmlLastError */ - xmlResetError(&(gs->xmlLastError)); - free(state); -} - -/** - * xmlNewGlobalState: - * - * xmlNewGlobalState() allocates a global state. This structure is used to - * hold all data for use by a thread when supporting backwards compatibility - * of libxml2 to pre-thread-safe behaviour. - * - * Returns the newly allocated xmlGlobalStatePtr or NULL in case of error - */ -static xmlGlobalStatePtr -xmlNewGlobalState(void) -{ - xmlGlobalState *gs; - - gs = malloc(sizeof(xmlGlobalState)); - if (gs == NULL) { - xmlGenericError(xmlGenericErrorContext, - "xmlGetGlobalState: out of memory\n"); - return (NULL); - } - - memset(gs, 0, sizeof(xmlGlobalState)); - xmlInitializeGlobalState(gs); - return (gs); -} -#endif /* LIBXML_THREAD_ENABLED */ - #ifdef HAVE_PTHREAD_H #elif defined HAVE_WIN32_THREADS #if !defined(HAVE_COMPILER_TLS) @@ -808,9 +744,6 @@ xmlIsMainThread(void) xmlOnceInit(); #endif -#ifdef DEBUG_THREADS - xmlGenericError(xmlGenericErrorContext, "xmlIsMainThread()\n"); -#endif #ifdef HAVE_PTHREAD_H return (pthread_equal(mainthread,pthread_self())); #elif defined HAVE_WIN32_THREADS @@ -831,9 +764,6 @@ xmlIsMainThread(void) void xmlLockLibrary(void) { -#ifdef DEBUG_THREADS - xmlGenericError(xmlGenericErrorContext, "xmlLockLibrary()\n"); -#endif xmlRMutexLock(xmlLibraryLock); } @@ -846,9 +776,6 @@ xmlLockLibrary(void) void xmlUnlockLibrary(void) { -#ifdef DEBUG_THREADS - xmlGenericError(xmlGenericErrorContext, "xmlUnlockLibrary()\n"); -#endif xmlRMutexUnlock(xmlLibraryLock); } @@ -909,9 +836,6 @@ xmlInitThreads(void) void xmlCleanupThreads(void) { -#ifdef DEBUG_THREADS - xmlGenericError(xmlGenericErrorContext, "xmlCleanupThreads()\n"); -#endif #ifdef HAVE_PTHREAD_H if ((libxml_is_threaded) && (pthread_key_delete != NULL)) pthread_key_delete(globalkey); @@ -937,49 +861,6 @@ xmlCleanupThreads(void) #endif } -#ifdef LIBXML_THREAD_ENABLED - -/** - * xmlOnceInit - * - * xmlOnceInit() is used to initialize the value of mainthread for use - * in other routines. This function should only be called using - * pthread_once() in association with the once_control variable to ensure - * that the function is only called once. See man pthread_once for more - * details. - */ -static void -xmlOnceInit(void) -{ -#ifdef HAVE_PTHREAD_H - (void) pthread_key_create(&globalkey, xmlFreeGlobalState); - mainthread = pthread_self(); -#elif defined(HAVE_WIN32_THREADS) - if (!run_once.done) { - if (InterlockedIncrement(&run_once.control) == 1) { -#if !defined(HAVE_COMPILER_TLS) - globalkey = TlsAlloc(); -#endif - mainthread = GetCurrentThreadId(); - run_once.done = 1; - } else { - /* Another thread is working; give up our slice and - * wait until they're done. */ - while (!run_once.done) - Sleep(0); - } - } -#elif defined HAVE_BEOS_THREADS - if (atomic_add(&run_once_init, 1) == 0) { - globalkey = tls_allocate(); - tls_set(globalkey, NULL); - mainthread = find_thread(NULL); - } else - atomic_add(&run_once_init, -1); -#endif -} -#endif - /** * DllMain: * @hinstDLL: handle to DLL instance diff --git a/android/native/libxml2/xmlmemory.c b/android/native/libxml2/xmlmemory.c index a0ab9539cd..16bd076b84 100644 --- a/android/native/libxml2/xmlmemory.c +++ b/android/native/libxml2/xmlmemory.c @@ -62,7 +62,6 @@ void xmlMallocBreakpoint(void); * * ************************************************************************/ -#if !defined(LIBXML_THREAD_ENABLED) && !defined(LIBXML_THREAD_ALLOC_ENABLED) #ifdef xmlMalloc #undef xmlMalloc #endif @@ -72,7 +71,6 @@ void xmlMallocBreakpoint(void); #ifdef xmlMemStrdup #undef xmlMemStrdup #endif -#endif /* * Each of the blocks allocated begin with a header containing informations