mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-03 15:54:39 +00:00
(Libxml2) Take out threads support
This commit is contained in:
parent
78d0edc4aa
commit
67fb8485c6
@ -430,14 +430,12 @@ LIBXML2
|
|||||||
#include "../../deps/libxml2/parser.c"
|
#include "../../deps/libxml2/parser.c"
|
||||||
#include "../../deps/libxml2/parserInternals.c"
|
#include "../../deps/libxml2/parserInternals.c"
|
||||||
#include "../../deps/libxml2/SAX2.c"
|
#include "../../deps/libxml2/SAX2.c"
|
||||||
#include "../../deps/libxml2/libxml_threads.c"
|
|
||||||
#include "../../deps/libxml2/tree.c"
|
#include "../../deps/libxml2/tree.c"
|
||||||
#include "../../deps/libxml2/uri.c"
|
#include "../../deps/libxml2/uri.c"
|
||||||
#include "../../deps/libxml2/valid.c"
|
#include "../../deps/libxml2/valid.c"
|
||||||
#include "../../deps/libxml2/xmlIO.c"
|
#include "../../deps/libxml2/xmlIO.c"
|
||||||
#include "../../deps/libxml2/xmlmemory.c"
|
#include "../../deps/libxml2/xmlmemory.c"
|
||||||
#include "../../deps/libxml2/xmlreader.c"
|
#include "../../deps/libxml2/xmlreader.c"
|
||||||
#include "../../deps/libxml2/xmlsave.c"
|
|
||||||
#include "../../deps/libxml2/xmlstring.c"
|
#include "../../deps/libxml2/xmlstring.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
17
deps/libxml2/dict.c
vendored
17
deps/libxml2/dict.c
vendored
@ -121,12 +121,6 @@ struct _xmlDict {
|
|||||||
int seed;
|
int seed;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* A mutex for modifying the reference counter for shared
|
|
||||||
* dictionaries.
|
|
||||||
*/
|
|
||||||
static xmlRMutexPtr xmlDictMutex = NULL;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Whether the dictionary mutex was initialized.
|
* Whether the dictionary mutex was initialized.
|
||||||
*/
|
*/
|
||||||
@ -143,9 +137,6 @@ static int xmlInitializeDict(void) {
|
|||||||
if (xmlDictInitialized)
|
if (xmlDictInitialized)
|
||||||
return(1);
|
return(1);
|
||||||
|
|
||||||
if ((xmlDictMutex = xmlNewRMutex()) == NULL)
|
|
||||||
return(0);
|
|
||||||
|
|
||||||
#ifdef DICT_RANDOMIZATION
|
#ifdef DICT_RANDOMIZATION
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
#endif
|
#endif
|
||||||
@ -163,8 +154,6 @@ xmlDictCleanup(void) {
|
|||||||
if (!xmlDictInitialized)
|
if (!xmlDictInitialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xmlFreeRMutex(xmlDictMutex);
|
|
||||||
|
|
||||||
xmlDictInitialized = 0;
|
xmlDictInitialized = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,9 +508,7 @@ xmlDictReference(xmlDictPtr dict) {
|
|||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
if (dict == NULL) return -1;
|
if (dict == NULL) return -1;
|
||||||
xmlRMutexLock(xmlDictMutex);
|
|
||||||
dict->ref_counter++;
|
dict->ref_counter++;
|
||||||
xmlRMutexUnlock(xmlDictMutex);
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,15 +654,11 @@ xmlDictFree(xmlDictPtr dict) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* decrement the counter, it may be shared by a parser and docs */
|
/* decrement the counter, it may be shared by a parser and docs */
|
||||||
xmlRMutexLock(xmlDictMutex);
|
|
||||||
dict->ref_counter--;
|
dict->ref_counter--;
|
||||||
if (dict->ref_counter > 0) {
|
if (dict->ref_counter > 0) {
|
||||||
xmlRMutexUnlock(xmlDictMutex);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlRMutexUnlock(xmlDictMutex);
|
|
||||||
|
|
||||||
if (dict->subdict != NULL) {
|
if (dict->subdict != NULL) {
|
||||||
xmlDictFree(dict->subdict);
|
xmlDictFree(dict->subdict);
|
||||||
}
|
}
|
||||||
|
162
deps/libxml2/elfgcchack.h
vendored
162
deps/libxml2/elfgcchack.h
vendored
@ -50,7 +50,6 @@
|
|||||||
#include "libxml/xmlmemory.h"
|
#include "libxml/xmlmemory.h"
|
||||||
#include "libxml/xmlreader.h"
|
#include "libxml/xmlreader.h"
|
||||||
#include "libxml/xmlregexp.h"
|
#include "libxml/xmlregexp.h"
|
||||||
#include "libxml/xmlsave.h"
|
|
||||||
#include "libxml/xmlschemas.h"
|
#include "libxml/xmlschemas.h"
|
||||||
#include "libxml/xmlschemastypes.h"
|
#include "libxml/xmlschemastypes.h"
|
||||||
#include "libxml/xmlstring.h"
|
#include "libxml/xmlstring.h"
|
||||||
@ -719,17 +718,6 @@ extern __typeof (xmlCleanupParser) xmlCleanupParser__internal_alias __attribute(
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef bottom_threads
|
|
||||||
#undef xmlCleanupThreads
|
|
||||||
extern __typeof (xmlCleanupThreads) xmlCleanupThreads __attribute((alias("xmlCleanupThreads__internal_alias")));
|
|
||||||
#else
|
|
||||||
#ifndef xmlCleanupThreads
|
|
||||||
extern __typeof (xmlCleanupThreads) xmlCleanupThreads__internal_alias __attribute((visibility("hidden")));
|
|
||||||
#define xmlCleanupThreads xmlCleanupThreads__internal_alias
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef bottom_parserInternals
|
#ifdef bottom_parserInternals
|
||||||
#undef xmlClearNodeInfoSeq
|
#undef xmlClearNodeInfoSeq
|
||||||
extern __typeof (xmlClearNodeInfoSeq) xmlClearNodeInfoSeq __attribute((alias("xmlClearNodeInfoSeq__internal_alias")));
|
extern __typeof (xmlClearNodeInfoSeq) xmlClearNodeInfoSeq __attribute((alias("xmlClearNodeInfoSeq__internal_alias")));
|
||||||
@ -1601,16 +1589,6 @@ extern __typeof (xmlFreeInputStream) xmlFreeInputStream__internal_alias __attrib
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef bottom_threads
|
|
||||||
#undef xmlFreeMutex
|
|
||||||
extern __typeof (xmlFreeMutex) xmlFreeMutex __attribute((alias("xmlFreeMutex__internal_alias")));
|
|
||||||
#else
|
|
||||||
#ifndef xmlFreeMutex
|
|
||||||
extern __typeof (xmlFreeMutex) xmlFreeMutex__internal_alias __attribute((visibility("hidden")));
|
|
||||||
#define xmlFreeMutex xmlFreeMutex__internal_alias
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef bottom_tree
|
#ifdef bottom_tree
|
||||||
#undef xmlFreeNode
|
#undef xmlFreeNode
|
||||||
extern __typeof (xmlFreeNode) xmlFreeNode __attribute((alias("xmlFreeNode__internal_alias")));
|
extern __typeof (xmlFreeNode) xmlFreeNode __attribute((alias("xmlFreeNode__internal_alias")));
|
||||||
@ -1701,16 +1679,6 @@ extern __typeof (xmlFreePropList) xmlFreePropList__internal_alias __attribute((v
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef bottom_threads
|
|
||||||
#undef xmlFreeRMutex
|
|
||||||
extern __typeof (xmlFreeRMutex) xmlFreeRMutex __attribute((alias("xmlFreeRMutex__internal_alias")));
|
|
||||||
#else
|
|
||||||
#ifndef xmlFreeRMutex
|
|
||||||
extern __typeof (xmlFreeRMutex) xmlFreeRMutex__internal_alias __attribute((visibility("hidden")));
|
|
||||||
#define xmlFreeRMutex xmlFreeRMutex__internal_alias
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef bottom_valid
|
#ifdef bottom_valid
|
||||||
#undef xmlFreeRefTable
|
#undef xmlFreeRefTable
|
||||||
extern __typeof (xmlFreeRefTable) xmlFreeRefTable __attribute((alias("xmlFreeRefTable__internal_alias")));
|
extern __typeof (xmlFreeRefTable) xmlFreeRefTable __attribute((alias("xmlFreeRefTable__internal_alias")));
|
||||||
@ -1903,16 +1871,6 @@ extern __typeof (xmlGetExternalEntityLoader) xmlGetExternalEntityLoader__interna
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef bottom_threads
|
|
||||||
#undef xmlGetGlobalState
|
|
||||||
extern __typeof (xmlGetGlobalState) xmlGetGlobalState __attribute((alias("xmlGetGlobalState__internal_alias")));
|
|
||||||
#else
|
|
||||||
#ifndef xmlGetGlobalState
|
|
||||||
extern __typeof (xmlGetGlobalState) xmlGetGlobalState__internal_alias __attribute((visibility("hidden")));
|
|
||||||
#define xmlGetGlobalState xmlGetGlobalState__internal_alias
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef bottom_valid
|
#ifdef bottom_valid
|
||||||
#undef xmlGetID
|
#undef xmlGetID
|
||||||
extern __typeof (xmlGetID) xmlGetID __attribute((alias("xmlGetID__internal_alias")));
|
extern __typeof (xmlGetID) xmlGetID __attribute((alias("xmlGetID__internal_alias")));
|
||||||
@ -2047,16 +2005,6 @@ extern __typeof (xmlGetRefs) xmlGetRefs__internal_alias __attribute((visibility(
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef bottom_threads
|
|
||||||
#undef xmlGetThreadId
|
|
||||||
extern __typeof (xmlGetThreadId) xmlGetThreadId __attribute((alias("xmlGetThreadId__internal_alias")));
|
|
||||||
#else
|
|
||||||
#ifndef xmlGetThreadId
|
|
||||||
extern __typeof (xmlGetThreadId) xmlGetThreadId__internal_alias __attribute((visibility("hidden")));
|
|
||||||
#define xmlGetThreadId xmlGetThreadId__internal_alias
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef bottom_xmlstring
|
#ifdef bottom_xmlstring
|
||||||
#undef xmlGetUTF8Char
|
#undef xmlGetUTF8Char
|
||||||
extern __typeof (xmlGetUTF8Char) xmlGetUTF8Char __attribute((alias("xmlGetUTF8Char__internal_alias")));
|
extern __typeof (xmlGetUTF8Char) xmlGetUTF8Char __attribute((alias("xmlGetUTF8Char__internal_alias")));
|
||||||
@ -2397,16 +2345,6 @@ extern __typeof (xmlInitParserCtxt) xmlInitParserCtxt__internal_alias __attribut
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef bottom_threads
|
|
||||||
#undef xmlInitThreads
|
|
||||||
extern __typeof (xmlInitThreads) xmlInitThreads __attribute((alias("xmlInitThreads__internal_alias")));
|
|
||||||
#else
|
|
||||||
#ifndef xmlInitThreads
|
|
||||||
extern __typeof (xmlInitThreads) xmlInitThreads__internal_alias __attribute((visibility("hidden")));
|
|
||||||
#define xmlInitThreads xmlInitThreads__internal_alias
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef bottom_globals
|
#ifdef bottom_globals
|
||||||
#undef xmlInitializeGlobalState
|
#undef xmlInitializeGlobalState
|
||||||
extern __typeof (xmlInitializeGlobalState) xmlInitializeGlobalState __attribute((alias("xmlInitializeGlobalState__internal_alias")));
|
extern __typeof (xmlInitializeGlobalState) xmlInitializeGlobalState __attribute((alias("xmlInitializeGlobalState__internal_alias")));
|
||||||
@ -2518,16 +2456,6 @@ extern __typeof (xmlIsLetter) xmlIsLetter__internal_alias __attribute((visibilit
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef bottom_threads
|
|
||||||
#undef xmlIsMainThread
|
|
||||||
extern __typeof (xmlIsMainThread) xmlIsMainThread __attribute((alias("xmlIsMainThread__internal_alias")));
|
|
||||||
#else
|
|
||||||
#ifndef xmlIsMainThread
|
|
||||||
extern __typeof (xmlIsMainThread) xmlIsMainThread__internal_alias __attribute((visibility("hidden")));
|
|
||||||
#define xmlIsMainThread xmlIsMainThread__internal_alias
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef bottom_valid
|
#ifdef bottom_valid
|
||||||
#undef xmlIsMixedElement
|
#undef xmlIsMixedElement
|
||||||
extern __typeof (xmlIsMixedElement) xmlIsMixedElement __attribute((alias("xmlIsMixedElement__internal_alias")));
|
extern __typeof (xmlIsMixedElement) xmlIsMixedElement __attribute((alias("xmlIsMixedElement__internal_alias")));
|
||||||
@ -2558,16 +2486,6 @@ extern __typeof (xmlIsRef) xmlIsRef__internal_alias __attribute((visibility("hid
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef bottom_xmlsave
|
|
||||||
#undef xmlIsXHTML
|
|
||||||
extern __typeof (xmlIsXHTML) xmlIsXHTML __attribute((alias("xmlIsXHTML__internal_alias")));
|
|
||||||
#else
|
|
||||||
#ifndef xmlIsXHTML
|
|
||||||
extern __typeof (xmlIsXHTML) xmlIsXHTML__internal_alias __attribute((visibility("hidden")));
|
|
||||||
#define xmlIsXHTML xmlIsXHTML__internal_alias
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef bottom_parserInternals
|
#ifdef bottom_parserInternals
|
||||||
#undef xmlKeepBlanksDefault
|
#undef xmlKeepBlanksDefault
|
||||||
extern __typeof (xmlKeepBlanksDefault) xmlKeepBlanksDefault __attribute((alias("xmlKeepBlanksDefault__internal_alias")));
|
extern __typeof (xmlKeepBlanksDefault) xmlKeepBlanksDefault __attribute((alias("xmlKeepBlanksDefault__internal_alias")));
|
||||||
@ -2870,16 +2788,6 @@ extern __typeof (xmlLoadExternalEntity) xmlLoadExternalEntity__internal_alias __
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef bottom_threads
|
|
||||||
#undef xmlLockLibrary
|
|
||||||
extern __typeof (xmlLockLibrary) xmlLockLibrary __attribute((alias("xmlLockLibrary__internal_alias")));
|
|
||||||
#else
|
|
||||||
#ifndef xmlLockLibrary
|
|
||||||
extern __typeof (xmlLockLibrary) xmlLockLibrary__internal_alias __attribute((visibility("hidden")));
|
|
||||||
#define xmlLockLibrary xmlLockLibrary__internal_alias
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef bottom_xmlmemory
|
#ifdef bottom_xmlmemory
|
||||||
#undef xmlMallocAtomicLoc
|
#undef xmlMallocAtomicLoc
|
||||||
extern __typeof (xmlMallocAtomicLoc) xmlMallocAtomicLoc __attribute((alias("xmlMallocAtomicLoc__internal_alias")));
|
extern __typeof (xmlMallocAtomicLoc) xmlMallocAtomicLoc __attribute((alias("xmlMallocAtomicLoc__internal_alias")));
|
||||||
@ -3030,26 +2938,6 @@ extern __typeof (xmlMemoryStrdup) xmlMemoryStrdup__internal_alias __attribute((v
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef bottom_threads
|
|
||||||
#undef xmlMutexLock
|
|
||||||
extern __typeof (xmlMutexLock) xmlMutexLock __attribute((alias("xmlMutexLock__internal_alias")));
|
|
||||||
#else
|
|
||||||
#ifndef xmlMutexLock
|
|
||||||
extern __typeof (xmlMutexLock) xmlMutexLock__internal_alias __attribute((visibility("hidden")));
|
|
||||||
#define xmlMutexLock xmlMutexLock__internal_alias
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef bottom_threads
|
|
||||||
#undef xmlMutexUnlock
|
|
||||||
extern __typeof (xmlMutexUnlock) xmlMutexUnlock __attribute((alias("xmlMutexUnlock__internal_alias")));
|
|
||||||
#else
|
|
||||||
#ifndef xmlMutexUnlock
|
|
||||||
extern __typeof (xmlMutexUnlock) xmlMutexUnlock__internal_alias __attribute((visibility("hidden")));
|
|
||||||
#define xmlMutexUnlock xmlMutexUnlock__internal_alias
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef bottom_tree
|
#ifdef bottom_tree
|
||||||
#undef xmlNewCDataBlock
|
#undef xmlNewCDataBlock
|
||||||
extern __typeof (xmlNewCDataBlock) xmlNewCDataBlock __attribute((alias("xmlNewCDataBlock__internal_alias")));
|
extern __typeof (xmlNewCDataBlock) xmlNewCDataBlock __attribute((alias("xmlNewCDataBlock__internal_alias")));
|
||||||
@ -3286,16 +3174,6 @@ extern __typeof (xmlNewInputStream) xmlNewInputStream__internal_alias __attribut
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef bottom_threads
|
|
||||||
#undef xmlNewMutex
|
|
||||||
extern __typeof (xmlNewMutex) xmlNewMutex __attribute((alias("xmlNewMutex__internal_alias")));
|
|
||||||
#else
|
|
||||||
#ifndef xmlNewMutex
|
|
||||||
extern __typeof (xmlNewMutex) xmlNewMutex__internal_alias __attribute((visibility("hidden")));
|
|
||||||
#define xmlNewMutex xmlNewMutex__internal_alias
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef bottom_tree
|
#ifdef bottom_tree
|
||||||
#undef xmlNewNode
|
#undef xmlNewNode
|
||||||
extern __typeof (xmlNewNode) xmlNewNode __attribute((alias("xmlNewNode__internal_alias")));
|
extern __typeof (xmlNewNode) xmlNewNode __attribute((alias("xmlNewNode__internal_alias")));
|
||||||
@ -3378,16 +3256,6 @@ extern __typeof (xmlNewProp) xmlNewProp__internal_alias __attribute((visibility(
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef bottom_threads
|
|
||||||
#undef xmlNewRMutex
|
|
||||||
extern __typeof (xmlNewRMutex) xmlNewRMutex __attribute((alias("xmlNewRMutex__internal_alias")));
|
|
||||||
#else
|
|
||||||
#ifndef xmlNewRMutex
|
|
||||||
extern __typeof (xmlNewRMutex) xmlNewRMutex__internal_alias __attribute((visibility("hidden")));
|
|
||||||
#define xmlNewRMutex xmlNewRMutex__internal_alias
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef bottom_tree
|
#ifdef bottom_tree
|
||||||
#undef xmlNewReference
|
#undef xmlNewReference
|
||||||
extern __typeof (xmlNewReference) xmlNewReference __attribute((alias("xmlNewReference__internal_alias")));
|
extern __typeof (xmlNewReference) xmlNewReference __attribute((alias("xmlNewReference__internal_alias")));
|
||||||
@ -4513,26 +4381,6 @@ extern __typeof (xmlPushInput) xmlPushInput__internal_alias __attribute((visibil
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef bottom_threads
|
|
||||||
#undef xmlRMutexLock
|
|
||||||
extern __typeof (xmlRMutexLock) xmlRMutexLock __attribute((alias("xmlRMutexLock__internal_alias")));
|
|
||||||
#else
|
|
||||||
#ifndef xmlRMutexLock
|
|
||||||
extern __typeof (xmlRMutexLock) xmlRMutexLock__internal_alias __attribute((visibility("hidden")));
|
|
||||||
#define xmlRMutexLock xmlRMutexLock__internal_alias
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef bottom_threads
|
|
||||||
#undef xmlRMutexUnlock
|
|
||||||
extern __typeof (xmlRMutexUnlock) xmlRMutexUnlock __attribute((alias("xmlRMutexUnlock__internal_alias")));
|
|
||||||
#else
|
|
||||||
#ifndef xmlRMutexUnlock
|
|
||||||
extern __typeof (xmlRMutexUnlock) xmlRMutexUnlock__internal_alias __attribute((visibility("hidden")));
|
|
||||||
#define xmlRMutexUnlock xmlRMutexUnlock__internal_alias
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef bottom_parser
|
#ifdef bottom_parser
|
||||||
#undef xmlReadDoc
|
#undef xmlReadDoc
|
||||||
extern __typeof (xmlReadDoc) xmlReadDoc __attribute((alias("xmlReadDoc__internal_alias")));
|
extern __typeof (xmlReadDoc) xmlReadDoc __attribute((alias("xmlReadDoc__internal_alias")));
|
||||||
@ -6700,16 +6548,6 @@ extern __typeof (xmlUnlinkNode) xmlUnlinkNode__internal_alias __attribute((visib
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef bottom_threads
|
|
||||||
#undef xmlUnlockLibrary
|
|
||||||
extern __typeof (xmlUnlockLibrary) xmlUnlockLibrary __attribute((alias("xmlUnlockLibrary__internal_alias")));
|
|
||||||
#else
|
|
||||||
#ifndef xmlUnlockLibrary
|
|
||||||
extern __typeof (xmlUnlockLibrary) xmlUnlockLibrary__internal_alias __attribute((visibility("hidden")));
|
|
||||||
#define xmlUnlockLibrary xmlUnlockLibrary__internal_alias
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(LIBXML_TREE_ENABLED)
|
#if defined(LIBXML_TREE_ENABLED)
|
||||||
#ifdef bottom_tree
|
#ifdef bottom_tree
|
||||||
#undef xmlUnsetNsProp
|
#undef xmlUnsetNsProp
|
||||||
|
136
deps/libxml2/globals.c
vendored
136
deps/libxml2/globals.c
vendored
@ -23,16 +23,6 @@
|
|||||||
#include <libxml/xmlmemory.h>
|
#include <libxml/xmlmemory.h>
|
||||||
#include <libxml/threads.h>
|
#include <libxml/threads.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* Helpful Macro
|
|
||||||
*/
|
|
||||||
#define IS_MAIN_THREAD 1
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Mutex to protect "ForNewThreads" variables
|
|
||||||
*/
|
|
||||||
static xmlMutexPtr xmlThrDefMutex = NULL;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlInitGlobals:
|
* xmlInitGlobals:
|
||||||
*
|
*
|
||||||
@ -40,8 +30,6 @@ static xmlMutexPtr xmlThrDefMutex = NULL;
|
|||||||
*/
|
*/
|
||||||
void xmlInitGlobals(void)
|
void xmlInitGlobals(void)
|
||||||
{
|
{
|
||||||
if (xmlThrDefMutex == NULL)
|
|
||||||
xmlThrDefMutex = xmlNewMutex();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,11 +39,6 @@ void xmlInitGlobals(void)
|
|||||||
*/
|
*/
|
||||||
void xmlCleanupGlobals(void)
|
void xmlCleanupGlobals(void)
|
||||||
{
|
{
|
||||||
if (xmlThrDefMutex != NULL) {
|
|
||||||
xmlFreeMutex(xmlThrDefMutex);
|
|
||||||
xmlThrDefMutex = NULL;
|
|
||||||
}
|
|
||||||
__xmlGlobalInitMutexDestroy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
@ -368,10 +351,6 @@ xmlInitializeGlobalState(xmlGlobalStatePtr gs)
|
|||||||
/*
|
/*
|
||||||
* Perform initialization as required by libxml
|
* Perform initialization as required by libxml
|
||||||
*/
|
*/
|
||||||
if (xmlThrDefMutex == NULL)
|
|
||||||
xmlInitGlobals();
|
|
||||||
|
|
||||||
xmlMutexLock(xmlThrDefMutex);
|
|
||||||
|
|
||||||
gs->oldXMLWDcompatibility = 0;
|
gs->oldXMLWDcompatibility = 0;
|
||||||
gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef;
|
gs->xmlBufferAllocScheme = xmlBufferAllocSchemeThrDef;
|
||||||
@ -410,8 +389,6 @@ xmlInitializeGlobalState(xmlGlobalStatePtr gs)
|
|||||||
gs->xmlParserInputBufferCreateFilenameValue = xmlParserInputBufferCreateFilenameValueThrDef;
|
gs->xmlParserInputBufferCreateFilenameValue = xmlParserInputBufferCreateFilenameValueThrDef;
|
||||||
gs->xmlOutputBufferCreateFilenameValue = xmlOutputBufferCreateFilenameValueThrDef;
|
gs->xmlOutputBufferCreateFilenameValue = xmlOutputBufferCreateFilenameValueThrDef;
|
||||||
memset(&gs->xmlLastError, 0, sizeof(xmlError));
|
memset(&gs->xmlLastError, 0, sizeof(xmlError));
|
||||||
|
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -420,21 +397,17 @@ xmlInitializeGlobalState(xmlGlobalStatePtr gs)
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
|
xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
|
||||||
xmlMutexLock(xmlThrDefMutex);
|
|
||||||
xmlGenericErrorContextThrDef = ctx;
|
xmlGenericErrorContextThrDef = ctx;
|
||||||
if (handler != NULL)
|
if (handler != NULL)
|
||||||
xmlGenericErrorThrDef = handler;
|
xmlGenericErrorThrDef = handler;
|
||||||
else
|
else
|
||||||
xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
|
xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
|
xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
|
||||||
xmlMutexLock(xmlThrDefMutex);
|
|
||||||
xmlStructuredErrorContextThrDef = ctx;
|
xmlStructuredErrorContextThrDef = ctx;
|
||||||
xmlStructuredErrorThrDef = handler;
|
xmlStructuredErrorThrDef = handler;
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -460,12 +433,10 @@ xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func)
|
|||||||
{
|
{
|
||||||
xmlRegisterNodeFunc old;
|
xmlRegisterNodeFunc old;
|
||||||
|
|
||||||
xmlMutexLock(xmlThrDefMutex);
|
|
||||||
old = xmlRegisterNodeDefaultValueThrDef;
|
old = xmlRegisterNodeDefaultValueThrDef;
|
||||||
|
|
||||||
__xmlRegisterCallbacks = 1;
|
__xmlRegisterCallbacks = 1;
|
||||||
xmlRegisterNodeDefaultValueThrDef = func;
|
xmlRegisterNodeDefaultValueThrDef = func;
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
|
||||||
|
|
||||||
return(old);
|
return(old);
|
||||||
}
|
}
|
||||||
@ -493,12 +464,10 @@ xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func)
|
|||||||
{
|
{
|
||||||
xmlDeregisterNodeFunc old;
|
xmlDeregisterNodeFunc old;
|
||||||
|
|
||||||
xmlMutexLock(xmlThrDefMutex);
|
|
||||||
old = xmlDeregisterNodeDefaultValueThrDef;
|
old = xmlDeregisterNodeDefaultValueThrDef;
|
||||||
|
|
||||||
__xmlRegisterCallbacks = 1;
|
__xmlRegisterCallbacks = 1;
|
||||||
xmlDeregisterNodeDefaultValueThrDef = func;
|
xmlDeregisterNodeDefaultValueThrDef = func;
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
|
||||||
|
|
||||||
return(old);
|
return(old);
|
||||||
}
|
}
|
||||||
@ -508,14 +477,12 @@ xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilena
|
|||||||
{
|
{
|
||||||
xmlParserInputBufferCreateFilenameFunc old;
|
xmlParserInputBufferCreateFilenameFunc old;
|
||||||
|
|
||||||
xmlMutexLock(xmlThrDefMutex);
|
|
||||||
old = xmlParserInputBufferCreateFilenameValueThrDef;
|
old = xmlParserInputBufferCreateFilenameValueThrDef;
|
||||||
if (old == NULL) {
|
if (old == NULL) {
|
||||||
old = __xmlParserInputBufferCreateFilename;
|
old = __xmlParserInputBufferCreateFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlParserInputBufferCreateFilenameValueThrDef = func;
|
xmlParserInputBufferCreateFilenameValueThrDef = func;
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
|
||||||
|
|
||||||
return(old);
|
return(old);
|
||||||
}
|
}
|
||||||
@ -525,10 +492,8 @@ xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc fun
|
|||||||
{
|
{
|
||||||
xmlOutputBufferCreateFilenameFunc old;
|
xmlOutputBufferCreateFilenameFunc old;
|
||||||
|
|
||||||
xmlMutexLock(xmlThrDefMutex);
|
|
||||||
old = xmlOutputBufferCreateFilenameValueThrDef;
|
old = xmlOutputBufferCreateFilenameValueThrDef;
|
||||||
xmlOutputBufferCreateFilenameValueThrDef = func;
|
xmlOutputBufferCreateFilenameValueThrDef = func;
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
|
||||||
|
|
||||||
return(old);
|
return(old);
|
||||||
}
|
}
|
||||||
@ -536,10 +501,7 @@ xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc fun
|
|||||||
#undef xmlLastError
|
#undef xmlLastError
|
||||||
xmlError *
|
xmlError *
|
||||||
__xmlLastError(void) {
|
__xmlLastError(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlLastError);
|
return (&xmlLastError);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlLastError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -552,321 +514,223 @@ __xmlLastError(void) {
|
|||||||
#undef oldXMLWDcompatibility
|
#undef oldXMLWDcompatibility
|
||||||
int *
|
int *
|
||||||
__oldXMLWDcompatibility(void) {
|
__oldXMLWDcompatibility(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&oldXMLWDcompatibility);
|
return (&oldXMLWDcompatibility);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->oldXMLWDcompatibility);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlBufferAllocScheme
|
#undef xmlBufferAllocScheme
|
||||||
xmlBufferAllocationScheme *
|
xmlBufferAllocationScheme *
|
||||||
__xmlBufferAllocScheme(void) {
|
__xmlBufferAllocScheme(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlBufferAllocScheme);
|
return (&xmlBufferAllocScheme);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlBufferAllocScheme);
|
|
||||||
}
|
}
|
||||||
xmlBufferAllocationScheme xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v) {
|
xmlBufferAllocationScheme xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v) {
|
||||||
xmlBufferAllocationScheme ret;
|
xmlBufferAllocationScheme ret;
|
||||||
xmlMutexLock(xmlThrDefMutex);
|
|
||||||
ret = xmlBufferAllocSchemeThrDef;
|
ret = xmlBufferAllocSchemeThrDef;
|
||||||
xmlBufferAllocSchemeThrDef = v;
|
xmlBufferAllocSchemeThrDef = v;
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlDefaultBufferSize
|
#undef xmlDefaultBufferSize
|
||||||
int *
|
int *
|
||||||
__xmlDefaultBufferSize(void) {
|
__xmlDefaultBufferSize(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlDefaultBufferSize);
|
return (&xmlDefaultBufferSize);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlDefaultBufferSize);
|
|
||||||
}
|
}
|
||||||
int xmlThrDefDefaultBufferSize(int v) {
|
int xmlThrDefDefaultBufferSize(int v) {
|
||||||
int ret;
|
int ret;
|
||||||
xmlMutexLock(xmlThrDefMutex);
|
|
||||||
ret = xmlDefaultBufferSizeThrDef;
|
ret = xmlDefaultBufferSizeThrDef;
|
||||||
xmlDefaultBufferSizeThrDef = v;
|
xmlDefaultBufferSizeThrDef = v;
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlDefaultSAXLocator
|
#undef xmlDefaultSAXLocator
|
||||||
xmlSAXLocator *
|
xmlSAXLocator *
|
||||||
__xmlDefaultSAXLocator(void) {
|
__xmlDefaultSAXLocator(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlDefaultSAXLocator);
|
return (&xmlDefaultSAXLocator);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlDefaultSAXLocator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlDoValidityCheckingDefaultValue
|
#undef xmlDoValidityCheckingDefaultValue
|
||||||
int *
|
int *
|
||||||
__xmlDoValidityCheckingDefaultValue(void) {
|
__xmlDoValidityCheckingDefaultValue(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlDoValidityCheckingDefaultValue);
|
return (&xmlDoValidityCheckingDefaultValue);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlDoValidityCheckingDefaultValue);
|
|
||||||
}
|
}
|
||||||
int xmlThrDefDoValidityCheckingDefaultValue(int v) {
|
int xmlThrDefDoValidityCheckingDefaultValue(int v) {
|
||||||
int ret;
|
int ret;
|
||||||
xmlMutexLock(xmlThrDefMutex);
|
|
||||||
ret = xmlDoValidityCheckingDefaultValueThrDef;
|
ret = xmlDoValidityCheckingDefaultValueThrDef;
|
||||||
xmlDoValidityCheckingDefaultValueThrDef = v;
|
xmlDoValidityCheckingDefaultValueThrDef = v;
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlGenericError
|
#undef xmlGenericError
|
||||||
xmlGenericErrorFunc *
|
xmlGenericErrorFunc *
|
||||||
__xmlGenericError(void) {
|
__xmlGenericError(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlGenericError);
|
return (&xmlGenericError);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlGenericError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlStructuredError
|
#undef xmlStructuredError
|
||||||
xmlStructuredErrorFunc *
|
xmlStructuredErrorFunc *
|
||||||
__xmlStructuredError(void) {
|
__xmlStructuredError(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlStructuredError);
|
return (&xmlStructuredError);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlStructuredError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlGenericErrorContext
|
#undef xmlGenericErrorContext
|
||||||
void * *
|
void * *
|
||||||
__xmlGenericErrorContext(void) {
|
__xmlGenericErrorContext(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlGenericErrorContext);
|
return (&xmlGenericErrorContext);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlGenericErrorContext);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlStructuredErrorContext
|
#undef xmlStructuredErrorContext
|
||||||
void * *
|
void * *
|
||||||
__xmlStructuredErrorContext(void) {
|
__xmlStructuredErrorContext(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlStructuredErrorContext);
|
return (&xmlStructuredErrorContext);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlStructuredErrorContext);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlGetWarningsDefaultValue
|
#undef xmlGetWarningsDefaultValue
|
||||||
int *
|
int *
|
||||||
__xmlGetWarningsDefaultValue(void) {
|
__xmlGetWarningsDefaultValue(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlGetWarningsDefaultValue);
|
return (&xmlGetWarningsDefaultValue);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlGetWarningsDefaultValue);
|
|
||||||
}
|
}
|
||||||
int xmlThrDefGetWarningsDefaultValue(int v) {
|
int xmlThrDefGetWarningsDefaultValue(int v) {
|
||||||
int ret;
|
int ret;
|
||||||
xmlMutexLock(xmlThrDefMutex);
|
|
||||||
ret = xmlGetWarningsDefaultValueThrDef;
|
ret = xmlGetWarningsDefaultValueThrDef;
|
||||||
xmlGetWarningsDefaultValueThrDef = v;
|
xmlGetWarningsDefaultValueThrDef = v;
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlIndentTreeOutput
|
#undef xmlIndentTreeOutput
|
||||||
int *
|
int *
|
||||||
__xmlIndentTreeOutput(void) {
|
__xmlIndentTreeOutput(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlIndentTreeOutput);
|
return (&xmlIndentTreeOutput);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlIndentTreeOutput);
|
|
||||||
}
|
}
|
||||||
int xmlThrDefIndentTreeOutput(int v) {
|
int xmlThrDefIndentTreeOutput(int v) {
|
||||||
int ret;
|
int ret;
|
||||||
xmlMutexLock(xmlThrDefMutex);
|
|
||||||
ret = xmlIndentTreeOutputThrDef;
|
ret = xmlIndentTreeOutputThrDef;
|
||||||
xmlIndentTreeOutputThrDef = v;
|
xmlIndentTreeOutputThrDef = v;
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlTreeIndentString
|
#undef xmlTreeIndentString
|
||||||
const char * *
|
const char * *
|
||||||
__xmlTreeIndentString(void) {
|
__xmlTreeIndentString(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlTreeIndentString);
|
return (&xmlTreeIndentString);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlTreeIndentString);
|
|
||||||
}
|
}
|
||||||
const char * xmlThrDefTreeIndentString(const char * v) {
|
const char * xmlThrDefTreeIndentString(const char * v) {
|
||||||
const char * ret;
|
const char * ret;
|
||||||
xmlMutexLock(xmlThrDefMutex);
|
|
||||||
ret = xmlTreeIndentStringThrDef;
|
ret = xmlTreeIndentStringThrDef;
|
||||||
xmlTreeIndentStringThrDef = v;
|
xmlTreeIndentStringThrDef = v;
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlKeepBlanksDefaultValue
|
#undef xmlKeepBlanksDefaultValue
|
||||||
int *
|
int *
|
||||||
__xmlKeepBlanksDefaultValue(void) {
|
__xmlKeepBlanksDefaultValue(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlKeepBlanksDefaultValue);
|
return (&xmlKeepBlanksDefaultValue);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlKeepBlanksDefaultValue);
|
|
||||||
}
|
}
|
||||||
int xmlThrDefKeepBlanksDefaultValue(int v) {
|
int xmlThrDefKeepBlanksDefaultValue(int v) {
|
||||||
int ret;
|
int ret;
|
||||||
xmlMutexLock(xmlThrDefMutex);
|
|
||||||
ret = xmlKeepBlanksDefaultValueThrDef;
|
ret = xmlKeepBlanksDefaultValueThrDef;
|
||||||
xmlKeepBlanksDefaultValueThrDef = v;
|
xmlKeepBlanksDefaultValueThrDef = v;
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlLineNumbersDefaultValue
|
#undef xmlLineNumbersDefaultValue
|
||||||
int *
|
int *
|
||||||
__xmlLineNumbersDefaultValue(void) {
|
__xmlLineNumbersDefaultValue(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlLineNumbersDefaultValue);
|
return (&xmlLineNumbersDefaultValue);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlLineNumbersDefaultValue);
|
|
||||||
}
|
}
|
||||||
int xmlThrDefLineNumbersDefaultValue(int v) {
|
int xmlThrDefLineNumbersDefaultValue(int v) {
|
||||||
int ret;
|
int ret;
|
||||||
xmlMutexLock(xmlThrDefMutex);
|
|
||||||
ret = xmlLineNumbersDefaultValueThrDef;
|
ret = xmlLineNumbersDefaultValueThrDef;
|
||||||
xmlLineNumbersDefaultValueThrDef = v;
|
xmlLineNumbersDefaultValueThrDef = v;
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlLoadExtDtdDefaultValue
|
#undef xmlLoadExtDtdDefaultValue
|
||||||
int *
|
int *
|
||||||
__xmlLoadExtDtdDefaultValue(void) {
|
__xmlLoadExtDtdDefaultValue(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlLoadExtDtdDefaultValue);
|
return (&xmlLoadExtDtdDefaultValue);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlLoadExtDtdDefaultValue);
|
|
||||||
}
|
}
|
||||||
int xmlThrDefLoadExtDtdDefaultValue(int v) {
|
int xmlThrDefLoadExtDtdDefaultValue(int v) {
|
||||||
int ret;
|
int ret;
|
||||||
xmlMutexLock(xmlThrDefMutex);
|
|
||||||
ret = xmlLoadExtDtdDefaultValueThrDef;
|
ret = xmlLoadExtDtdDefaultValueThrDef;
|
||||||
xmlLoadExtDtdDefaultValueThrDef = v;
|
xmlLoadExtDtdDefaultValueThrDef = v;
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlParserDebugEntities
|
#undef xmlParserDebugEntities
|
||||||
int *
|
int *
|
||||||
__xmlParserDebugEntities(void) {
|
__xmlParserDebugEntities(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlParserDebugEntities);
|
return (&xmlParserDebugEntities);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlParserDebugEntities);
|
|
||||||
}
|
}
|
||||||
int xmlThrDefParserDebugEntities(int v) {
|
int xmlThrDefParserDebugEntities(int v) {
|
||||||
int ret;
|
int ret;
|
||||||
xmlMutexLock(xmlThrDefMutex);
|
|
||||||
ret = xmlParserDebugEntitiesThrDef;
|
ret = xmlParserDebugEntitiesThrDef;
|
||||||
xmlParserDebugEntitiesThrDef = v;
|
xmlParserDebugEntitiesThrDef = v;
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlParserVersion
|
#undef xmlParserVersion
|
||||||
const char * *
|
const char * *
|
||||||
__xmlParserVersion(void) {
|
__xmlParserVersion(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlParserVersion);
|
return (&xmlParserVersion);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlParserVersion);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlPedanticParserDefaultValue
|
#undef xmlPedanticParserDefaultValue
|
||||||
int *
|
int *
|
||||||
__xmlPedanticParserDefaultValue(void) {
|
__xmlPedanticParserDefaultValue(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlPedanticParserDefaultValue);
|
return (&xmlPedanticParserDefaultValue);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlPedanticParserDefaultValue);
|
|
||||||
}
|
}
|
||||||
int xmlThrDefPedanticParserDefaultValue(int v) {
|
int xmlThrDefPedanticParserDefaultValue(int v) {
|
||||||
int ret;
|
int ret;
|
||||||
xmlMutexLock(xmlThrDefMutex);
|
|
||||||
ret = xmlPedanticParserDefaultValueThrDef;
|
ret = xmlPedanticParserDefaultValueThrDef;
|
||||||
xmlPedanticParserDefaultValueThrDef = v;
|
xmlPedanticParserDefaultValueThrDef = v;
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlSaveNoEmptyTags
|
#undef xmlSaveNoEmptyTags
|
||||||
int *
|
int *
|
||||||
__xmlSaveNoEmptyTags(void) {
|
__xmlSaveNoEmptyTags(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlSaveNoEmptyTags);
|
return (&xmlSaveNoEmptyTags);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlSaveNoEmptyTags);
|
|
||||||
}
|
}
|
||||||
int xmlThrDefSaveNoEmptyTags(int v) {
|
int xmlThrDefSaveNoEmptyTags(int v) {
|
||||||
int ret;
|
int ret;
|
||||||
xmlMutexLock(xmlThrDefMutex);
|
|
||||||
ret = xmlSaveNoEmptyTagsThrDef;
|
ret = xmlSaveNoEmptyTagsThrDef;
|
||||||
xmlSaveNoEmptyTagsThrDef = v;
|
xmlSaveNoEmptyTagsThrDef = v;
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlSubstituteEntitiesDefaultValue
|
#undef xmlSubstituteEntitiesDefaultValue
|
||||||
int *
|
int *
|
||||||
__xmlSubstituteEntitiesDefaultValue(void) {
|
__xmlSubstituteEntitiesDefaultValue(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlSubstituteEntitiesDefaultValue);
|
return (&xmlSubstituteEntitiesDefaultValue);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlSubstituteEntitiesDefaultValue);
|
|
||||||
}
|
}
|
||||||
int xmlThrDefSubstituteEntitiesDefaultValue(int v) {
|
int xmlThrDefSubstituteEntitiesDefaultValue(int v) {
|
||||||
int ret;
|
int ret;
|
||||||
xmlMutexLock(xmlThrDefMutex);
|
|
||||||
ret = xmlSubstituteEntitiesDefaultValueThrDef;
|
ret = xmlSubstituteEntitiesDefaultValueThrDef;
|
||||||
xmlSubstituteEntitiesDefaultValueThrDef = v;
|
xmlSubstituteEntitiesDefaultValueThrDef = v;
|
||||||
xmlMutexUnlock(xmlThrDefMutex);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlRegisterNodeDefaultValue
|
#undef xmlRegisterNodeDefaultValue
|
||||||
xmlRegisterNodeFunc *
|
xmlRegisterNodeFunc *
|
||||||
__xmlRegisterNodeDefaultValue(void) {
|
__xmlRegisterNodeDefaultValue(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlRegisterNodeDefaultValue);
|
return (&xmlRegisterNodeDefaultValue);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlRegisterNodeDefaultValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlDeregisterNodeDefaultValue
|
#undef xmlDeregisterNodeDefaultValue
|
||||||
xmlDeregisterNodeFunc *
|
xmlDeregisterNodeFunc *
|
||||||
__xmlDeregisterNodeDefaultValue(void) {
|
__xmlDeregisterNodeDefaultValue(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlDeregisterNodeDefaultValue);
|
return (&xmlDeregisterNodeDefaultValue);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlDeregisterNodeDefaultValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlParserInputBufferCreateFilenameValue
|
#undef xmlParserInputBufferCreateFilenameValue
|
||||||
xmlParserInputBufferCreateFilenameFunc *
|
xmlParserInputBufferCreateFilenameFunc *
|
||||||
__xmlParserInputBufferCreateFilenameValue(void) {
|
__xmlParserInputBufferCreateFilenameValue(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlParserInputBufferCreateFilenameValue);
|
return (&xmlParserInputBufferCreateFilenameValue);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlParserInputBufferCreateFilenameValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef xmlOutputBufferCreateFilenameValue
|
#undef xmlOutputBufferCreateFilenameValue
|
||||||
xmlOutputBufferCreateFilenameFunc *
|
xmlOutputBufferCreateFilenameFunc *
|
||||||
__xmlOutputBufferCreateFilenameValue(void) {
|
__xmlOutputBufferCreateFilenameValue(void) {
|
||||||
if (IS_MAIN_THREAD)
|
|
||||||
return (&xmlOutputBufferCreateFilenameValue);
|
return (&xmlOutputBufferCreateFilenameValue);
|
||||||
else
|
|
||||||
return (&xmlGetGlobalState()->xmlOutputBufferCreateFilenameValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define bottom_globals
|
#define bottom_globals
|
||||||
|
7
deps/libxml2/libxml.h
vendored
7
deps/libxml2/libxml.h
vendored
@ -35,13 +35,6 @@ extern int __xmlRegisterCallbacks;
|
|||||||
void __xmlIOErr(int domain, int code, const char *extra);
|
void __xmlIOErr(int domain, int code, const char *extra);
|
||||||
void __xmlLoaderErr(void *ctx, const char *msg, const char *filename);
|
void __xmlLoaderErr(void *ctx, const char *msg, const char *filename);
|
||||||
|
|
||||||
/*
|
|
||||||
* internal global initialization critical section routines.
|
|
||||||
*/
|
|
||||||
void __xmlGlobalInitMutexLock(void);
|
|
||||||
void __xmlGlobalInitMutexUnlock(void);
|
|
||||||
void __xmlGlobalInitMutexDestroy(void);
|
|
||||||
|
|
||||||
#ifdef IN_LIBXML
|
#ifdef IN_LIBXML
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#ifdef PIC
|
#ifdef PIC
|
||||||
|
84
deps/libxml2/libxml/threads.h
vendored
84
deps/libxml2/libxml/threads.h
vendored
@ -1,84 +0,0 @@
|
|||||||
/**
|
|
||||||
* Summary: interfaces for thread handling
|
|
||||||
* Description: set of generic threading related routines
|
|
||||||
* should work with pthreads, Windows native or TLS threads
|
|
||||||
*
|
|
||||||
* Copy: See Copyright for the status of this software.
|
|
||||||
*
|
|
||||||
* Author: Daniel Veillard
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __XML_THREADS_H__
|
|
||||||
#define __XML_THREADS_H__
|
|
||||||
|
|
||||||
#include <libxml/xmlversion.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* xmlMutex are a simple mutual exception locks.
|
|
||||||
*/
|
|
||||||
typedef struct _xmlMutex xmlMutex;
|
|
||||||
typedef xmlMutex *xmlMutexPtr;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* xmlRMutex are reentrant mutual exception locks.
|
|
||||||
*/
|
|
||||||
typedef struct _xmlRMutex xmlRMutex;
|
|
||||||
typedef xmlRMutex *xmlRMutexPtr;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#include <libxml/globals.h>
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
XMLPUBFUN xmlMutexPtr XMLCALL
|
|
||||||
xmlNewMutex (void);
|
|
||||||
XMLPUBFUN void XMLCALL
|
|
||||||
xmlMutexLock (xmlMutexPtr tok);
|
|
||||||
XMLPUBFUN void XMLCALL
|
|
||||||
xmlMutexUnlock (xmlMutexPtr tok);
|
|
||||||
XMLPUBFUN void XMLCALL
|
|
||||||
xmlFreeMutex (xmlMutexPtr tok);
|
|
||||||
|
|
||||||
XMLPUBFUN xmlRMutexPtr XMLCALL
|
|
||||||
xmlNewRMutex (void);
|
|
||||||
XMLPUBFUN void XMLCALL
|
|
||||||
xmlRMutexLock (xmlRMutexPtr tok);
|
|
||||||
XMLPUBFUN void XMLCALL
|
|
||||||
xmlRMutexUnlock (xmlRMutexPtr tok);
|
|
||||||
XMLPUBFUN void XMLCALL
|
|
||||||
xmlFreeRMutex (xmlRMutexPtr tok);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Library wide APIs.
|
|
||||||
*/
|
|
||||||
XMLPUBFUN void XMLCALL
|
|
||||||
xmlInitThreads (void);
|
|
||||||
XMLPUBFUN void XMLCALL
|
|
||||||
xmlLockLibrary (void);
|
|
||||||
XMLPUBFUN void XMLCALL
|
|
||||||
xmlUnlockLibrary(void);
|
|
||||||
XMLPUBFUN int XMLCALL
|
|
||||||
xmlGetThreadId (void);
|
|
||||||
XMLPUBFUN int XMLCALL
|
|
||||||
xmlIsMainThread (void);
|
|
||||||
XMLPUBFUN void XMLCALL
|
|
||||||
xmlCleanupThreads(void);
|
|
||||||
XMLPUBFUN xmlGlobalStatePtr XMLCALL
|
|
||||||
xmlGetGlobalState(void);
|
|
||||||
|
|
||||||
#if defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && defined(LIBXML_STATIC_FOR_DLL)
|
|
||||||
int XMLCALL xmlDllMain(void *hinstDLL, unsigned long fdwReason, void *lpvReserved);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __XML_THREADS_H__ */
|
|
915
deps/libxml2/libxml_threads.c
vendored
915
deps/libxml2/libxml_threads.c
vendored
@ -1,915 +0,0 @@
|
|||||||
/**
|
|
||||||
* threads.c: set of generic threading related routines
|
|
||||||
*
|
|
||||||
* See Copyright for the status of this software.
|
|
||||||
*
|
|
||||||
* Gary Pennington <Gary.Pennington@uk.sun.com>
|
|
||||||
* daniel@veillard.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define IN_LIBXML
|
|
||||||
#include "libxml.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <libxml/threads.h>
|
|
||||||
#include <libxml/globals.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
|
||||||
#include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_UNISTD_H
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_STDLIB_H
|
|
||||||
#include <stdlib.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
#include <pthread.h>
|
|
||||||
#elif defined HAVE_WIN32_THREADS
|
|
||||||
#include <windows.h>
|
|
||||||
#ifndef HAVE_COMPILER_TLS
|
|
||||||
#include <process.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_BEOS_THREADS
|
|
||||||
#include <OS.h>
|
|
||||||
#include <TLS.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(SOLARIS)
|
|
||||||
#include <note.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
|
|
||||||
static int libxml_is_threaded = -1;
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#ifdef linux
|
|
||||||
#if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (__GNUC__ > 3)
|
|
||||||
extern int pthread_once (pthread_once_t *__once_control,
|
|
||||||
void (*__init_routine) (void))
|
|
||||||
__attribute((weak));
|
|
||||||
extern void *pthread_getspecific (pthread_key_t __key)
|
|
||||||
__attribute((weak));
|
|
||||||
extern int pthread_setspecific (pthread_key_t __key,
|
|
||||||
__const void *__pointer)
|
|
||||||
__attribute((weak));
|
|
||||||
extern int pthread_key_create (pthread_key_t *__key,
|
|
||||||
void (*__destr_function) (void *))
|
|
||||||
__attribute((weak));
|
|
||||||
extern int pthread_key_delete (pthread_key_t __key)
|
|
||||||
__attribute((weak));
|
|
||||||
extern int pthread_mutex_init ()
|
|
||||||
__attribute((weak));
|
|
||||||
extern int pthread_mutex_destroy ()
|
|
||||||
__attribute((weak));
|
|
||||||
extern int pthread_mutex_lock ()
|
|
||||||
__attribute((weak));
|
|
||||||
extern int pthread_mutex_unlock ()
|
|
||||||
__attribute((weak));
|
|
||||||
extern int pthread_cond_init ()
|
|
||||||
__attribute((weak));
|
|
||||||
extern int pthread_cond_destroy ()
|
|
||||||
__attribute((weak));
|
|
||||||
extern int pthread_cond_wait ()
|
|
||||||
__attribute((weak));
|
|
||||||
extern int pthread_equal ()
|
|
||||||
__attribute((weak));
|
|
||||||
extern pthread_t pthread_self ()
|
|
||||||
__attribute((weak));
|
|
||||||
extern int pthread_key_create ()
|
|
||||||
__attribute((weak));
|
|
||||||
extern int pthread_key_delete ()
|
|
||||||
__attribute((weak));
|
|
||||||
extern int pthread_cond_signal ()
|
|
||||||
__attribute((weak));
|
|
||||||
#endif
|
|
||||||
#endif /* linux */
|
|
||||||
#endif /* __GNUC__ */
|
|
||||||
#endif /* HAVE_PTHREAD_H */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO: this module still uses malloc/free and not xmlMalloc/xmlFree
|
|
||||||
* to avoid some crazyness since xmlMalloc/xmlFree may actually
|
|
||||||
* be hosted on allocated blocks needing them for the allocation ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* xmlMutex are a simple mutual exception locks
|
|
||||||
*/
|
|
||||||
struct _xmlMutex {
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
pthread_mutex_t lock;
|
|
||||||
#elif defined HAVE_WIN32_THREADS
|
|
||||||
HANDLE mutex;
|
|
||||||
#elif defined HAVE_BEOS_THREADS
|
|
||||||
sem_id sem;
|
|
||||||
thread_id tid;
|
|
||||||
#else
|
|
||||||
int empty;
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* xmlRMutex are reentrant mutual exception locks
|
|
||||||
*/
|
|
||||||
struct _xmlRMutex {
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
pthread_mutex_t lock;
|
|
||||||
unsigned int held;
|
|
||||||
unsigned int waiters;
|
|
||||||
pthread_t tid;
|
|
||||||
pthread_cond_t cv;
|
|
||||||
#elif defined HAVE_WIN32_THREADS
|
|
||||||
CRITICAL_SECTION cs;
|
|
||||||
unsigned int count;
|
|
||||||
#elif defined HAVE_BEOS_THREADS
|
|
||||||
xmlMutexPtr lock;
|
|
||||||
thread_id tid;
|
|
||||||
int32 count;
|
|
||||||
#else
|
|
||||||
int empty;
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This module still has some internal static data.
|
|
||||||
* - xmlLibraryLock a global lock
|
|
||||||
* - globalkey used for per-thread data
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
static pthread_key_t globalkey;
|
|
||||||
static pthread_t mainthread;
|
|
||||||
static pthread_once_t once_control = PTHREAD_ONCE_INIT;
|
|
||||||
static pthread_mutex_t global_init_lock = PTHREAD_MUTEX_INITIALIZER;
|
|
||||||
#elif defined HAVE_WIN32_THREADS
|
|
||||||
#if defined(HAVE_COMPILER_TLS)
|
|
||||||
static __declspec(thread) xmlGlobalState tlstate;
|
|
||||||
static __declspec(thread) int tlstate_inited = 0;
|
|
||||||
#else /* HAVE_COMPILER_TLS */
|
|
||||||
static DWORD globalkey = TLS_OUT_OF_INDEXES;
|
|
||||||
#endif /* HAVE_COMPILER_TLS */
|
|
||||||
static DWORD mainthread;
|
|
||||||
static struct {
|
|
||||||
DWORD done;
|
|
||||||
DWORD control;
|
|
||||||
} run_once = { 0, 0};
|
|
||||||
static volatile LPCRITICAL_SECTION global_init_lock = NULL;
|
|
||||||
|
|
||||||
/* endif HAVE_WIN32_THREADS */
|
|
||||||
#elif defined HAVE_BEOS_THREADS
|
|
||||||
int32 globalkey = 0;
|
|
||||||
thread_id mainthread = 0;
|
|
||||||
int32 run_once_init = 0;
|
|
||||||
static int32 global_init_lock = -1;
|
|
||||||
static vint32 global_init_count = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static xmlRMutexPtr xmlLibraryLock = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlNewMutex:
|
|
||||||
*
|
|
||||||
* xmlNewMutex() is used to allocate a libxml2 token struct for use in
|
|
||||||
* synchronizing access to data.
|
|
||||||
*
|
|
||||||
* Returns a new simple mutex pointer or NULL in case of error
|
|
||||||
*/
|
|
||||||
xmlMutexPtr
|
|
||||||
xmlNewMutex(void)
|
|
||||||
{
|
|
||||||
xmlMutexPtr tok;
|
|
||||||
|
|
||||||
if ((tok = malloc(sizeof(xmlMutex))) == NULL)
|
|
||||||
return (NULL);
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
if (libxml_is_threaded != 0)
|
|
||||||
pthread_mutex_init(&tok->lock, NULL);
|
|
||||||
#elif defined HAVE_WIN32_THREADS
|
|
||||||
tok->mutex = CreateMutex(NULL, FALSE, NULL);
|
|
||||||
#elif defined HAVE_BEOS_THREADS
|
|
||||||
if ((tok->sem = create_sem(1, "xmlMutex")) < B_OK) {
|
|
||||||
free(tok);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
tok->tid = -1;
|
|
||||||
#endif
|
|
||||||
return (tok);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlFreeMutex:
|
|
||||||
* @tok: the simple mutex
|
|
||||||
*
|
|
||||||
* xmlFreeMutex() is used to reclaim resources associated with a libxml2 token
|
|
||||||
* struct.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xmlFreeMutex(xmlMutexPtr tok)
|
|
||||||
{
|
|
||||||
if (tok == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
if (libxml_is_threaded != 0)
|
|
||||||
pthread_mutex_destroy(&tok->lock);
|
|
||||||
#elif defined HAVE_WIN32_THREADS
|
|
||||||
CloseHandle(tok->mutex);
|
|
||||||
#elif defined HAVE_BEOS_THREADS
|
|
||||||
delete_sem(tok->sem);
|
|
||||||
#endif
|
|
||||||
free(tok);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlMutexLock:
|
|
||||||
* @tok: the simple mutex
|
|
||||||
*
|
|
||||||
* xmlMutexLock() is used to lock a libxml2 token.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xmlMutexLock(xmlMutexPtr tok)
|
|
||||||
{
|
|
||||||
if (tok == NULL)
|
|
||||||
return;
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
if (libxml_is_threaded != 0)
|
|
||||||
pthread_mutex_lock(&tok->lock);
|
|
||||||
#elif defined HAVE_WIN32_THREADS
|
|
||||||
WaitForSingleObject(tok->mutex, INFINITE);
|
|
||||||
#elif defined HAVE_BEOS_THREADS
|
|
||||||
if (acquire_sem(tok->sem) != B_NO_ERROR) {
|
|
||||||
}
|
|
||||||
tok->tid = find_thread(NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlMutexUnlock:
|
|
||||||
* @tok: the simple mutex
|
|
||||||
*
|
|
||||||
* xmlMutexUnlock() is used to unlock a libxml2 token.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xmlMutexUnlock(xmlMutexPtr tok)
|
|
||||||
{
|
|
||||||
if (tok == NULL)
|
|
||||||
return;
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
if (libxml_is_threaded != 0)
|
|
||||||
pthread_mutex_unlock(&tok->lock);
|
|
||||||
#elif defined HAVE_WIN32_THREADS
|
|
||||||
ReleaseMutex(tok->mutex);
|
|
||||||
#elif defined HAVE_BEOS_THREADS
|
|
||||||
if (tok->tid == find_thread(NULL)) {
|
|
||||||
tok->tid = -1;
|
|
||||||
release_sem(tok->sem);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlNewRMutex:
|
|
||||||
*
|
|
||||||
* xmlRNewMutex() is used to allocate a reentrant mutex for use in
|
|
||||||
* synchronizing access to data. token_r is a re-entrant lock and thus useful
|
|
||||||
* for synchronizing access to data structures that may be manipulated in a
|
|
||||||
* recursive fashion.
|
|
||||||
*
|
|
||||||
* Returns the new reentrant mutex pointer or NULL in case of error
|
|
||||||
*/
|
|
||||||
xmlRMutexPtr
|
|
||||||
xmlNewRMutex(void)
|
|
||||||
{
|
|
||||||
xmlRMutexPtr tok;
|
|
||||||
|
|
||||||
if ((tok = malloc(sizeof(xmlRMutex))) == NULL)
|
|
||||||
return (NULL);
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
if (libxml_is_threaded != 0) {
|
|
||||||
pthread_mutex_init(&tok->lock, NULL);
|
|
||||||
tok->held = 0;
|
|
||||||
tok->waiters = 0;
|
|
||||||
pthread_cond_init(&tok->cv, NULL);
|
|
||||||
}
|
|
||||||
#elif defined HAVE_WIN32_THREADS
|
|
||||||
InitializeCriticalSection(&tok->cs);
|
|
||||||
tok->count = 0;
|
|
||||||
#elif defined HAVE_BEOS_THREADS
|
|
||||||
if ((tok->lock = xmlNewMutex()) == NULL) {
|
|
||||||
free(tok);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
tok->count = 0;
|
|
||||||
#endif
|
|
||||||
return (tok);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlFreeRMutex:
|
|
||||||
* @tok: the reentrant mutex
|
|
||||||
*
|
|
||||||
* xmlRFreeMutex() is used to reclaim resources associated with a
|
|
||||||
* reentrant mutex.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xmlFreeRMutex(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
|
|
||||||
{
|
|
||||||
if (tok == NULL)
|
|
||||||
return;
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
if (libxml_is_threaded != 0) {
|
|
||||||
pthread_mutex_destroy(&tok->lock);
|
|
||||||
pthread_cond_destroy(&tok->cv);
|
|
||||||
}
|
|
||||||
#elif defined HAVE_WIN32_THREADS
|
|
||||||
DeleteCriticalSection(&tok->cs);
|
|
||||||
#elif defined HAVE_BEOS_THREADS
|
|
||||||
xmlFreeMutex(tok->lock);
|
|
||||||
#endif
|
|
||||||
free(tok);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlRMutexLock:
|
|
||||||
* @tok: the reentrant mutex
|
|
||||||
*
|
|
||||||
* xmlRMutexLock() is used to lock a libxml2 token_r.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xmlRMutexLock(xmlRMutexPtr tok)
|
|
||||||
{
|
|
||||||
if (tok == NULL)
|
|
||||||
return;
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
if (libxml_is_threaded == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&tok->lock);
|
|
||||||
if (tok->held) {
|
|
||||||
if (pthread_equal(tok->tid, pthread_self())) {
|
|
||||||
tok->held++;
|
|
||||||
pthread_mutex_unlock(&tok->lock);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
tok->waiters++;
|
|
||||||
while (tok->held)
|
|
||||||
pthread_cond_wait(&tok->cv, &tok->lock);
|
|
||||||
tok->waiters--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tok->tid = pthread_self();
|
|
||||||
tok->held = 1;
|
|
||||||
pthread_mutex_unlock(&tok->lock);
|
|
||||||
#elif defined HAVE_WIN32_THREADS
|
|
||||||
EnterCriticalSection(&tok->cs);
|
|
||||||
++tok->count;
|
|
||||||
#elif defined HAVE_BEOS_THREADS
|
|
||||||
if (tok->lock->tid == find_thread(NULL)) {
|
|
||||||
tok->count++;
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
xmlMutexLock(tok->lock);
|
|
||||||
tok->count = 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlRMutexUnlock:
|
|
||||||
* @tok: the reentrant mutex
|
|
||||||
*
|
|
||||||
* xmlRMutexUnlock() is used to unlock a libxml2 token_r.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xmlRMutexUnlock(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
|
|
||||||
{
|
|
||||||
if (tok == NULL)
|
|
||||||
return;
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
if (libxml_is_threaded == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&tok->lock);
|
|
||||||
tok->held--;
|
|
||||||
if (tok->held == 0) {
|
|
||||||
if (tok->waiters)
|
|
||||||
pthread_cond_signal(&tok->cv);
|
|
||||||
memset(&tok->tid, 0, sizeof(tok->tid));
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock(&tok->lock);
|
|
||||||
#elif defined HAVE_WIN32_THREADS
|
|
||||||
if (!--tok->count)
|
|
||||||
LeaveCriticalSection(&tok->cs);
|
|
||||||
#elif defined HAVE_BEOS_THREADS
|
|
||||||
if (tok->lock->tid == find_thread(NULL)) {
|
|
||||||
tok->count--;
|
|
||||||
if (tok->count == 0) {
|
|
||||||
xmlMutexUnlock(tok->lock);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlGlobalInitMutexLock
|
|
||||||
*
|
|
||||||
* Makes sure that the global initialization mutex is initialized and
|
|
||||||
* locks it.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
__xmlGlobalInitMutexLock(void)
|
|
||||||
{
|
|
||||||
/* Make sure the global init lock is initialized and then lock it. */
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
/* The mutex is statically initialized, so we just lock it. */
|
|
||||||
if (pthread_mutex_lock)
|
|
||||||
pthread_mutex_lock(&global_init_lock);
|
|
||||||
#elif defined HAVE_WIN32_THREADS
|
|
||||||
LPCRITICAL_SECTION cs;
|
|
||||||
|
|
||||||
/* Create a new critical section */
|
|
||||||
if (global_init_lock == NULL) {
|
|
||||||
cs = malloc(sizeof(CRITICAL_SECTION));
|
|
||||||
if (cs == NULL) {
|
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlGlobalInitMutexLock: out of memory\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
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
|
|
||||||
* allocated by this thread. */
|
|
||||||
if (global_init_lock != cs) {
|
|
||||||
DeleteCriticalSection(cs);
|
|
||||||
free(cs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Lock the chosen critical section */
|
|
||||||
EnterCriticalSection(global_init_lock);
|
|
||||||
#elif defined HAVE_BEOS_THREADS
|
|
||||||
int32 sem;
|
|
||||||
|
|
||||||
/* Allocate a new semaphore */
|
|
||||||
sem = create_sem(1, "xmlGlobalinitMutex");
|
|
||||||
|
|
||||||
while (global_init_lock == -1) {
|
|
||||||
if (atomic_add(&global_init_count, 1) == 0) {
|
|
||||||
global_init_lock = sem;
|
|
||||||
} else {
|
|
||||||
snooze(1);
|
|
||||||
atomic_add(&global_init_count, -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If another thread successfully recorded its critical
|
|
||||||
* section in the global_init_lock then discard the one
|
|
||||||
* allocated by this thread. */
|
|
||||||
if (global_init_lock != sem)
|
|
||||||
delete_sem(sem);
|
|
||||||
|
|
||||||
/* Acquire the chosen semaphore */
|
|
||||||
if (acquire_sem(global_init_lock) != B_NO_ERROR) {
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
__xmlGlobalInitMutexUnlock(void)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
if (pthread_mutex_unlock)
|
|
||||||
pthread_mutex_unlock(&global_init_lock);
|
|
||||||
#elif defined HAVE_WIN32_THREADS
|
|
||||||
if (global_init_lock != NULL) {
|
|
||||||
LeaveCriticalSection(global_init_lock);
|
|
||||||
}
|
|
||||||
#elif defined HAVE_BEOS_THREADS
|
|
||||||
release_sem(global_init_lock);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlGlobalInitMutexDestroy
|
|
||||||
*
|
|
||||||
* Makes sure that the global initialization mutex is destroyed before
|
|
||||||
* application termination.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
__xmlGlobalInitMutexDestroy(void)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
#elif defined HAVE_WIN32_THREADS
|
|
||||||
if (global_init_lock != NULL) {
|
|
||||||
DeleteCriticalSection(global_init_lock);
|
|
||||||
free(global_init_lock);
|
|
||||||
global_init_lock = NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* *
|
|
||||||
* Per thread global state handling *
|
|
||||||
* *
|
|
||||||
************************************************************************/
|
|
||||||
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
#elif defined HAVE_WIN32_THREADS
|
|
||||||
#if !defined(HAVE_COMPILER_TLS)
|
|
||||||
#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL)
|
|
||||||
typedef struct _xmlGlobalStateCleanupHelperParams {
|
|
||||||
HANDLE thread;
|
|
||||||
void *memory;
|
|
||||||
} xmlGlobalStateCleanupHelperParams;
|
|
||||||
|
|
||||||
static void XMLCDECL
|
|
||||||
xmlGlobalStateCleanupHelper(void *p)
|
|
||||||
{
|
|
||||||
xmlGlobalStateCleanupHelperParams *params =
|
|
||||||
(xmlGlobalStateCleanupHelperParams *) p;
|
|
||||||
WaitForSingleObject(params->thread, INFINITE);
|
|
||||||
CloseHandle(params->thread);
|
|
||||||
xmlFreeGlobalState(params->memory);
|
|
||||||
free(params);
|
|
||||||
_endthread();
|
|
||||||
}
|
|
||||||
#else /* LIBXML_STATIC && !LIBXML_STATIC_FOR_DLL */
|
|
||||||
|
|
||||||
typedef struct _xmlGlobalStateCleanupHelperParams {
|
|
||||||
void *memory;
|
|
||||||
struct _xmlGlobalStateCleanupHelperParams *prev;
|
|
||||||
struct _xmlGlobalStateCleanupHelperParams *next;
|
|
||||||
} xmlGlobalStateCleanupHelperParams;
|
|
||||||
|
|
||||||
static xmlGlobalStateCleanupHelperParams *cleanup_helpers_head = NULL;
|
|
||||||
static CRITICAL_SECTION cleanup_helpers_cs;
|
|
||||||
|
|
||||||
#endif /* LIBXMLSTATIC && !LIBXML_STATIC_FOR_DLL */
|
|
||||||
#endif /* HAVE_COMPILER_TLS */
|
|
||||||
#endif /* HAVE_WIN32_THREADS */
|
|
||||||
|
|
||||||
#if defined HAVE_BEOS_THREADS
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlGlobalStateCleanup:
|
|
||||||
* @data: unused parameter
|
|
||||||
*
|
|
||||||
* Used for Beos only
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xmlGlobalStateCleanup(void *data)
|
|
||||||
{
|
|
||||||
void *globalval = tls_get(globalkey);
|
|
||||||
|
|
||||||
if (globalval != NULL)
|
|
||||||
xmlFreeGlobalState(globalval);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlGetGlobalState:
|
|
||||||
*
|
|
||||||
* xmlGetGlobalState() is called to retrieve the global state for a thread.
|
|
||||||
*
|
|
||||||
* Returns the thread global state or NULL in case of error
|
|
||||||
*/
|
|
||||||
xmlGlobalStatePtr
|
|
||||||
xmlGetGlobalState(void)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
xmlGlobalState *globalval;
|
|
||||||
|
|
||||||
if (libxml_is_threaded == 0)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
pthread_once(&once_control, xmlOnceInit);
|
|
||||||
|
|
||||||
if ((globalval = (xmlGlobalState *)
|
|
||||||
pthread_getspecific(globalkey)) == NULL) {
|
|
||||||
xmlGlobalState *tsd = xmlNewGlobalState();
|
|
||||||
if (tsd == NULL)
|
|
||||||
return(NULL);
|
|
||||||
|
|
||||||
pthread_setspecific(globalkey, tsd);
|
|
||||||
return (tsd);
|
|
||||||
}
|
|
||||||
return (globalval);
|
|
||||||
#elif defined HAVE_WIN32_THREADS
|
|
||||||
#if defined(HAVE_COMPILER_TLS)
|
|
||||||
if (!tlstate_inited) {
|
|
||||||
tlstate_inited = 1;
|
|
||||||
xmlInitializeGlobalState(&tlstate);
|
|
||||||
}
|
|
||||||
return &tlstate;
|
|
||||||
#else /* HAVE_COMPILER_TLS */
|
|
||||||
xmlGlobalState *globalval;
|
|
||||||
xmlGlobalStateCleanupHelperParams *p;
|
|
||||||
|
|
||||||
xmlOnceInit();
|
|
||||||
#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL)
|
|
||||||
globalval = (xmlGlobalState *) TlsGetValue(globalkey);
|
|
||||||
#else
|
|
||||||
p = (xmlGlobalStateCleanupHelperParams *) TlsGetValue(globalkey);
|
|
||||||
globalval = (xmlGlobalState *) (p ? p->memory : NULL);
|
|
||||||
#endif
|
|
||||||
if (globalval == NULL) {
|
|
||||||
xmlGlobalState *tsd = xmlNewGlobalState();
|
|
||||||
|
|
||||||
if (tsd == NULL)
|
|
||||||
return(NULL);
|
|
||||||
p = (xmlGlobalStateCleanupHelperParams *)
|
|
||||||
malloc(sizeof(xmlGlobalStateCleanupHelperParams));
|
|
||||||
if (p == NULL) {
|
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlGetGlobalState: out of memory\n");
|
|
||||||
xmlFreeGlobalState(tsd);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
p->memory = tsd;
|
|
||||||
#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL)
|
|
||||||
DuplicateHandle(GetCurrentProcess(), GetCurrentThread(),
|
|
||||||
GetCurrentProcess(), &p->thread, 0, TRUE,
|
|
||||||
DUPLICATE_SAME_ACCESS);
|
|
||||||
TlsSetValue(globalkey, tsd);
|
|
||||||
_beginthread(xmlGlobalStateCleanupHelper, 0, p);
|
|
||||||
#else
|
|
||||||
EnterCriticalSection(&cleanup_helpers_cs);
|
|
||||||
if (cleanup_helpers_head != NULL) {
|
|
||||||
cleanup_helpers_head->prev = p;
|
|
||||||
}
|
|
||||||
p->next = cleanup_helpers_head;
|
|
||||||
p->prev = NULL;
|
|
||||||
cleanup_helpers_head = p;
|
|
||||||
TlsSetValue(globalkey, p);
|
|
||||||
LeaveCriticalSection(&cleanup_helpers_cs);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return (tsd);
|
|
||||||
}
|
|
||||||
return (globalval);
|
|
||||||
#endif /* HAVE_COMPILER_TLS */
|
|
||||||
#elif defined HAVE_BEOS_THREADS
|
|
||||||
xmlGlobalState *globalval;
|
|
||||||
|
|
||||||
xmlOnceInit();
|
|
||||||
|
|
||||||
if ((globalval = (xmlGlobalState *) tls_get(globalkey)) == NULL) {
|
|
||||||
xmlGlobalState *tsd = xmlNewGlobalState();
|
|
||||||
if (tsd == NULL)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
tls_set(globalkey, tsd);
|
|
||||||
on_exit_thread(xmlGlobalStateCleanup, NULL);
|
|
||||||
return (tsd);
|
|
||||||
}
|
|
||||||
return (globalval);
|
|
||||||
#else
|
|
||||||
return (NULL);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* *
|
|
||||||
* Library wide thread interfaces *
|
|
||||||
* *
|
|
||||||
************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlGetThreadId:
|
|
||||||
*
|
|
||||||
* xmlGetThreadId() find the current thread ID number
|
|
||||||
* Note that this is likely to be broken on some platforms using pthreads
|
|
||||||
* as the specification doesn't mandate pthread_t to be an integer type
|
|
||||||
*
|
|
||||||
* Returns the current thread ID number
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
xmlGetThreadId(void)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
pthread_t id;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (libxml_is_threaded == 0)
|
|
||||||
return (0);
|
|
||||||
id = pthread_self();
|
|
||||||
/* horrible but preserves compat, see warning above */
|
|
||||||
memcpy(&ret, &id, sizeof(ret));
|
|
||||||
return (ret);
|
|
||||||
#elif defined HAVE_WIN32_THREADS
|
|
||||||
return GetCurrentThreadId();
|
|
||||||
#elif defined HAVE_BEOS_THREADS
|
|
||||||
return find_thread(NULL);
|
|
||||||
#else
|
|
||||||
return ((int) 0);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlIsMainThread:
|
|
||||||
*
|
|
||||||
* xmlIsMainThread() check whether the current thread is the main thread.
|
|
||||||
*
|
|
||||||
* Returns 1 if the current thread is the main thread, 0 otherwise
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
xmlIsMainThread(void)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
if (libxml_is_threaded == -1)
|
|
||||||
xmlInitThreads();
|
|
||||||
if (libxml_is_threaded == 0)
|
|
||||||
return (1);
|
|
||||||
pthread_once(&once_control, xmlOnceInit);
|
|
||||||
#elif defined HAVE_WIN32_THREADS
|
|
||||||
xmlOnceInit();
|
|
||||||
#elif defined HAVE_BEOS_THREADS
|
|
||||||
xmlOnceInit();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
return (pthread_equal(mainthread,pthread_self()));
|
|
||||||
#elif defined HAVE_WIN32_THREADS
|
|
||||||
return (mainthread == GetCurrentThreadId());
|
|
||||||
#elif defined HAVE_BEOS_THREADS
|
|
||||||
return (mainthread == find_thread(NULL));
|
|
||||||
#else
|
|
||||||
return (1);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlLockLibrary:
|
|
||||||
*
|
|
||||||
* xmlLockLibrary() is used to take out a re-entrant lock on the libxml2
|
|
||||||
* library.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xmlLockLibrary(void)
|
|
||||||
{
|
|
||||||
xmlRMutexLock(xmlLibraryLock);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlUnlockLibrary:
|
|
||||||
*
|
|
||||||
* xmlUnlockLibrary() is used to release a re-entrant lock on the libxml2
|
|
||||||
* library.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xmlUnlockLibrary(void)
|
|
||||||
{
|
|
||||||
xmlRMutexUnlock(xmlLibraryLock);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlInitThreads:
|
|
||||||
*
|
|
||||||
* xmlInitThreads() is used to to initialize all the thread related
|
|
||||||
* data of the libxml2 library.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xmlInitThreads(void)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
if (libxml_is_threaded == -1) {
|
|
||||||
if ((pthread_once != NULL) &&
|
|
||||||
(pthread_getspecific != NULL) &&
|
|
||||||
(pthread_setspecific != NULL) &&
|
|
||||||
(pthread_key_create != NULL) &&
|
|
||||||
(pthread_key_delete != NULL) &&
|
|
||||||
(pthread_mutex_init != NULL) &&
|
|
||||||
(pthread_mutex_destroy != NULL) &&
|
|
||||||
(pthread_mutex_lock != NULL) &&
|
|
||||||
(pthread_mutex_unlock != NULL) &&
|
|
||||||
(pthread_cond_init != NULL) &&
|
|
||||||
(pthread_cond_destroy != NULL) &&
|
|
||||||
(pthread_cond_wait != NULL) &&
|
|
||||||
(pthread_equal != NULL) &&
|
|
||||||
(pthread_self != NULL) &&
|
|
||||||
(pthread_cond_signal != NULL)) {
|
|
||||||
libxml_is_threaded = 1;
|
|
||||||
|
|
||||||
/* fprintf(stderr, "Running multithreaded\n"); */
|
|
||||||
} else {
|
|
||||||
|
|
||||||
/* fprintf(stderr, "Running without multithread\n"); */
|
|
||||||
libxml_is_threaded = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
|
|
||||||
InitializeCriticalSection(&cleanup_helpers_cs);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlCleanupThreads:
|
|
||||||
*
|
|
||||||
* xmlCleanupThreads() is used to to cleanup all the thread related
|
|
||||||
* data of the libxml2 library once processing has ended.
|
|
||||||
*
|
|
||||||
* WARNING: if your application is multithreaded or has plugin support
|
|
||||||
* calling this may crash the application if another thread or
|
|
||||||
* a plugin is still using libxml2. It's sometimes very hard to
|
|
||||||
* guess if libxml2 is in use in the application, some libraries
|
|
||||||
* or plugins may use it without notice. In case of doubt abstain
|
|
||||||
* from calling this function or do it just before calling exit()
|
|
||||||
* to avoid leak reports from valgrind !
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xmlCleanupThreads(void)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
if ((libxml_is_threaded) && (pthread_key_delete != NULL))
|
|
||||||
pthread_key_delete(globalkey);
|
|
||||||
#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
|
|
||||||
if (globalkey != TLS_OUT_OF_INDEXES) {
|
|
||||||
xmlGlobalStateCleanupHelperParams *p;
|
|
||||||
|
|
||||||
EnterCriticalSection(&cleanup_helpers_cs);
|
|
||||||
p = cleanup_helpers_head;
|
|
||||||
while (p != NULL) {
|
|
||||||
xmlGlobalStateCleanupHelperParams *temp = p;
|
|
||||||
|
|
||||||
p = p->next;
|
|
||||||
xmlFreeGlobalState(temp->memory);
|
|
||||||
free(temp);
|
|
||||||
}
|
|
||||||
cleanup_helpers_head = 0;
|
|
||||||
LeaveCriticalSection(&cleanup_helpers_cs);
|
|
||||||
TlsFree(globalkey);
|
|
||||||
globalkey = TLS_OUT_OF_INDEXES;
|
|
||||||
}
|
|
||||||
DeleteCriticalSection(&cleanup_helpers_cs);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DllMain:
|
|
||||||
* @hinstDLL: handle to DLL instance
|
|
||||||
* @fdwReason: Reason code for entry
|
|
||||||
* @lpvReserved: generic pointer (depends upon reason code)
|
|
||||||
*
|
|
||||||
* Entry point for Windows library. It is being used to free thread-specific
|
|
||||||
* storage.
|
|
||||||
*
|
|
||||||
* Returns TRUE always
|
|
||||||
*/
|
|
||||||
#ifdef HAVE_PTHREAD_H
|
|
||||||
#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
|
|
||||||
#if defined(LIBXML_STATIC_FOR_DLL)
|
|
||||||
BOOL XMLCALL
|
|
||||||
xmlDllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|
||||||
#else
|
|
||||||
BOOL WINAPI
|
|
||||||
DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
switch (fdwReason) {
|
|
||||||
case DLL_THREAD_DETACH:
|
|
||||||
if (globalkey != TLS_OUT_OF_INDEXES) {
|
|
||||||
xmlGlobalState *globalval = NULL;
|
|
||||||
xmlGlobalStateCleanupHelperParams *p =
|
|
||||||
(xmlGlobalStateCleanupHelperParams *)
|
|
||||||
TlsGetValue(globalkey);
|
|
||||||
globalval = (xmlGlobalState *) (p ? p->memory : NULL);
|
|
||||||
if (globalval) {
|
|
||||||
xmlFreeGlobalState(globalval);
|
|
||||||
TlsSetValue(globalkey, NULL);
|
|
||||||
}
|
|
||||||
if (p) {
|
|
||||||
EnterCriticalSection(&cleanup_helpers_cs);
|
|
||||||
if (p == cleanup_helpers_head)
|
|
||||||
cleanup_helpers_head = p->next;
|
|
||||||
else
|
|
||||||
p->prev->next = p->next;
|
|
||||||
if (p->next != NULL)
|
|
||||||
p->next->prev = p->prev;
|
|
||||||
LeaveCriticalSection(&cleanup_helpers_cs);
|
|
||||||
free(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#define bottom_threads
|
|
||||||
#include "elfgcchack.h"
|
|
2
deps/libxml2/parser.c
vendored
2
deps/libxml2/parser.c
vendored
@ -12203,7 +12203,6 @@ xmlInitParser(void) {
|
|||||||
if (xmlParserInitialized != 0)
|
if (xmlParserInitialized != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xmlInitThreads();
|
|
||||||
xmlInitGlobals();
|
xmlInitGlobals();
|
||||||
if ((xmlGenericError == xmlGenericErrorDefaultFunc) ||
|
if ((xmlGenericError == xmlGenericErrorDefaultFunc) ||
|
||||||
(xmlGenericError == NULL))
|
(xmlGenericError == NULL))
|
||||||
@ -12247,7 +12246,6 @@ xmlCleanupParser(void) {
|
|||||||
xmlCleanupInputCallbacks();
|
xmlCleanupInputCallbacks();
|
||||||
xmlCleanupGlobals();
|
xmlCleanupGlobals();
|
||||||
xmlResetLastError();
|
xmlResetLastError();
|
||||||
xmlCleanupThreads(); /* must be last if called not from the main thread */
|
|
||||||
xmlCleanupMemory();
|
xmlCleanupMemory();
|
||||||
xmlParserInitialized = 0;
|
xmlParserInitialized = 0;
|
||||||
}
|
}
|
||||||
|
241
deps/libxml2/uri.c
vendored
241
deps/libxml2/uri.c
vendored
@ -2203,247 +2203,6 @@ done:
|
|||||||
return(val);
|
return(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlBuildRelativeURI:
|
|
||||||
* @URI: the URI reference under consideration
|
|
||||||
* @base: the base value
|
|
||||||
*
|
|
||||||
* Expresses the URI of the reference in terms relative to the
|
|
||||||
* base. Some examples of this operation include:
|
|
||||||
* base = "http://site1.com/docs/book1.html"
|
|
||||||
* URI input URI returned
|
|
||||||
* docs/pic1.gif pic1.gif
|
|
||||||
* docs/img/pic1.gif img/pic1.gif
|
|
||||||
* img/pic1.gif ../img/pic1.gif
|
|
||||||
* http://site1.com/docs/pic1.gif pic1.gif
|
|
||||||
* http://site2.com/docs/pic1.gif http://site2.com/docs/pic1.gif
|
|
||||||
*
|
|
||||||
* base = "docs/book1.html"
|
|
||||||
* URI input URI returned
|
|
||||||
* docs/pic1.gif pic1.gif
|
|
||||||
* docs/img/pic1.gif img/pic1.gif
|
|
||||||
* img/pic1.gif ../img/pic1.gif
|
|
||||||
* http://site1.com/docs/pic1.gif http://site1.com/docs/pic1.gif
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Note: if the URI reference is really wierd or complicated, it may be
|
|
||||||
* worthwhile to first convert it into a "nice" one by calling
|
|
||||||
* xmlBuildURI (using 'base') before calling this routine,
|
|
||||||
* since this routine (for reasonable efficiency) assumes URI has
|
|
||||||
* already been through some validation.
|
|
||||||
*
|
|
||||||
* Returns a new URI string (to be freed by the caller) or NULL in case
|
|
||||||
* error.
|
|
||||||
*/
|
|
||||||
xmlChar *
|
|
||||||
xmlBuildRelativeURI (const xmlChar * URI, const xmlChar * base)
|
|
||||||
{
|
|
||||||
xmlChar *val = NULL;
|
|
||||||
int ret;
|
|
||||||
int ix;
|
|
||||||
int pos = 0;
|
|
||||||
int nbslash = 0;
|
|
||||||
int len;
|
|
||||||
xmlURIPtr ref = NULL;
|
|
||||||
xmlURIPtr bas = NULL;
|
|
||||||
xmlChar *bptr, *uptr, *vptr;
|
|
||||||
int remove_path = 0;
|
|
||||||
|
|
||||||
if ((URI == NULL) || (*URI == 0))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* First parse URI into a standard form
|
|
||||||
*/
|
|
||||||
ref = xmlCreateURI ();
|
|
||||||
if (ref == NULL)
|
|
||||||
return NULL;
|
|
||||||
/* If URI not already in "relative" form */
|
|
||||||
if (URI[0] != '.') {
|
|
||||||
ret = xmlParseURIReference (ref, (const char *) URI);
|
|
||||||
if (ret != 0)
|
|
||||||
goto done; /* Error in URI, return NULL */
|
|
||||||
} else
|
|
||||||
ref->path = (char *)xmlStrdup(URI);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Next parse base into the same standard form
|
|
||||||
*/
|
|
||||||
if ((base == NULL) || (*base == 0)) {
|
|
||||||
val = xmlStrdup (URI);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
bas = xmlCreateURI ();
|
|
||||||
if (bas == NULL)
|
|
||||||
goto done;
|
|
||||||
if (base[0] != '.') {
|
|
||||||
ret = xmlParseURIReference (bas, (const char *) base);
|
|
||||||
if (ret != 0)
|
|
||||||
goto done; /* Error in base, return NULL */
|
|
||||||
} else
|
|
||||||
bas->path = (char *)xmlStrdup(base);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If the scheme / server on the URI differs from the base,
|
|
||||||
* just return the URI
|
|
||||||
*/
|
|
||||||
if ((ref->scheme != NULL) &&
|
|
||||||
((bas->scheme == NULL) ||
|
|
||||||
(xmlStrcmp ((xmlChar *)bas->scheme, (xmlChar *)ref->scheme)) ||
|
|
||||||
(xmlStrcmp ((xmlChar *)bas->server, (xmlChar *)ref->server)))) {
|
|
||||||
val = xmlStrdup (URI);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
if (xmlStrEqual((xmlChar *)bas->path, (xmlChar *)ref->path)) {
|
|
||||||
val = xmlStrdup(BAD_CAST "");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
if (bas->path == NULL) {
|
|
||||||
val = xmlStrdup((xmlChar *)ref->path);
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
if (ref->path == NULL) {
|
|
||||||
ref->path = (char *) "/";
|
|
||||||
remove_path = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* At this point (at last!) we can compare the two paths
|
|
||||||
*
|
|
||||||
* First we take care of the special case where either of the
|
|
||||||
* two path components may be missing (bug 316224)
|
|
||||||
*/
|
|
||||||
if (bas->path == NULL) {
|
|
||||||
if (ref->path != NULL) {
|
|
||||||
uptr = (xmlChar *) ref->path;
|
|
||||||
if (*uptr == '/')
|
|
||||||
uptr++;
|
|
||||||
/* exception characters from xmlSaveUri */
|
|
||||||
val = xmlURIEscapeStr(uptr, BAD_CAST "/;&=+$,");
|
|
||||||
}
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
bptr = (xmlChar *)bas->path;
|
|
||||||
if (ref->path == NULL) {
|
|
||||||
for (ix = 0; bptr[ix] != 0; ix++) {
|
|
||||||
if (bptr[ix] == '/')
|
|
||||||
nbslash++;
|
|
||||||
}
|
|
||||||
uptr = NULL;
|
|
||||||
len = 1; /* this is for a string terminator only */
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* Next we compare the two strings and find where they first differ
|
|
||||||
*/
|
|
||||||
if ((ref->path[pos] == '.') && (ref->path[pos+1] == '/'))
|
|
||||||
pos += 2;
|
|
||||||
if ((*bptr == '.') && (bptr[1] == '/'))
|
|
||||||
bptr += 2;
|
|
||||||
else if ((*bptr == '/') && (ref->path[pos] != '/'))
|
|
||||||
bptr++;
|
|
||||||
while ((bptr[pos] == ref->path[pos]) && (bptr[pos] != 0))
|
|
||||||
pos++;
|
|
||||||
|
|
||||||
if (bptr[pos] == ref->path[pos]) {
|
|
||||||
val = xmlStrdup(BAD_CAST "");
|
|
||||||
goto done; /* (I can't imagine why anyone would do this) */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* In URI, "back up" to the last '/' encountered. This will be the
|
|
||||||
* beginning of the "unique" suffix of URI
|
|
||||||
*/
|
|
||||||
ix = pos;
|
|
||||||
if ((ref->path[ix] == '/') && (ix > 0))
|
|
||||||
ix--;
|
|
||||||
else if ((ref->path[ix] == 0) && (ix > 1) && (ref->path[ix - 1] == '/'))
|
|
||||||
ix -= 2;
|
|
||||||
for (; ix > 0; ix--) {
|
|
||||||
if (ref->path[ix] == '/')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (ix == 0) {
|
|
||||||
uptr = (xmlChar *)ref->path;
|
|
||||||
} else {
|
|
||||||
ix++;
|
|
||||||
uptr = (xmlChar *)&ref->path[ix];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* In base, count the number of '/' from the differing point
|
|
||||||
*/
|
|
||||||
if (bptr[pos] != ref->path[pos]) {/* check for trivial URI == base */
|
|
||||||
for (; bptr[ix] != 0; ix++) {
|
|
||||||
if (bptr[ix] == '/')
|
|
||||||
nbslash++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
len = xmlStrlen (uptr) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nbslash == 0) {
|
|
||||||
if (uptr != NULL)
|
|
||||||
/* exception characters from xmlSaveUri */
|
|
||||||
val = xmlURIEscapeStr(uptr, BAD_CAST "/;&=+$,");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Allocate just enough space for the returned string -
|
|
||||||
* length of the remainder of the URI, plus enough space
|
|
||||||
* for the "../" groups, plus one for the terminator
|
|
||||||
*/
|
|
||||||
val = (xmlChar *) xmlMalloc (len + 3 * nbslash);
|
|
||||||
if (val == NULL) {
|
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlBuildRelativeURI: out of memory\n");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
vptr = val;
|
|
||||||
/*
|
|
||||||
* Put in as many "../" as needed
|
|
||||||
*/
|
|
||||||
for (; nbslash>0; nbslash--) {
|
|
||||||
*vptr++ = '.';
|
|
||||||
*vptr++ = '.';
|
|
||||||
*vptr++ = '/';
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Finish up with the end of the URI
|
|
||||||
*/
|
|
||||||
if (uptr != NULL) {
|
|
||||||
if ((vptr > val) && (len > 0) &&
|
|
||||||
(uptr[0] == '/') && (vptr[-1] == '/')) {
|
|
||||||
memcpy (vptr, uptr + 1, len - 1);
|
|
||||||
vptr[len - 2] = 0;
|
|
||||||
} else {
|
|
||||||
memcpy (vptr, uptr, len);
|
|
||||||
vptr[len - 1] = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
vptr[len - 1] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* escape the freshly-built path */
|
|
||||||
vptr = val;
|
|
||||||
/* exception characters from xmlSaveUri */
|
|
||||||
val = xmlURIEscapeStr(vptr, BAD_CAST "/;&=+$,");
|
|
||||||
xmlFree(vptr);
|
|
||||||
|
|
||||||
done:
|
|
||||||
/*
|
|
||||||
* Free the working variables
|
|
||||||
*/
|
|
||||||
if (remove_path != 0)
|
|
||||||
ref->path = NULL;
|
|
||||||
if (ref != NULL)
|
|
||||||
xmlFreeURI (ref);
|
|
||||||
if (bas != NULL)
|
|
||||||
xmlFreeURI (bas);
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlCanonicPath:
|
* xmlCanonicPath:
|
||||||
* @path: the resource locator in a filesystem notation
|
* @path: the resource locator in a filesystem notation
|
||||||
|
1
deps/libxml2/xmllint.c
vendored
1
deps/libxml2/xmllint.c
vendored
@ -1927,7 +1927,6 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
|
|||||||
static void showVersion(const char *name) {
|
static void showVersion(const char *name) {
|
||||||
fprintf(stderr, "%s: using libxml version %s\n", name, xmlParserVersion);
|
fprintf(stderr, "%s: using libxml version %s\n", name, xmlParserVersion);
|
||||||
fprintf(stderr, " compiled with: ");
|
fprintf(stderr, " compiled with: ");
|
||||||
if (xmlHasFeature(XML_WITH_THREAD)) fprintf(stderr, "Threads ");
|
|
||||||
if (xmlHasFeature(XML_WITH_TREE)) fprintf(stderr, "Tree ");
|
if (xmlHasFeature(XML_WITH_TREE)) fprintf(stderr, "Tree ");
|
||||||
if (xmlHasFeature(XML_WITH_OUTPUT)) fprintf(stderr, "Output ");
|
if (xmlHasFeature(XML_WITH_OUTPUT)) fprintf(stderr, "Output ");
|
||||||
if (xmlHasFeature(XML_WITH_PUSH)) fprintf(stderr, "Push ");
|
if (xmlHasFeature(XML_WITH_PUSH)) fprintf(stderr, "Push ");
|
||||||
|
16
deps/libxml2/xmlmemory.c
vendored
16
deps/libxml2/xmlmemory.c
vendored
@ -38,7 +38,6 @@ static int xmlMemInitialized = 0;
|
|||||||
static unsigned long debugMemSize = 0;
|
static unsigned long debugMemSize = 0;
|
||||||
static unsigned long debugMemBlocks = 0;
|
static unsigned long debugMemBlocks = 0;
|
||||||
static unsigned long debugMaxMemSize = 0;
|
static unsigned long debugMaxMemSize = 0;
|
||||||
static xmlMutexPtr xmlMemMutex = NULL;
|
|
||||||
|
|
||||||
void xmlMallocBreakpoint(void);
|
void xmlMallocBreakpoint(void);
|
||||||
|
|
||||||
@ -153,12 +152,10 @@ xmlMallocLoc(size_t size, const char * file, int line)
|
|||||||
p->mh_type = MALLOC_TYPE;
|
p->mh_type = MALLOC_TYPE;
|
||||||
p->mh_file = file;
|
p->mh_file = file;
|
||||||
p->mh_line = line;
|
p->mh_line = line;
|
||||||
xmlMutexLock(xmlMemMutex);
|
|
||||||
p->mh_number = ++block;
|
p->mh_number = ++block;
|
||||||
debugMemSize += size;
|
debugMemSize += size;
|
||||||
debugMemBlocks++;
|
debugMemBlocks++;
|
||||||
if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize;
|
if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize;
|
||||||
xmlMutexUnlock(xmlMemMutex);
|
|
||||||
|
|
||||||
|
|
||||||
if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint();
|
if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint();
|
||||||
@ -211,12 +208,10 @@ xmlMallocAtomicLoc(size_t size, const char * file, int line)
|
|||||||
p->mh_type = MALLOC_ATOMIC_TYPE;
|
p->mh_type = MALLOC_ATOMIC_TYPE;
|
||||||
p->mh_file = file;
|
p->mh_file = file;
|
||||||
p->mh_line = line;
|
p->mh_line = line;
|
||||||
xmlMutexLock(xmlMemMutex);
|
|
||||||
p->mh_number = ++block;
|
p->mh_number = ++block;
|
||||||
debugMemSize += size;
|
debugMemSize += size;
|
||||||
debugMemBlocks++;
|
debugMemBlocks++;
|
||||||
if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize;
|
if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize;
|
||||||
xmlMutexUnlock(xmlMemMutex);
|
|
||||||
|
|
||||||
|
|
||||||
if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint();
|
if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint();
|
||||||
@ -281,10 +276,8 @@ xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
p->mh_tag = ~MEMTAG;
|
p->mh_tag = ~MEMTAG;
|
||||||
xmlMutexLock(xmlMemMutex);
|
|
||||||
debugMemSize -= p->mh_size;
|
debugMemSize -= p->mh_size;
|
||||||
debugMemBlocks--;
|
debugMemBlocks--;
|
||||||
xmlMutexUnlock(xmlMemMutex);
|
|
||||||
|
|
||||||
p = (MEMHDR *) realloc(p,RESERVE_SIZE+size);
|
p = (MEMHDR *) realloc(p,RESERVE_SIZE+size);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
@ -303,11 +296,9 @@ xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
|
|||||||
p->mh_size = size;
|
p->mh_size = size;
|
||||||
p->mh_file = file;
|
p->mh_file = file;
|
||||||
p->mh_line = line;
|
p->mh_line = line;
|
||||||
xmlMutexLock(xmlMemMutex);
|
|
||||||
debugMemSize += size;
|
debugMemSize += size;
|
||||||
debugMemBlocks++;
|
debugMemBlocks++;
|
||||||
if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize;
|
if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize;
|
||||||
xmlMutexUnlock(xmlMemMutex);
|
|
||||||
|
|
||||||
TEST_POINT
|
TEST_POINT
|
||||||
|
|
||||||
@ -371,10 +362,8 @@ xmlMemFree(void *ptr)
|
|||||||
if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint();
|
if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint();
|
||||||
p->mh_tag = ~MEMTAG;
|
p->mh_tag = ~MEMTAG;
|
||||||
memset(target, -1, p->mh_size);
|
memset(target, -1, p->mh_size);
|
||||||
xmlMutexLock(xmlMemMutex);
|
|
||||||
debugMemSize -= p->mh_size;
|
debugMemSize -= p->mh_size;
|
||||||
debugMemBlocks--;
|
debugMemBlocks--;
|
||||||
xmlMutexUnlock(xmlMemMutex);
|
|
||||||
|
|
||||||
free(p);
|
free(p);
|
||||||
|
|
||||||
@ -420,12 +409,10 @@ xmlMemStrdupLoc(const char *str, const char *file, int line)
|
|||||||
p->mh_type = STRDUP_TYPE;
|
p->mh_type = STRDUP_TYPE;
|
||||||
p->mh_file = file;
|
p->mh_file = file;
|
||||||
p->mh_line = line;
|
p->mh_line = line;
|
||||||
xmlMutexLock(xmlMemMutex);
|
|
||||||
p->mh_number = ++block;
|
p->mh_number = ++block;
|
||||||
debugMemSize += size;
|
debugMemSize += size;
|
||||||
debugMemBlocks++;
|
debugMemBlocks++;
|
||||||
if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize;
|
if (debugMemSize > debugMaxMemSize) debugMaxMemSize = debugMemSize;
|
||||||
xmlMutexUnlock(xmlMemMutex);
|
|
||||||
|
|
||||||
s = (char *) HDR_2_CLIENT(p);
|
s = (char *) HDR_2_CLIENT(p);
|
||||||
|
|
||||||
@ -611,7 +598,6 @@ xmlInitMemory(void)
|
|||||||
*/
|
*/
|
||||||
if (xmlMemInitialized) return(-1);
|
if (xmlMemInitialized) return(-1);
|
||||||
xmlMemInitialized = 1;
|
xmlMemInitialized = 1;
|
||||||
xmlMemMutex = xmlNewMutex();
|
|
||||||
|
|
||||||
#ifdef HAVE_STDLIB_H
|
#ifdef HAVE_STDLIB_H
|
||||||
breakpoint = getenv("XML_MEM_BREAKPOINT");
|
breakpoint = getenv("XML_MEM_BREAKPOINT");
|
||||||
@ -640,8 +626,6 @@ xmlCleanupMemory(void) {
|
|||||||
if (xmlMemInitialized == 0)
|
if (xmlMemInitialized == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xmlFreeMutex(xmlMemMutex);
|
|
||||||
xmlMemMutex = NULL;
|
|
||||||
xmlMemInitialized = 0;
|
xmlMemInitialized = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
66
deps/libxml2/xmlsave.c
vendored
66
deps/libxml2/xmlsave.c
vendored
@ -1,66 +0,0 @@
|
|||||||
/*
|
|
||||||
* xmlsave.c: Implemetation of the document serializer
|
|
||||||
*
|
|
||||||
* See Copyright for the status of this software.
|
|
||||||
*
|
|
||||||
* daniel@veillard.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define IN_LIBXML
|
|
||||||
#include "libxml.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <libxml/xmlmemory.h>
|
|
||||||
#include <libxml/parserInternals.h>
|
|
||||||
#include <libxml/tree.h>
|
|
||||||
#include <libxml/xmlsave.h>
|
|
||||||
|
|
||||||
#define MAX_INDENT 60
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* *
|
|
||||||
* XHTML detection *
|
|
||||||
* *
|
|
||||||
************************************************************************/
|
|
||||||
#define XHTML_STRICT_PUBLIC_ID BAD_CAST \
|
|
||||||
"-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
||||||
#define XHTML_STRICT_SYSTEM_ID BAD_CAST \
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
|
|
||||||
#define XHTML_FRAME_PUBLIC_ID BAD_CAST \
|
|
||||||
"-//W3C//DTD XHTML 1.0 Frameset//EN"
|
|
||||||
#define XHTML_FRAME_SYSTEM_ID BAD_CAST \
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"
|
|
||||||
#define XHTML_TRANS_PUBLIC_ID BAD_CAST \
|
|
||||||
"-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
||||||
#define XHTML_TRANS_SYSTEM_ID BAD_CAST \
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
|
|
||||||
|
|
||||||
#define XHTML_NS_NAME BAD_CAST "http://www.w3.org/1999/xhtml"
|
|
||||||
/**
|
|
||||||
* xmlIsXHTML:
|
|
||||||
* @systemID: the system identifier
|
|
||||||
* @publicID: the public identifier
|
|
||||||
*
|
|
||||||
* Try to find if the document correspond to an XHTML DTD
|
|
||||||
*
|
|
||||||
* Returns 1 if true, 0 if not and -1 in case of error
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
xmlIsXHTML(const xmlChar *systemID, const xmlChar *publicID) {
|
|
||||||
if ((systemID == NULL) && (publicID == NULL))
|
|
||||||
return(-1);
|
|
||||||
if (publicID != NULL) {
|
|
||||||
if (xmlStrEqual(publicID, XHTML_STRICT_PUBLIC_ID)) return(1);
|
|
||||||
if (xmlStrEqual(publicID, XHTML_FRAME_PUBLIC_ID)) return(1);
|
|
||||||
if (xmlStrEqual(publicID, XHTML_TRANS_PUBLIC_ID)) return(1);
|
|
||||||
}
|
|
||||||
if (systemID != NULL) {
|
|
||||||
if (xmlStrEqual(systemID, XHTML_STRICT_SYSTEM_ID)) return(1);
|
|
||||||
if (xmlStrEqual(systemID, XHTML_FRAME_SYSTEM_ID)) return(1);
|
|
||||||
if (xmlStrEqual(systemID, XHTML_TRANS_SYSTEM_ID)) return(1);
|
|
||||||
}
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define bottom_xmlsave
|
|
||||||
#include "elfgcchack.h"
|
|
Loading…
x
Reference in New Issue
Block a user