diff --git a/src/main/cpp/CMakeLists.txt b/src/main/cpp/CMakeLists.txt index 2c2e7794b..4e2b238f5 100644 --- a/src/main/cpp/CMakeLists.txt +++ b/src/main/cpp/CMakeLists.txt @@ -17,6 +17,7 @@ # Options option(LOG4CXX_ABI_CHECK "Check for ABI changes" OFF) +option(LOG4CXX_ABI_15_COMPATIBILITY "Compatibility for legacy 15 ABI, with some global symbols" ON) # Build the log4cxx library add_library(log4cxx) @@ -53,6 +54,9 @@ if(LOG4CXX_MULTIPROCESS_ROLLING_FILE_APPENDER) multiprocessrollingfileappender.cpp ) endif() +if(LOG4CXX_ABI_15_COMPATIBILITY) + target_compile_definitions(log4cxx PRIVATE LOG4CXX_ABI_15_COMPATIBILITY) +endif() if(${ENABLE_FMT_LAYOUT}) list(APPEND extra_classes diff --git a/src/main/cpp/aprinitializer.cpp b/src/main/cpp/aprinitializer.cpp index e7d3146c9..b27e55af6 100644 --- a/src/main/cpp/aprinitializer.cpp +++ b/src/main/cpp/aprinitializer.cpp @@ -52,11 +52,21 @@ struct APRInitializer::APRInitializerPrivate{ namespace { -void tlsDestruct(void* ptr) +void tlsDestructImpl(void* ptr) { delete ((ThreadSpecificData*) ptr); } +} + +#if LOG4CXX_ABI_15_COMPATIBILITY +extern "C" void tlsDestruct(void* ptr) +{ + return tlsDestructImpl(ptr); +} +#endif +namespace +{ // The first object created and the last object destroyed struct apr_environment { @@ -72,6 +82,7 @@ struct apr_environment } + APRInitializer::APRInitializer() : m_priv(std::make_unique()) { @@ -79,7 +90,7 @@ APRInitializer::APRInitializer() : apr_atomic_init(m_priv->p); m_priv->startTime = Date::currentTime(); #if APR_HAS_THREADS - apr_status_t stat = apr_threadkey_private_create(&m_priv->tlsKey, tlsDestruct, m_priv->p); + apr_status_t stat = apr_threadkey_private_create(&m_priv->tlsKey, tlsDestructImpl, m_priv->p); assert(stat == APR_SUCCESS); assert(stat == APR_SUCCESS); #endif diff --git a/src/main/cpp/asyncappender.cpp b/src/main/cpp/asyncappender.cpp index 0f3cdfba9..6be448963 100644 --- a/src/main/cpp/asyncappender.cpp +++ b/src/main/cpp/asyncappender.cpp @@ -34,7 +34,10 @@ using namespace LOG4CXX_NS; using namespace LOG4CXX_NS::helpers; using namespace LOG4CXX_NS::spi; -namespace { +#if !LOG4CXX_ABI_15_COMPATIBILITY +namespace +{ +#endif /** * The default buffer size is set to 128 events. @@ -87,7 +90,9 @@ class DiscardSummary typedef std::map DiscardMap; +#if !LOG4CXX_ABI_15_COMPATIBILITY } +#endif struct AsyncAppender::AsyncAppenderPriv : public AppenderSkeleton::AppenderSkeletonPrivate { diff --git a/src/main/cpp/class.cpp b/src/main/cpp/class.cpp index 0e2d9028c..18a5c4b28 100644 --- a/src/main/cpp/class.cpp +++ b/src/main/cpp/class.cpp @@ -75,13 +75,22 @@ using namespace LOG4CXX_NS::filter; using namespace LOG4CXX_NS::xml; using namespace LOG4CXX_NS::rolling; -namespace LOG4CXX_NS { -uint32_t libraryVersion(){ +namespace LOG4CXX_NS +{ +uint32_t libraryVersion() +{ // This function defined in log4cxx.h return LOG4CXX_VERSION; } } +#if LOG4CXX_ABI_15_COMPATIBILITY +LOG4CXX_EXPORT uint32_t libraryVersion() +{ + return LOG4CXX_NS::libraryVersion(); +} +#endif + Class::Class() { }