You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rm...@apache.org on 2021/08/20 01:29:01 UTC
[logging-log4cxx] branch LOGCXX-431 updated: Check for
linux-specific pthread_setname_np
This is an automated email from the ASF dual-hosted git repository.
rmiddleton pushed a commit to branch LOGCXX-431
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
The following commit(s) were added to refs/heads/LOGCXX-431 by this push:
new 36e33e5 Check for linux-specific pthread_setname_np
36e33e5 is described below
commit 36e33e5ffdf44057f5cdb7cb3414c463635c2671
Author: Robert Middleton <ro...@rm5248.com>
AuthorDate: Thu Aug 19 21:28:47 2021 -0400
Check for linux-specific pthread_setname_np
---
src/cmake/pthread/log4cxx-pthread.cmake | 5 +++++
src/cmake/pthread/test-pthread.cpp | 6 ++++++
src/main/include/CMakeLists.txt | 10 ++++++++--
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/cmake/pthread/log4cxx-pthread.cmake b/src/cmake/pthread/log4cxx-pthread.cmake
new file mode 100644
index 0000000..aa3647b
--- /dev/null
+++ b/src/cmake/pthread/log4cxx-pthread.cmake
@@ -0,0 +1,5 @@
+include(FindThreads)
+
+try_compile(PTHREAD_SETNAME_NP_FOUND "${CMAKE_BINARY_DIR}/pthread-compile-tests"
+ "${CMAKE_CURRENT_LIST_DIR}/test-pthread.cpp")
+
diff --git a/src/cmake/pthread/test-pthread.cpp b/src/cmake/pthread/test-pthread.cpp
new file mode 100644
index 0000000..f30cd1a
--- /dev/null
+++ b/src/cmake/pthread/test-pthread.cpp
@@ -0,0 +1,6 @@
+#include <pthread.h>
+
+int main(){
+ pthread_t tid;
+ pthread_set_name_np(tid, "name");
+}
diff --git a/src/main/include/CMakeLists.txt b/src/main/include/CMakeLists.txt
index 575f68b..558eaeb 100644
--- a/src/main/include/CMakeLists.txt
+++ b/src/main/include/CMakeLists.txt
@@ -88,8 +88,14 @@ CHECK_FUNCTION_EXISTS(syslog HAS_SYSLOG)
if(UNIX)
set(CMAKE_REQUIRED_LIBRARIES "pthread")
CHECK_SYMBOL_EXISTS(pthread_sigmask "signal.h" HAS_PTHREAD_SIGMASK)
- set(CMAKE_REQUIRED_LIBRARIES "pthread")
- CHECK_SYMBOL_EXISTS(pthread_setname_np "pthread.h" HAS_PTHREAD_SETNAME)
+
+ # Check for the (linux) pthread_setname_np.
+ # OSX and BSD are special apparently. OSX only lets you name
+ # the current thread, while BSD calls it pthread_set_name_np.
+ # Since this is really not a core feature and the end-user can configure
+ # it anyway, we're only going to worry about linux.
+ include(${LOG4CXX_SOURCE_DIR}/src/cmake/pthread/log4cxx-pthread.cmake)
+ set(HAS_PTHREAD_SETNAME ${PTHREAD_SETNAME_NP_FOUND})
endif(UNIX)
if(WIN32)