Skip to content

Commit

Permalink
fix global symbols export for 15-ABI compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
vopl committed Oct 29, 2023
1 parent 20f4433 commit 986274c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions src/main/cpp/aprinitializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -72,14 +82,15 @@ struct apr_environment

}


APRInitializer::APRInitializer() :
m_priv(std::make_unique<APRInitializerPrivate>())
{
apr_pool_create(&m_priv->p, NULL);
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
Expand Down
7 changes: 6 additions & 1 deletion src/main/cpp/asyncappender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -87,7 +90,9 @@ class DiscardSummary

typedef std::map<LogString, DiscardSummary> DiscardMap;

#if !LOG4CXX_ABI_15_COMPATIBILITY
}
#endif

struct AsyncAppender::AsyncAppenderPriv : public AppenderSkeleton::AppenderSkeletonPrivate
{
Expand Down
13 changes: 11 additions & 2 deletions src/main/cpp/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
}
Expand Down

0 comments on commit 986274c

Please sign in to comment.