diff --git a/ChangeLog b/ChangeLog index 58618d55..86265f98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Oct 15 14:30:11 CEST 2001 Daniel Veillard + + * include/libxml/globals.h configure.in global.data: make + the allocation be per-thread a configure option + * encoding.c include/libxml/parser.h: fixed compilation + errors + Mon Oct 15 12:45:03 CEST 2001 Daniel Veillard * include/libxml/parser.h: Norm reported that a few lines diff --git a/configure.in b/configure.in index 9f50db73..45145ef9 100644 --- a/configure.in +++ b/configure.in @@ -249,6 +249,7 @@ dnl THREAD_LIBS="" WITH_THREADS=0 THREAD_CFLAGS="" + AC_ARG_WITH(threads, [ --with-threads Add multithread support(off)]) if test "$with_threads" = "yes" ; then echo Enabling multithreaded support @@ -264,6 +265,11 @@ if test "$with_threads" = "yes" ; then THREAD_CFLAGS="$XML_CFLAGS -D_REENTRANT" fi fi +AC_ARG_WITH(thread-alloc, [ --with-thread-alloc Add per-thread memory(off)]) +if test "$with_threads" = "yes" -a "$WITH_THREADS" = "1" ; then + THREAD_CFLAGS="$XML_CFLAGS -DLIBXML_THREAD_ALLOC_ENABLED" +fi + AC_SUBST(THREAD_LIBS) AC_SUBST(WITH_THREADS) AC_SUBST(THREAD_CFLAGS) diff --git a/encoding.c b/encoding.c index 781d8dab..a9495c42 100644 --- a/encoding.c +++ b/encoding.c @@ -44,6 +44,7 @@ #include #endif #include +#include static xmlCharEncodingHandlerPtr xmlUTF16LEHandler = NULL; static xmlCharEncodingHandlerPtr xmlUTF16BEHandler = NULL; diff --git a/global.data b/global.data index 45c3b31e..2a6a4455 100644 --- a/global.data +++ b/global.data @@ -6,7 +6,6 @@ int,xmlDefaultBufferSize xmlSAXHandler,xmlDefaultSAXHandler xmlSAXLocator,xmlDefaultSAXLocator int,xmlDoValidityCheckingDefaultValue -xmlFreeFunc,xmlFree xmlGenericErrorFunc,xmlGenericError void *,xmlGenericErrorContext int,xmlGetWarningsDefaultValue @@ -14,14 +13,11 @@ int,xmlIndentTreeOutput int,xmlKeepBlanksDefaultValue int,xmlLineNumbersDefaultValue int,xmlLoadExtDtdDefaultValue -xmlMallocFunc,xmlMalloc -xmlStrdupFunc,xmlMemStrdup int,xmlParserDebugEntities const char *,xmlParserVersion int,xmlPedanticParserDefaultValue -xmlReallocFunc,xmlRealloc int,xmlSaveNoEmptyTags #const xmlChar,xmlStringComment,[] #const xmlChar,xmlStringText,[] #const xmlChar,xmlStringTextNoenc,[] -int,xmlSubstituteEntitiesDefaultValue \ No newline at end of file +int,xmlSubstituteEntitiesDefaultValue diff --git a/include/libxml/globals.h b/include/libxml/globals.h index 499fa580..f1e46a9f 100644 --- a/include/libxml/globals.h +++ b/include/libxml/globals.h @@ -90,6 +90,54 @@ struct _xmlGlobalState void xmlInitializeGlobalState(xmlGlobalStatePtr gs); +/* + * In general the memory allocation entry points are not kept + * thread specific but this can be overriden by LIBXML_THREAD_ALLOC_ENABLED + * - xmlMalloc + * - xmlRealloc + * - xmlMemStrdup + * - xmlFree + */ + +#ifdef LIBXML_THREAD_ALLOC_ENABLED +#ifdef LIBXML_THREAD_ENABLED +extern xmlMallocFunc *__xmlMalloc(void); +#define xmlMalloc \ +(*(__xmlMalloc())) +#else +LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMalloc; +#endif + +#ifdef LIBXML_THREAD_ENABLED +extern xmlReallocFunc *__xmlRealloc(void); +#define xmlRealloc \ +(*(__xmlRealloc())) +#else +LIBXML_DLL_IMPORT extern xmlReallocFunc xmlRealloc; +#endif + +#ifdef LIBXML_THREAD_ENABLED +extern xmlFreeFunc *__xmlFree(void); +#define xmlFree \ +(*(__xmlFree())) +#else +LIBXML_DLL_IMPORT extern xmlFreeFunc xmlFree; +#endif + +#ifdef LIBXML_THREAD_ENABLED +extern xmlStrdupFunc *__xmlMemStrdup(void); +#define xmlMemStrdup \ +(*(__xmlMemStrdup())) +#else +LIBXML_DLL_IMPORT extern xmlStrdupFunc xmlMemStrdup; +#endif +#else /* !LIBXML_THREAD_ALLOC_ENABLED */ +LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMalloc; +LIBXML_DLL_IMPORT extern xmlReallocFunc xmlRealloc; +LIBXML_DLL_IMPORT extern xmlFreeFunc xmlFree; +LIBXML_DLL_IMPORT extern xmlStrdupFunc xmlMemStrdup; +#endif /* LIBXML_THREAD_ALLOC_ENABLED */ + /* * Everything starting from the line below is * Automatically generated by build_glob.py. @@ -161,14 +209,6 @@ extern int *__xmlDoValidityCheckingDefaultValue(void); LIBXML_DLL_IMPORT extern int xmlDoValidityCheckingDefaultValue; #endif -#ifdef LIBXML_THREAD_ENABLED -extern xmlFreeFunc *__xmlFree(void); -#define xmlFree \ -(*(__xmlFree())) -#else -LIBXML_DLL_IMPORT extern xmlFreeFunc xmlFree; -#endif - #ifdef LIBXML_THREAD_ENABLED extern xmlGenericErrorFunc *__xmlGenericError(void); #define xmlGenericError \ @@ -225,22 +265,6 @@ extern int *__xmlLoadExtDtdDefaultValue(void); LIBXML_DLL_IMPORT extern int xmlLoadExtDtdDefaultValue; #endif -#ifdef LIBXML_THREAD_ENABLED -extern xmlMallocFunc *__xmlMalloc(void); -#define xmlMalloc \ -(*(__xmlMalloc())) -#else -LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMalloc; -#endif - -#ifdef LIBXML_THREAD_ENABLED -extern xmlStrdupFunc *__xmlMemStrdup(void); -#define xmlMemStrdup \ -(*(__xmlMemStrdup())) -#else -LIBXML_DLL_IMPORT extern xmlStrdupFunc xmlMemStrdup; -#endif - #ifdef LIBXML_THREAD_ENABLED extern int *__xmlParserDebugEntities(void); #define xmlParserDebugEntities \ @@ -265,14 +289,6 @@ extern int *__xmlPedanticParserDefaultValue(void); LIBXML_DLL_IMPORT extern int xmlPedanticParserDefaultValue; #endif -#ifdef LIBXML_THREAD_ENABLED -extern xmlReallocFunc *__xmlRealloc(void); -#define xmlRealloc \ -(*(__xmlRealloc())) -#else -LIBXML_DLL_IMPORT extern xmlReallocFunc xmlRealloc; -#endif - #ifdef LIBXML_THREAD_ENABLED extern int *__xmlSaveNoEmptyTags(void); #define xmlSaveNoEmptyTags \ diff --git a/include/libxml/parser.h b/include/libxml/parser.h index a3ab9566..21244da7 100644 --- a/include/libxml/parser.h +++ b/include/libxml/parser.h @@ -13,9 +13,6 @@ #include #include #include -#if defined(_REENTRANT) || (_POSIX_C_SOURCE - 0 >= 199506L) -#include -#endif #ifdef __cplusplus extern "C" { @@ -579,5 +576,7 @@ xmlParserInputPtr } #endif +#include + #endif /* __XML_PARSER_H__ */