67 lines
2.1 KiB
Diff
67 lines
2.1 KiB
Diff
--- a/src/main/cpp/loggingevent.cpp
|
|
+++ b/src/main/cpp/loggingevent.cpp
|
|
@@ -339,12 +339,12 @@
|
|
|
|
const LogString& LoggingEvent::getCurrentThreadName()
|
|
{
|
|
-#if defined(_WIN32)
|
|
- using ThreadIdType = DWORD;
|
|
- ThreadIdType threadId = GetCurrentThreadId();
|
|
-#elif LOG4CXX_HAS_PTHREAD_SELF
|
|
+#ifdef LOG4CXX_HAS_PTHREAD_SELF
|
|
using ThreadIdType = pthread_t;
|
|
ThreadIdType threadId = pthread_self();
|
|
+#elif defined(_WIN32)
|
|
+ using ThreadIdType = DWORD;
|
|
+ ThreadIdType threadId = GetCurrentThreadId();
|
|
#else
|
|
using ThreadIdType = int;
|
|
ThreadIdType threadId = 0;
|
|
@@ -368,16 +368,16 @@
|
|
return thread_id_string;
|
|
}
|
|
|
|
-#if defined(_WIN32)
|
|
- char result[20];
|
|
- apr_snprintf(result, sizeof(result), LOG4CXX_WIN32_THREAD_FMTSPEC, threadId);
|
|
- thread_id_string = Transcoder::decode(result);
|
|
-#elif LOG4CXX_HAS_PTHREAD_SELF
|
|
+#ifdef LOG4CXX_HAS_PTHREAD_SELF
|
|
// pthread_t encoded in HEX takes needs as many characters
|
|
// as two times the size of the type, plus an additional null byte.
|
|
char result[sizeof(pthread_t) * 3 + 10];
|
|
apr_snprintf(result, sizeof(result), LOG4CXX_APR_THREAD_FMTSPEC, (void*) &threadId);
|
|
thread_id_string = Transcoder::decode(result);
|
|
+#elif defined(_WIN32)
|
|
+ char result[20];
|
|
+ apr_snprintf(result, sizeof(result), LOG4CXX_WIN32_THREAD_FMTSPEC, threadId);
|
|
+ thread_id_string = Transcoder::decode(result);
|
|
#else
|
|
thread_id_string = LOG4CXX_STR("0x00000000");
|
|
#endif
|
|
--- a/src/main/include/CMakeLists.txt
|
|
+++ b/src/main/include/CMakeLists.txt
|
|
@@ -140,9 +140,11 @@
|
|
CHECK_SYMBOL_EXISTS(wcstombs "cstdlib" HAS_WCSTOMBS)
|
|
CHECK_SYMBOL_EXISTS(fwide "cwchar" HAS_FWIDE )
|
|
CHECK_SYMBOL_EXISTS(syslog "syslog.h" HAS_SYSLOG)
|
|
-if(UNIX)
|
|
+if(UNIX OR MINGW)
|
|
set(CMAKE_REQUIRED_LIBRARIES "pthread")
|
|
- CHECK_SYMBOL_EXISTS(pthread_sigmask "signal.h" HAS_PTHREAD_SIGMASK)
|
|
+ if(UNIX)
|
|
+ CHECK_SYMBOL_EXISTS(pthread_sigmask "signal.h" HAS_PTHREAD_SIGMASK)
|
|
+ endif()
|
|
CHECK_SYMBOL_EXISTS(pthread_self "pthread.h" HAS_PTHREAD_SELF)
|
|
|
|
# Check for the (linux) pthread_setname_np.
|
|
@@ -157,7 +159,7 @@
|
|
if(${PTHREAD_GETNAME_NP_FOUND})
|
|
set(HAS_PTHREAD_GETNAME 1)
|
|
endif()
|
|
-endif(UNIX)
|
|
+endif()
|
|
|
|
foreach(varName
|
|
HAS_THREAD_LOCAL
|