mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-19 14:50:07 +03:00
globals: Also use global state struct if threads are disabled
This commit is contained in:
parent
a15ad9b268
commit
3d37ff84c3
4
dict.c
4
dict.c
@ -1062,10 +1062,6 @@ xmlGlobalRandom(void) {
|
||||
*/
|
||||
unsigned
|
||||
xmlRandom(void) {
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
return(xoroshiro64ss(xmlGetLocalRngState()));
|
||||
#else
|
||||
return(xmlGlobalRandom());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -60,11 +60,6 @@ ignored_words = {
|
||||
"ATTRIBUTE_COUNTED_BY": (3, "macro keyword"),
|
||||
"XML_DEPRECATED": (0, "macro keyword"),
|
||||
"XML_DEPRECATED_MEMBER": (0, "macro keyword"),
|
||||
"XML_GLOBALS_ALLOC": (0, "macro keyword"),
|
||||
"XML_GLOBALS_ERROR": (0, "macro keyword"),
|
||||
"XML_GLOBALS_IO": (0, "macro keyword"),
|
||||
"XML_GLOBALS_PARSER": (0, "macro keyword"),
|
||||
"XML_GLOBALS_TREE": (0, "macro keyword"),
|
||||
"XML_THREAD_LOCAL": (0, "macro keyword"),
|
||||
}
|
||||
|
||||
|
@ -652,9 +652,6 @@
|
||||
<exports symbol='_xmlSAXHandler' type='struct'/>
|
||||
<exports symbol='_xmlSAXHandlerV1' type='struct'/>
|
||||
<exports symbol='_xmlSAXLocator' type='struct'/>
|
||||
<exports symbol='xmlDefaultSAXHandler' type='variable'/>
|
||||
<exports symbol='xmlDefaultSAXLocator' type='variable'/>
|
||||
<exports symbol='xmlParserDebugEntities' type='variable'/>
|
||||
<exports symbol='xmlParserVersion' type='variable'/>
|
||||
<exports symbol='attributeDeclSAXFunc' type='function'/>
|
||||
<exports symbol='attributeSAXFunc' type='function'/>
|
||||
@ -1445,8 +1442,6 @@
|
||||
<exports symbol='_xmlNotation' type='struct'/>
|
||||
<exports symbol='_xmlNs' type='struct'/>
|
||||
<exports symbol='_xmlRef' type='struct'/>
|
||||
<exports symbol='xmlBufferAllocScheme' type='variable'/>
|
||||
<exports symbol='xmlDefaultBufferSize' type='variable'/>
|
||||
<exports symbol='xmlAddChild' type='function'/>
|
||||
<exports symbol='xmlAddChildList' type='function'/>
|
||||
<exports symbol='xmlAddNextSibling' type='function'/>
|
||||
@ -6750,18 +6745,6 @@ crash if you try to modify the tree)'/>
|
||||
<variable name='htmlDefaultSAXHandler' file='HTMLparser' type='const xmlSAXHandlerV1'>
|
||||
<info>DEPRECATED: This handler is unused and will be removed from future versions. Default old SAX v1 handler for HTML, builds the DOM tree</info>
|
||||
</variable>
|
||||
<variable name='xmlBufferAllocScheme' file='tree' type='const xmlBufferAllocationScheme'>
|
||||
<info>DEPRECATED: Don't use. Global setting, default allocation policy for buffers, default is XML_BUFFER_ALLOC_EXACT</info>
|
||||
</variable>
|
||||
<variable name='xmlDefaultBufferSize' file='tree' type='const int'>
|
||||
<info>DEPRECATED: Don't use. Global setting, default buffer size. Default value is BASE_BUFFER_SIZE</info>
|
||||
</variable>
|
||||
<variable name='xmlDefaultSAXHandler' file='parser' type='const xmlSAXHandlerV1'>
|
||||
<info>DEPRECATED: This handler is unused and will be removed from future versions. Default SAX version1 handler for XML, builds the DOM tree</info>
|
||||
</variable>
|
||||
<variable name='xmlDefaultSAXLocator' file='parser' type='const xmlSAXLocator'>
|
||||
<info>DEPRECATED: Don't use The default SAX Locator { getPublicId, getSystemId, getLineNumber, getColumnNumber}</info>
|
||||
</variable>
|
||||
<variable name='xmlFree' file='xmlmemory' type='xmlFreeFunc'>
|
||||
<info>@mem: an already allocated block of memory The variable holding the libxml free() implementation</info>
|
||||
</variable>
|
||||
@ -6781,9 +6764,6 @@ crash if you try to modify the tree)'/>
|
||||
<variable name='xmlMemStrdup' file='xmlmemory' type='xmlStrdupFunc'>
|
||||
<info>@str: a zero terminated string The variable holding the libxml strdup() implementation Returns the copy of the string or NULL in case of error</info>
|
||||
</variable>
|
||||
<variable name='xmlParserDebugEntities' file='parser' type='const int'>
|
||||
<info>DEPRECATED, always 0.</info>
|
||||
</variable>
|
||||
<variable name='xmlParserMaxDepth' file='parserInternals' type='const unsigned int'>
|
||||
<info>arbitrary depth limit for the XML documents that we allow to process. This is not a limitation of the parser but a safety boundary feature. It can be disabled with the XML_PARSE_HUGE parser option.</info>
|
||||
</variable>
|
||||
|
549
globals.c
549
globals.c
@ -74,6 +74,54 @@ static xmlMutex xmlThrDefMutex;
|
||||
* pointer.
|
||||
*/
|
||||
|
||||
struct _xmlGlobalState {
|
||||
#ifdef USE_TLS
|
||||
int initialized;
|
||||
#endif
|
||||
|
||||
#ifdef USE_WAIT_DTOR
|
||||
void *threadHandle;
|
||||
void *waitHandle;
|
||||
#endif
|
||||
|
||||
unsigned localRngState[2];
|
||||
|
||||
xmlError lastError;
|
||||
|
||||
#ifdef LIBXML_THREAD_ALLOC_ENABLED
|
||||
xmlMallocFunc malloc;
|
||||
xmlMallocFunc mallocAtomic;
|
||||
xmlReallocFunc realloc;
|
||||
xmlFreeFunc free;
|
||||
xmlStrdupFunc memStrdup;
|
||||
#endif
|
||||
|
||||
int doValidityCheckingDefaultValue;
|
||||
int getWarningsDefaultValue;
|
||||
int keepBlanksDefaultValue;
|
||||
int lineNumbersDefaultValue;
|
||||
int loadExtDtdDefaultValue;
|
||||
int pedanticParserDefaultValue;
|
||||
int substituteEntitiesDefaultValue;
|
||||
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
int indentTreeOutput;
|
||||
const char *treeIndentString;
|
||||
int saveNoEmptyTags;
|
||||
#endif
|
||||
|
||||
xmlGenericErrorFunc genericError;
|
||||
void *genericErrorContext;
|
||||
xmlStructuredErrorFunc structuredError;
|
||||
void *structuredErrorContext;
|
||||
|
||||
xmlRegisterNodeFunc registerNodeDefaultValue;
|
||||
xmlDeregisterNodeFunc deregisterNodeDefaultValue;
|
||||
|
||||
xmlParserInputBufferCreateFilenameFunc parserInputBufferCreateFilenameValue;
|
||||
xmlOutputBufferCreateFilenameFunc outputBufferCreateFilenameValue;
|
||||
};
|
||||
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
|
||||
/*
|
||||
@ -98,32 +146,6 @@ static xmlMutex xmlThrDefMutex;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define XML_DECLARE_MEMBER(name, type, attrs) \
|
||||
type gs_##name;
|
||||
|
||||
struct _xmlGlobalState {
|
||||
#ifdef USE_TLS
|
||||
int initialized;
|
||||
#endif
|
||||
|
||||
#ifdef USE_WAIT_DTOR
|
||||
void *threadHandle;
|
||||
void *waitHandle;
|
||||
#endif
|
||||
|
||||
unsigned localRngState[2];
|
||||
|
||||
xmlError lastError;
|
||||
|
||||
#define XML_OP XML_DECLARE_MEMBER
|
||||
XML_GLOBALS_ALLOC
|
||||
XML_GLOBALS_PARSER
|
||||
XML_GLOBALS_ERROR
|
||||
XML_GLOBALS_TREE
|
||||
XML_GLOBALS_IO
|
||||
#undef XML_OP
|
||||
};
|
||||
|
||||
#ifdef USE_TLS
|
||||
static XML_THREAD_LOCAL xmlGlobalState globalState;
|
||||
#endif
|
||||
@ -148,6 +170,10 @@ static DWORD globalkey = TLS_OUT_OF_INDEXES;
|
||||
static void
|
||||
xmlFreeGlobalState(void *state);
|
||||
|
||||
#else /* LIBXML_THREAD_ENABLED */
|
||||
|
||||
static xmlGlobalState globalState;
|
||||
|
||||
#endif /* LIBXML_THREAD_ENABLED */
|
||||
|
||||
/************************************************************************
|
||||
@ -247,234 +273,31 @@ const int xmlDefaultBufferSize = BASE_BUFFER_SIZE;
|
||||
* DEPRECATED, always 0.
|
||||
*/
|
||||
const int xmlParserDebugEntities = 0;
|
||||
/**
|
||||
* xmlDoValidityCheckingDefaultValue:
|
||||
*
|
||||
* DEPRECATED: Use the modern options API with XML_PARSE_DTDVALID.
|
||||
*
|
||||
* Global setting, indicate that the parser should work in validating mode.
|
||||
* Disabled by default.
|
||||
*/
|
||||
#if !defined(LIBXML_THREAD_ENABLED)
|
||||
int xmlDoValidityCheckingDefaultValue = 0;
|
||||
#endif
|
||||
|
||||
static int xmlDoValidityCheckingDefaultValueThrDef = 0;
|
||||
/**
|
||||
* xmlGetWarningsDefaultValue:
|
||||
*
|
||||
* DEPRECATED: Use the modern options API with XML_PARSE_NOWARNING.
|
||||
*
|
||||
* Global setting, indicate that the DTD validation should provide warnings.
|
||||
* Activated by default.
|
||||
*/
|
||||
#if !defined(LIBXML_THREAD_ENABLED)
|
||||
int xmlGetWarningsDefaultValue = 1;
|
||||
#endif
|
||||
static int xmlGetWarningsDefaultValueThrDef = 1;
|
||||
/**
|
||||
* xmlLoadExtDtdDefaultValue:
|
||||
*
|
||||
* DEPRECATED: Use the modern options API with XML_PARSE_DTDLOAD.
|
||||
*
|
||||
* Global setting, indicate that the parser should load DTD while not
|
||||
* validating.
|
||||
* Disabled by default.
|
||||
*/
|
||||
#if !defined(LIBXML_THREAD_ENABLED)
|
||||
int xmlLoadExtDtdDefaultValue = 0;
|
||||
#endif
|
||||
static int xmlLoadExtDtdDefaultValueThrDef = 0;
|
||||
/**
|
||||
* xmlPedanticParserDefaultValue:
|
||||
*
|
||||
* DEPRECATED: Use the modern options API with XML_PARSE_PEDANTIC.
|
||||
*
|
||||
* Global setting, indicate that the parser be pedantic
|
||||
* Disabled by default.
|
||||
*/
|
||||
#if !defined(LIBXML_THREAD_ENABLED)
|
||||
int xmlPedanticParserDefaultValue = 0;
|
||||
#endif
|
||||
static int xmlPedanticParserDefaultValueThrDef = 0;
|
||||
/**
|
||||
* xmlLineNumbersDefaultValue:
|
||||
*
|
||||
* DEPRECATED: The modern options API always enables line numbers.
|
||||
*
|
||||
* Global setting, indicate that the parser should store the line number
|
||||
* in the content field of elements in the DOM tree.
|
||||
* Disabled by default since this may not be safe for old classes of
|
||||
* application.
|
||||
*/
|
||||
#if !defined(LIBXML_THREAD_ENABLED)
|
||||
int xmlLineNumbersDefaultValue = 0;
|
||||
#endif
|
||||
static int xmlLineNumbersDefaultValueThrDef = 0;
|
||||
/**
|
||||
* xmlKeepBlanksDefaultValue:
|
||||
*
|
||||
* DEPRECATED: Use the modern options API with XML_PARSE_NOBLANKS.
|
||||
*
|
||||
* Global setting, indicate that the parser should keep all blanks
|
||||
* nodes found in the content
|
||||
* Activated by default, this is actually needed to have the parser
|
||||
* conformant to the XML Recommendation, however the option is kept
|
||||
* for some applications since this was libxml1 default behaviour.
|
||||
*/
|
||||
#if !defined(LIBXML_THREAD_ENABLED)
|
||||
int xmlKeepBlanksDefaultValue = 1;
|
||||
#endif
|
||||
static int xmlKeepBlanksDefaultValueThrDef = 1;
|
||||
/**
|
||||
* xmlSubstituteEntitiesDefaultValue:
|
||||
*
|
||||
* DEPRECATED: Use the modern options API with XML_PARSE_NOENT.
|
||||
*
|
||||
* Global setting, indicate that the parser should not generate entity
|
||||
* references but replace them with the actual content of the entity
|
||||
* Disabled by default, this should be activated when using XPath since
|
||||
* the XPath data model requires entities replacement and the XPath
|
||||
* engine does not handle entities references transparently.
|
||||
*/
|
||||
#if !defined(LIBXML_THREAD_ENABLED)
|
||||
int xmlSubstituteEntitiesDefaultValue = 0;
|
||||
#endif
|
||||
static int xmlSubstituteEntitiesDefaultValueThrDef = 0;
|
||||
|
||||
/**
|
||||
* xmlRegisterNodeDefaultValue:
|
||||
*
|
||||
* DEPRECATED: Don't use
|
||||
*/
|
||||
#if !defined(LIBXML_THREAD_ENABLED)
|
||||
xmlRegisterNodeFunc xmlRegisterNodeDefaultValue = NULL;
|
||||
#endif
|
||||
static xmlRegisterNodeFunc xmlRegisterNodeDefaultValueThrDef = NULL;
|
||||
|
||||
/**
|
||||
* xmlDeregisterNodeDefaultValue:
|
||||
*
|
||||
* DEPRECATED: Don't use
|
||||
*/
|
||||
#if !defined(LIBXML_THREAD_ENABLED)
|
||||
xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue = NULL;
|
||||
#endif
|
||||
static xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValueThrDef = NULL;
|
||||
|
||||
/**
|
||||
* xmlParserInputBufferCreateFilenameValue:
|
||||
*
|
||||
* DEPRECATED: Don't use
|
||||
*/
|
||||
#if !defined(LIBXML_THREAD_ENABLED)
|
||||
xmlParserInputBufferCreateFilenameFunc
|
||||
xmlParserInputBufferCreateFilenameValue = NULL;
|
||||
#endif
|
||||
static xmlParserInputBufferCreateFilenameFunc
|
||||
xmlParserInputBufferCreateFilenameValueThrDef = NULL;
|
||||
|
||||
/**
|
||||
* xmlOutputBufferCreateFilenameValue:
|
||||
*
|
||||
* DEPRECATED: Don't use
|
||||
*/
|
||||
#if !defined(LIBXML_THREAD_ENABLED)
|
||||
xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue = NULL;
|
||||
#endif
|
||||
static xmlOutputBufferCreateFilenameFunc
|
||||
xmlOutputBufferCreateFilenameValueThrDef = NULL;
|
||||
|
||||
/**
|
||||
* xmlGenericError:
|
||||
*
|
||||
* DEPRECATED: Use xmlCtxtSetErrorHandler.
|
||||
*
|
||||
* Global setting: function used for generic error callbacks
|
||||
*/
|
||||
#if !defined(LIBXML_THREAD_ENABLED)
|
||||
xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc;
|
||||
#endif
|
||||
static xmlGenericErrorFunc xmlGenericErrorThrDef = xmlGenericErrorDefaultFunc;
|
||||
/**
|
||||
* xmlStructuredError:
|
||||
*
|
||||
* DEPRECATED: Use xmlCtxtSetErrorHandler.
|
||||
*
|
||||
* Global setting: function used for structured error callbacks
|
||||
*/
|
||||
#if !defined(LIBXML_THREAD_ENABLED)
|
||||
xmlStructuredErrorFunc xmlStructuredError = NULL;
|
||||
#endif
|
||||
static xmlStructuredErrorFunc xmlStructuredErrorThrDef = NULL;
|
||||
/**
|
||||
* xmlGenericErrorContext:
|
||||
*
|
||||
* DEPRECATED: Use xmlCtxtSetErrorHandler.
|
||||
*
|
||||
* Global setting passed to generic error callbacks
|
||||
*/
|
||||
#if !defined(LIBXML_THREAD_ENABLED)
|
||||
void *xmlGenericErrorContext = NULL;
|
||||
#endif
|
||||
static void *xmlGenericErrorContextThrDef = NULL;
|
||||
/**
|
||||
* xmlStructuredErrorContext:
|
||||
*
|
||||
* DEPRECATED: Use xmlCtxtSetErrorHandler.
|
||||
*
|
||||
* Global setting passed to structured error callbacks
|
||||
*/
|
||||
#if !defined(LIBXML_THREAD_ENABLED)
|
||||
void *xmlStructuredErrorContext = NULL;
|
||||
#endif
|
||||
static void *xmlStructuredErrorContextThrDef = NULL;
|
||||
#if !defined(LIBXML_THREAD_ENABLED)
|
||||
xmlError xmlLastError;
|
||||
#endif
|
||||
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
/*
|
||||
* output defaults
|
||||
*/
|
||||
/**
|
||||
* xmlIndentTreeOutput:
|
||||
*
|
||||
* DEPRECATED: Use XML_SAVE_INDENT and XML_SAVE_NO_INDENT.
|
||||
*
|
||||
* Global setting, asking the serializer to indent the output tree by default
|
||||
* Enabled by default
|
||||
*/
|
||||
#if !defined(LIBXML_THREAD_ENABLED)
|
||||
int xmlIndentTreeOutput = 1;
|
||||
#endif
|
||||
static int xmlIndentTreeOutputThrDef = 1;
|
||||
|
||||
/**
|
||||
* xmlTreeIndentString:
|
||||
*
|
||||
* DEPRECATED: Use xmlSaveSetIndentString.
|
||||
*
|
||||
* The string used to do one-level indent. By default is equal to
|
||||
* " " (two spaces)
|
||||
*/
|
||||
#if !defined(LIBXML_THREAD_ENABLED)
|
||||
const char *xmlTreeIndentString = " ";
|
||||
#endif
|
||||
static const char *xmlTreeIndentStringThrDef = " ";
|
||||
|
||||
/**
|
||||
* xmlSaveNoEmptyTags:
|
||||
*
|
||||
* DEPRECATED: Use XML_SAVE_EMPTY and XML_SAVE_NO_EMPTY.
|
||||
*
|
||||
* Global setting, asking the serializer to not output empty tags
|
||||
* as <empty/> but <empty></empty>. those two forms are indistinguishable
|
||||
* once parsed.
|
||||
* Disabled by default
|
||||
*/
|
||||
#if !defined(LIBXML_THREAD_ENABLED)
|
||||
int xmlSaveNoEmptyTags = 0;
|
||||
#endif
|
||||
static int xmlSaveNoEmptyTagsThrDef = 0;
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
|
||||
@ -575,6 +398,9 @@ const xmlSAXHandlerV1 htmlDefaultSAXHandler = {
|
||||
};
|
||||
#endif /* LIBXML_HTML_ENABLED */
|
||||
|
||||
static void
|
||||
xmlInitGlobalState(xmlGlobalStatePtr gs);
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Per thread global state handling *
|
||||
@ -605,6 +431,8 @@ void xmlInitGlobalsInternal(void) {
|
||||
if (globalkey == TLS_OUT_OF_INDEXES)
|
||||
globalkey = TlsAlloc();
|
||||
#endif
|
||||
#else /* no thread support */
|
||||
xmlInitGlobalState(&globalState);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -648,7 +476,7 @@ void xmlCleanupGlobalsInternal(void) {
|
||||
}
|
||||
#endif
|
||||
#else /* no thread support */
|
||||
xmlResetError(&xmlLastError);
|
||||
xmlResetError(&globalState.lastError);
|
||||
#endif
|
||||
|
||||
xmlCleanupMutex(&xmlThrDefMutex);
|
||||
@ -692,6 +520,74 @@ xmlIsMainThread(void) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void
|
||||
xmlInitGlobalState(xmlGlobalStatePtr gs) {
|
||||
gs->localRngState[0] = xmlGlobalRandom();
|
||||
gs->localRngState[1] = xmlGlobalRandom();
|
||||
|
||||
memset(&gs->lastError, 0, sizeof(xmlError));
|
||||
|
||||
#ifdef LIBXML_THREAD_ALLOC_ENABLED
|
||||
/* XML_GLOBALS_ALLOC */
|
||||
gs->gs_xmlFree = free;
|
||||
gs->gs_xmlMalloc = malloc;
|
||||
gs->gs_xmlMallocAtomic = malloc;
|
||||
gs->gs_xmlRealloc = realloc;
|
||||
gs->gs_xmlMemStrdup = xmlPosixStrdup;
|
||||
#endif
|
||||
|
||||
xmlMutexLock(&xmlThrDefMutex);
|
||||
|
||||
/* XML_GLOBALS_PARSER */
|
||||
gs->doValidityCheckingDefaultValue =
|
||||
xmlDoValidityCheckingDefaultValueThrDef;
|
||||
gs->getWarningsDefaultValue = xmlGetWarningsDefaultValueThrDef;
|
||||
gs->keepBlanksDefaultValue = xmlKeepBlanksDefaultValueThrDef;
|
||||
gs->lineNumbersDefaultValue = xmlLineNumbersDefaultValueThrDef;
|
||||
gs->loadExtDtdDefaultValue = xmlLoadExtDtdDefaultValueThrDef;
|
||||
gs->pedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef;
|
||||
gs->substituteEntitiesDefaultValue =
|
||||
xmlSubstituteEntitiesDefaultValueThrDef;
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
gs->indentTreeOutput = xmlIndentTreeOutputThrDef;
|
||||
gs->treeIndentString = xmlTreeIndentStringThrDef;
|
||||
gs->saveNoEmptyTags = xmlSaveNoEmptyTagsThrDef;
|
||||
#endif
|
||||
|
||||
/* XML_GLOBALS_ERROR */
|
||||
gs->genericError = xmlGenericErrorThrDef;
|
||||
gs->structuredError = xmlStructuredErrorThrDef;
|
||||
gs->genericErrorContext = xmlGenericErrorContextThrDef;
|
||||
gs->structuredErrorContext = xmlStructuredErrorContextThrDef;
|
||||
|
||||
/* XML_GLOBALS_TREE */
|
||||
gs->registerNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
|
||||
gs->deregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
|
||||
|
||||
/* XML_GLOBALS_IO */
|
||||
gs->parserInputBufferCreateFilenameValue =
|
||||
xmlParserInputBufferCreateFilenameValueThrDef;
|
||||
gs->outputBufferCreateFilenameValue =
|
||||
xmlOutputBufferCreateFilenameValueThrDef;
|
||||
|
||||
xmlMutexUnlock(&xmlThrDefMutex);
|
||||
|
||||
#ifdef USE_TLS
|
||||
gs->initialized = 1;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_POSIX_THREADS
|
||||
pthread_setspecific(globalkey, gs);
|
||||
#elif defined HAVE_WIN32_THREADS
|
||||
#ifndef USE_TLS
|
||||
TlsSetValue(globalkey, gs);
|
||||
#endif
|
||||
#ifdef USE_WAIT_DTOR
|
||||
xmlRegisterGlobalStateDtor(gs);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
|
||||
static void
|
||||
@ -700,14 +596,9 @@ xmlFreeGlobalState(void *state)
|
||||
xmlGlobalState *gs = (xmlGlobalState *) state;
|
||||
|
||||
/*
|
||||
* Free any memory allocated in the thread's xmlLastError. If it
|
||||
* Free any memory allocated in the thread's error struct. If it
|
||||
* weren't for this indirect allocation, we wouldn't need
|
||||
* a destructor with thread-local storage at all!
|
||||
*
|
||||
* It would be nice if we could make xmlLastError a special error
|
||||
* type which uses statically allocated, fixed-size buffers.
|
||||
* But the xmlError struct is fully public and widely used,
|
||||
* so changes are dangerous.
|
||||
*/
|
||||
xmlResetError(&gs->lastError);
|
||||
#ifndef USE_TLS
|
||||
@ -748,74 +639,6 @@ xmlRegisterGlobalStateDtor(xmlGlobalState *gs) {
|
||||
}
|
||||
#endif /* USE_WAIT_DTOR */
|
||||
|
||||
static void
|
||||
xmlInitGlobalState(xmlGlobalStatePtr gs) {
|
||||
gs->localRngState[0] = xmlGlobalRandom();
|
||||
gs->localRngState[1] = xmlGlobalRandom();
|
||||
|
||||
memset(&gs->lastError, 0, sizeof(xmlError));
|
||||
|
||||
#ifdef LIBXML_THREAD_ALLOC_ENABLED
|
||||
/* XML_GLOBALS_ALLOC */
|
||||
gs->gs_xmlFree = free;
|
||||
gs->gs_xmlMalloc = malloc;
|
||||
gs->gs_xmlMallocAtomic = malloc;
|
||||
gs->gs_xmlRealloc = realloc;
|
||||
gs->gs_xmlMemStrdup = xmlPosixStrdup;
|
||||
#endif
|
||||
|
||||
xmlMutexLock(&xmlThrDefMutex);
|
||||
|
||||
/* XML_GLOBALS_PARSER */
|
||||
gs->gs_xmlDoValidityCheckingDefaultValue =
|
||||
xmlDoValidityCheckingDefaultValueThrDef;
|
||||
gs->gs_xmlGetWarningsDefaultValue = xmlGetWarningsDefaultValueThrDef;
|
||||
gs->gs_xmlKeepBlanksDefaultValue = xmlKeepBlanksDefaultValueThrDef;
|
||||
gs->gs_xmlLineNumbersDefaultValue = xmlLineNumbersDefaultValueThrDef;
|
||||
gs->gs_xmlLoadExtDtdDefaultValue = xmlLoadExtDtdDefaultValueThrDef;
|
||||
gs->gs_xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef;
|
||||
gs->gs_xmlSubstituteEntitiesDefaultValue =
|
||||
xmlSubstituteEntitiesDefaultValueThrDef;
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
gs->gs_xmlIndentTreeOutput = xmlIndentTreeOutputThrDef;
|
||||
gs->gs_xmlTreeIndentString = xmlTreeIndentStringThrDef;
|
||||
gs->gs_xmlSaveNoEmptyTags = xmlSaveNoEmptyTagsThrDef;
|
||||
#endif
|
||||
|
||||
/* XML_GLOBALS_ERROR */
|
||||
gs->gs_xmlGenericError = xmlGenericErrorThrDef;
|
||||
gs->gs_xmlStructuredError = xmlStructuredErrorThrDef;
|
||||
gs->gs_xmlGenericErrorContext = xmlGenericErrorContextThrDef;
|
||||
gs->gs_xmlStructuredErrorContext = xmlStructuredErrorContextThrDef;
|
||||
|
||||
/* XML_GLOBALS_TREE */
|
||||
gs->gs_xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
|
||||
gs->gs_xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
|
||||
|
||||
/* XML_GLOBALS_IO */
|
||||
gs->gs_xmlParserInputBufferCreateFilenameValue =
|
||||
xmlParserInputBufferCreateFilenameValueThrDef;
|
||||
gs->gs_xmlOutputBufferCreateFilenameValue =
|
||||
xmlOutputBufferCreateFilenameValueThrDef;
|
||||
|
||||
xmlMutexUnlock(&xmlThrDefMutex);
|
||||
|
||||
#ifdef USE_TLS
|
||||
gs->initialized = 1;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_POSIX_THREADS
|
||||
pthread_setspecific(globalkey, gs);
|
||||
#elif defined HAVE_WIN32_THREADS
|
||||
#ifndef USE_TLS
|
||||
TlsSetValue(globalkey, gs);
|
||||
#endif
|
||||
#ifdef USE_WAIT_DTOR
|
||||
xmlRegisterGlobalStateDtor(gs);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef USE_TLS
|
||||
/**
|
||||
* xmlNewGlobalState:
|
||||
@ -882,26 +705,112 @@ xmlGetThreadLocalStorage(int allowFailure) {
|
||||
return(gs);
|
||||
}
|
||||
|
||||
/* Define thread-local storage accessors with macro magic */
|
||||
#else /* LIBXML_THREAD_ENABLED */
|
||||
|
||||
#define XML_DEFINE_GLOBAL_WRAPPER(name, type, attrs) \
|
||||
type *__##name(void) { \
|
||||
return (&xmlGetThreadLocalStorage(0)->gs_##name); \
|
||||
}
|
||||
static xmlGlobalStatePtr
|
||||
xmlGetThreadLocalStorage(int allowFailure ATTRIBUTE_UNUSED) {
|
||||
return(&globalState);
|
||||
}
|
||||
|
||||
#define XML_OP XML_DEFINE_GLOBAL_WRAPPER
|
||||
XML_GLOBALS_ALLOC
|
||||
XML_GLOBALS_PARSER
|
||||
XML_GLOBALS_ERROR
|
||||
XML_GLOBALS_TREE
|
||||
XML_GLOBALS_IO
|
||||
#undef XML_OP
|
||||
#endif /* LIBXML_THREAD_ENABLED */
|
||||
|
||||
const xmlError *
|
||||
__xmlLastError(void) {
|
||||
return(&xmlGetThreadLocalStorage(0)->lastError);
|
||||
}
|
||||
|
||||
int *
|
||||
__xmlDoValidityCheckingDefaultValue(void) {
|
||||
return(&xmlGetThreadLocalStorage(0)->doValidityCheckingDefaultValue);
|
||||
}
|
||||
|
||||
int *
|
||||
__xmlGetWarningsDefaultValue(void) {
|
||||
return(&xmlGetThreadLocalStorage(0)->getWarningsDefaultValue);
|
||||
}
|
||||
|
||||
int *
|
||||
__xmlKeepBlanksDefaultValue(void) {
|
||||
return(&xmlGetThreadLocalStorage(0)->keepBlanksDefaultValue);
|
||||
}
|
||||
|
||||
int *
|
||||
__xmlLineNumbersDefaultValue(void) {
|
||||
return(&xmlGetThreadLocalStorage(0)->lineNumbersDefaultValue);
|
||||
}
|
||||
|
||||
int *
|
||||
__xmlLoadExtDtdDefaultValue(void) {
|
||||
return(&xmlGetThreadLocalStorage(0)->loadExtDtdDefaultValue);
|
||||
}
|
||||
|
||||
int *
|
||||
__xmlPedanticParserDefaultValue(void) {
|
||||
return(&xmlGetThreadLocalStorage(0)->pedanticParserDefaultValue);
|
||||
}
|
||||
|
||||
int *
|
||||
__xmlSubstituteEntitiesDefaultValue(void) {
|
||||
return(&xmlGetThreadLocalStorage(0)->substituteEntitiesDefaultValue);
|
||||
}
|
||||
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
int *
|
||||
__xmlIndentTreeOutput(void) {
|
||||
return(&xmlGetThreadLocalStorage(0)->indentTreeOutput);
|
||||
}
|
||||
|
||||
const char **
|
||||
__xmlTreeIndentString(void) {
|
||||
return(&xmlGetThreadLocalStorage(0)->treeIndentString);
|
||||
}
|
||||
|
||||
int *
|
||||
__xmlSaveNoEmptyTags(void) {
|
||||
return(&xmlGetThreadLocalStorage(0)->saveNoEmptyTags);
|
||||
}
|
||||
#endif
|
||||
|
||||
xmlGenericErrorFunc *
|
||||
__xmlGenericError(void) {
|
||||
return(&xmlGetThreadLocalStorage(0)->genericError);
|
||||
}
|
||||
|
||||
void **
|
||||
__xmlGenericErrorContext(void) {
|
||||
return(&xmlGetThreadLocalStorage(0)->genericErrorContext);
|
||||
}
|
||||
|
||||
xmlStructuredErrorFunc *
|
||||
__xmlStructuredError(void) {
|
||||
return(&xmlGetThreadLocalStorage(0)->structuredError);
|
||||
}
|
||||
|
||||
void **
|
||||
__xmlStructuredErrorContext(void) {
|
||||
return(&xmlGetThreadLocalStorage(0)->structuredErrorContext);
|
||||
}
|
||||
|
||||
xmlRegisterNodeFunc *
|
||||
__xmlRegisterNodeDefaultValue(void) {
|
||||
return(&xmlGetThreadLocalStorage(0)->registerNodeDefaultValue);
|
||||
}
|
||||
|
||||
xmlDeregisterNodeFunc *
|
||||
__xmlDeregisterNodeDefaultValue(void) {
|
||||
return(&xmlGetThreadLocalStorage(0)->deregisterNodeDefaultValue);
|
||||
}
|
||||
|
||||
xmlParserInputBufferCreateFilenameFunc *
|
||||
__xmlParserInputBufferCreateFilenameValue(void) {
|
||||
return(&xmlGetThreadLocalStorage(0)->parserInputBufferCreateFilenameValue);
|
||||
}
|
||||
|
||||
xmlOutputBufferCreateFilenameFunc *
|
||||
__xmlOutputBufferCreateFilenameValue(void) {
|
||||
return(&xmlGetThreadLocalStorage(0)->outputBufferCreateFilenameValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlGetLocalRngState:
|
||||
*
|
||||
@ -912,8 +821,6 @@ xmlGetLocalRngState(void) {
|
||||
return(xmlGetThreadLocalStorage(0)->localRngState);
|
||||
}
|
||||
|
||||
#endif /* LIBXML_THREAD_ENABLED */
|
||||
|
||||
/**
|
||||
* xmlCheckThreadLocalStorage:
|
||||
*
|
||||
@ -946,11 +853,7 @@ xmlCheckThreadLocalStorage(void) {
|
||||
*/
|
||||
xmlError *
|
||||
xmlGetLastErrorInternal(void) {
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
return(&xmlGetThreadLocalStorage(0)->lastError);
|
||||
#else
|
||||
return(&xmlLastError);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** DOC_DISABLE */
|
||||
|
@ -971,6 +971,8 @@ typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
|
||||
*/
|
||||
|
||||
XMLPUBVAR const char *const xmlParserVersion;
|
||||
|
||||
/** DOC_DISABLE */
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR const int xmlParserDebugEntities;
|
||||
XML_DEPRECATED
|
||||
@ -980,50 +982,44 @@ XML_DEPRECATED
|
||||
XMLPUBVAR const xmlSAXHandlerV1 xmlDefaultSAXHandler;
|
||||
#endif
|
||||
|
||||
/** DOC_DISABLE */
|
||||
#define XML_GLOBALS_PARSER_CORE \
|
||||
XML_OP(xmlDoValidityCheckingDefaultValue, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlGetWarningsDefaultValue, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlKeepBlanksDefaultValue, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlLineNumbersDefaultValue, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlLoadExtDtdDefaultValue, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlPedanticParserDefaultValue, int, XML_DEPRECATED) \
|
||||
XML_OP(xmlSubstituteEntitiesDefaultValue, int, XML_DEPRECATED)
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN int *__xmlDoValidityCheckingDefaultValue(void);
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN int *__xmlGetWarningsDefaultValue(void);
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN int *__xmlKeepBlanksDefaultValue(void);
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN int *__xmlLineNumbersDefaultValue(void);
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN int *__xmlLoadExtDtdDefaultValue(void);
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN int *__xmlPedanticParserDefaultValue(void);
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN int *__xmlSubstituteEntitiesDefaultValue(void);
|
||||
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
#define XML_GLOBALS_PARSER_OUTPUT \
|
||||
XML_OP(xmlIndentTreeOutput, int, XML_NO_ATTR) \
|
||||
XML_OP(xmlTreeIndentString, const char *, XML_NO_ATTR) \
|
||||
XML_OP(xmlSaveNoEmptyTags, int, XML_NO_ATTR)
|
||||
#else
|
||||
#define XML_GLOBALS_PARSER_OUTPUT
|
||||
XMLPUBFUN int *__xmlIndentTreeOutput(void);
|
||||
XMLPUBFUN const char **__xmlTreeIndentString(void);
|
||||
XMLPUBFUN int *__xmlSaveNoEmptyTags(void);
|
||||
#endif
|
||||
|
||||
#define XML_GLOBALS_PARSER \
|
||||
XML_GLOBALS_PARSER_CORE \
|
||||
XML_GLOBALS_PARSER_OUTPUT
|
||||
|
||||
#define XML_OP XML_DECLARE_GLOBAL
|
||||
XML_GLOBALS_PARSER
|
||||
#undef XML_OP
|
||||
|
||||
#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
|
||||
#ifndef XML_GLOBALS_NO_REDEFINITION
|
||||
#define xmlDoValidityCheckingDefaultValue \
|
||||
XML_GLOBAL_MACRO(xmlDoValidityCheckingDefaultValue)
|
||||
(*__xmlDoValidityCheckingDefaultValue())
|
||||
#define xmlGetWarningsDefaultValue \
|
||||
XML_GLOBAL_MACRO(xmlGetWarningsDefaultValue)
|
||||
#define xmlKeepBlanksDefaultValue XML_GLOBAL_MACRO(xmlKeepBlanksDefaultValue)
|
||||
(*__xmlGetWarningsDefaultValue())
|
||||
#define xmlKeepBlanksDefaultValue (*__xmlKeepBlanksDefaultValue())
|
||||
#define xmlLineNumbersDefaultValue \
|
||||
XML_GLOBAL_MACRO(xmlLineNumbersDefaultValue)
|
||||
#define xmlLoadExtDtdDefaultValue XML_GLOBAL_MACRO(xmlLoadExtDtdDefaultValue)
|
||||
(*__xmlLineNumbersDefaultValue())
|
||||
#define xmlLoadExtDtdDefaultValue (*__xmlLoadExtDtdDefaultValue())
|
||||
#define xmlPedanticParserDefaultValue \
|
||||
XML_GLOBAL_MACRO(xmlPedanticParserDefaultValue)
|
||||
(*__xmlPedanticParserDefaultValue())
|
||||
#define xmlSubstituteEntitiesDefaultValue \
|
||||
XML_GLOBAL_MACRO(xmlSubstituteEntitiesDefaultValue)
|
||||
(*__xmlSubstituteEntitiesDefaultValue())
|
||||
#ifdef LIBXML_OUTPUT_ENABLED
|
||||
#define xmlIndentTreeOutput XML_GLOBAL_MACRO(xmlIndentTreeOutput)
|
||||
#define xmlTreeIndentString XML_GLOBAL_MACRO(xmlTreeIndentString)
|
||||
#define xmlSaveNoEmptyTags XML_GLOBAL_MACRO(xmlSaveNoEmptyTags)
|
||||
#define xmlIndentTreeOutput (*__xmlIndentTreeOutput())
|
||||
#define xmlTreeIndentString (*__xmlTreeIndentString())
|
||||
#define xmlSaveNoEmptyTags (*__xmlSaveNoEmptyTags())
|
||||
#endif
|
||||
#endif
|
||||
/** DOC_ENABLE */
|
||||
|
@ -678,26 +678,22 @@ typedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node);
|
||||
* Variables.
|
||||
*/
|
||||
|
||||
/** DOC_DISABLE */
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR const xmlBufferAllocationScheme xmlBufferAllocScheme;
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR const int xmlDefaultBufferSize;
|
||||
|
||||
/** DOC_DISABLE */
|
||||
#define XML_GLOBALS_TREE \
|
||||
XML_OP(xmlRegisterNodeDefaultValue, xmlRegisterNodeFunc, XML_DEPRECATED) \
|
||||
XML_OP(xmlDeregisterNodeDefaultValue, xmlDeregisterNodeFunc, \
|
||||
XML_DEPRECATED)
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN xmlRegisterNodeFunc *__xmlRegisterNodeDefaultValue(void);
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN xmlDeregisterNodeFunc *__xmlDeregisterNodeDefaultValue(void);
|
||||
|
||||
#define XML_OP XML_DECLARE_GLOBAL
|
||||
XML_GLOBALS_TREE
|
||||
#undef XML_OP
|
||||
|
||||
#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
|
||||
#ifndef XML_GLOBALS_NO_REDEFINITION
|
||||
#define xmlRegisterNodeDefaultValue \
|
||||
XML_GLOBAL_MACRO(xmlRegisterNodeDefaultValue)
|
||||
(*__xmlRegisterNodeDefaultValue())
|
||||
#define xmlDeregisterNodeDefaultValue \
|
||||
XML_GLOBAL_MACRO(xmlDeregisterNodeDefaultValue)
|
||||
(*__xmlDeregisterNodeDefaultValue())
|
||||
#endif
|
||||
/** DOC_ENABLE */
|
||||
|
||||
|
@ -176,21 +176,18 @@ struct _xmlOutputBuffer {
|
||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||
|
||||
/** DOC_DISABLE */
|
||||
#define XML_GLOBALS_IO \
|
||||
XML_OP(xmlParserInputBufferCreateFilenameValue, \
|
||||
xmlParserInputBufferCreateFilenameFunc, XML_DEPRECATED) \
|
||||
XML_OP(xmlOutputBufferCreateFilenameValue, \
|
||||
xmlOutputBufferCreateFilenameFunc, XML_DEPRECATED)
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN xmlParserInputBufferCreateFilenameFunc *
|
||||
__xmlParserInputBufferCreateFilenameValue(void);
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN xmlOutputBufferCreateFilenameFunc *
|
||||
__xmlOutputBufferCreateFilenameValue(void);
|
||||
|
||||
#define XML_OP XML_DECLARE_GLOBAL
|
||||
XML_GLOBALS_IO
|
||||
#undef XML_OP
|
||||
|
||||
#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
|
||||
#ifndef XML_GLOBALS_NO_REDEFINITION
|
||||
#define xmlParserInputBufferCreateFilenameValue \
|
||||
XML_GLOBAL_MACRO(xmlParserInputBufferCreateFilenameValue)
|
||||
(*__xmlParserInputBufferCreateFilenameValue())
|
||||
#define xmlOutputBufferCreateFilenameValue \
|
||||
XML_GLOBAL_MACRO(xmlOutputBufferCreateFilenameValue)
|
||||
(*__xmlOutputBufferCreateFilenameValue())
|
||||
#endif
|
||||
/** DOC_ENABLE */
|
||||
|
||||
|
@ -870,31 +870,20 @@ typedef void (*xmlGenericErrorFunc) (void *ctx,
|
||||
typedef void (*xmlStructuredErrorFunc) (void *userData, const xmlError *error);
|
||||
|
||||
/** DOC_DISABLE */
|
||||
#if defined(LIBXML_THREAD_ENABLED)
|
||||
XML_DEPRECATED
|
||||
XMLPUBFUN const xmlError *
|
||||
__xmlLastError(void);
|
||||
#elif !defined(IN_LIBXML)
|
||||
XML_DEPRECATED
|
||||
XMLPUBVAR const xmlError xmlLastError;
|
||||
#endif
|
||||
XMLPUBFUN const xmlError *__xmlLastError(void);
|
||||
|
||||
#define XML_GLOBALS_ERROR \
|
||||
XML_OP(xmlGenericError, xmlGenericErrorFunc, XML_NO_ATTR) \
|
||||
XML_OP(xmlGenericErrorContext, void *, XML_NO_ATTR) \
|
||||
XML_OP(xmlStructuredError, xmlStructuredErrorFunc, XML_NO_ATTR) \
|
||||
XML_OP(xmlStructuredErrorContext, void *, XML_NO_ATTR)
|
||||
XMLPUBFUN xmlGenericErrorFunc *__xmlGenericError(void);
|
||||
XMLPUBFUN void **__xmlGenericErrorContext(void);
|
||||
XMLPUBFUN xmlStructuredErrorFunc *__xmlStructuredError(void);
|
||||
XMLPUBFUN void **__xmlStructuredErrorContext(void);
|
||||
|
||||
#define XML_OP XML_DECLARE_GLOBAL
|
||||
XML_GLOBALS_ERROR
|
||||
#undef XML_OP
|
||||
|
||||
#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
|
||||
#define xmlLastError XML_GLOBAL_MACRO(xmlLastError)
|
||||
#define xmlGenericError XML_GLOBAL_MACRO(xmlGenericError)
|
||||
#define xmlGenericErrorContext XML_GLOBAL_MACRO(xmlGenericErrorContext)
|
||||
#define xmlStructuredError XML_GLOBAL_MACRO(xmlStructuredError)
|
||||
#define xmlStructuredErrorContext XML_GLOBAL_MACRO(xmlStructuredErrorContext)
|
||||
#ifndef XML_GLOBALS_NO_REDEFINITION
|
||||
#define xmlLastError (*__xmlLastError())
|
||||
#define xmlGenericError (*__xmlGenericError())
|
||||
#define xmlGenericErrorContext (*__xmlGenericErrorContext())
|
||||
#define xmlStructuredError (*__xmlStructuredError())
|
||||
#define xmlStructuredErrorContext (*__xmlStructuredErrorContext())
|
||||
#endif
|
||||
/** DOC_ENABLE */
|
||||
|
||||
|
@ -114,21 +114,6 @@
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Accessors for globals
|
||||
*/
|
||||
|
||||
#define XML_NO_ATTR
|
||||
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
#define XML_DECLARE_GLOBAL(name, type, attrs) \
|
||||
attrs XMLPUBFUN type *__##name(void);
|
||||
#define XML_GLOBAL_MACRO(name) (*__##name())
|
||||
#else
|
||||
#define XML_DECLARE_GLOBAL(name, type, attrs) \
|
||||
attrs XMLPUBVAR type name;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Originally declared in xmlversion.h which is generated
|
||||
*/
|
||||
|
@ -69,27 +69,25 @@ typedef char *(*xmlStrdupFunc)(const char *str);
|
||||
* - xmlMemStrdup
|
||||
* - xmlFree
|
||||
*/
|
||||
/** DOC_DISABLE */
|
||||
#ifdef LIBXML_THREAD_ALLOC_ENABLED
|
||||
#define XML_GLOBALS_ALLOC \
|
||||
XML_OP(xmlMalloc, xmlMallocFunc, XML_NO_ATTR) \
|
||||
XML_OP(xmlMallocAtomic, xmlMallocFunc, XML_NO_ATTR) \
|
||||
XML_OP(xmlRealloc, xmlReallocFunc, XML_NO_ATTR) \
|
||||
XML_OP(xmlFree, xmlFreeFunc, XML_NO_ATTR) \
|
||||
XML_OP(xmlMemStrdup, xmlStrdupFunc, XML_NO_ATTR)
|
||||
#define XML_OP XML_DECLARE_GLOBAL
|
||||
XML_GLOBALS_ALLOC
|
||||
#undef XML_OP
|
||||
#if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
|
||||
#define xmlMalloc XML_GLOBAL_MACRO(xmlMalloc)
|
||||
#define xmlMallocAtomic XML_GLOBAL_MACRO(xmlMallocAtomic)
|
||||
#define xmlRealloc XML_GLOBAL_MACRO(xmlRealloc)
|
||||
#define xmlFree XML_GLOBAL_MACRO(xmlFree)
|
||||
#define xmlMemStrdup XML_GLOBAL_MACRO(xmlMemStrdup)
|
||||
#endif
|
||||
#else
|
||||
#define XML_GLOBALS_ALLOC
|
||||
|
||||
/** DOC_DISABLE */
|
||||
XMLPUBFUN xmlMallocFunc *__xmlMalloc(void);
|
||||
XMLPUBFUN xmlMallocFunc *__xmlMallocAtomic(void);
|
||||
XMLPUBFUN xmlReallocFunc *__xmlRealloc(void);
|
||||
XMLPUBFUN xmlFreeFunc *__xmlFree(void);
|
||||
XMLPUBFUN xmlStrdupFunc *__xmlMemStrdup(void);
|
||||
|
||||
#ifndef XML_GLOBALS_NO_REDEFINITION
|
||||
#define xmlMalloc (*__xmlMalloc())
|
||||
#define xmlMallocAtomic (*__xmlMallocAtomic())
|
||||
#define xmlRealloc (*__xmlRealloc())
|
||||
#define xmlFree (*__xmlFree())
|
||||
#define xmlMemStrdup (*__xmlMemStrdup())
|
||||
#endif
|
||||
/** DOC_ENABLE */
|
||||
|
||||
#else
|
||||
XMLPUBVAR xmlMallocFunc xmlMalloc;
|
||||
XMLPUBVAR xmlMallocFunc xmlMallocAtomic;
|
||||
XMLPUBVAR xmlReallocFunc xmlRealloc;
|
||||
|
@ -9,9 +9,7 @@ xmlCleanupGlobalsInternal(void);
|
||||
XML_HIDDEN xmlError *
|
||||
xmlGetLastErrorInternal(void);
|
||||
|
||||
#ifdef LIBXML_THREAD_ENABLED
|
||||
XML_HIDDEN unsigned *
|
||||
xmlGetLocalRngState(void);
|
||||
#endif
|
||||
|
||||
#endif /* XML_GLOBALS_H_PRIVATE__ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user