summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeevan Ramakant Nagvekar <jeevan.nagvekar1@wipro.com>2018-07-23 15:28:45 +0530
committerSaya Sugiura <ssugiura@jp.adit-jv.com>2021-09-14 11:32:24 +0900
commita81db84e3321a0a561260ec74163b21b75043069 (patch)
tree7710f63e2f43d7c72572ece2b90e16fa156b24c9
parent4a82545662d7d9d9b54be7393c382a4d1759daef (diff)
downloadDLT-daemon-devel_pthread_setname_np.tar.gz
Replace prctl with pthread_setname_np to set thread namedevel_pthread_setname_np
This commit replaces pcrtl call with pthread_setname_np Summary of changes: 1. CHECK_LIBRARY_EXISTS and CHECK_FUNCTION_EXISTS are used to determine if pthread_setname_np is available on platform. Thus, availability of pthread_setname_np is checked automatically without knowing the platform for which compilation is taking place. 2. Variable HAVE_FUNC_PTHREAD_SETNAME_NP is set if the API pthread_setname_np is found. If this variable is set, then "DLT_USE_PTHREAD_SETNAME_NP" compiler flag is set. Then pthread_setname_np API is used to set thread name else thread name is not set. Signed-off-by: Jeevan Ramakant Nagvekar <jeevan.nagvekar1@wipro.com> Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
-rw-r--r--cmake/CMakeLists.txt6
-rw-r--r--src/lib/dlt_user.c8
2 files changed, 12 insertions, 2 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 46b67e4..87d7579 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -90,6 +90,12 @@ else()
CHECK_FUNCTION_EXISTS( mq_receive HAVE_FUNC_MQRECEIVE)
endif()
+if( CMAKE_THREAD_LIBS_INIT )
+ CHECK_LIBRARY_EXISTS( ${CMAKE_THREAD_LIBS_INIT} pthread_setname_np pthread.h HAVE_FUNC_PTHREAD_SETNAME_NP )
+else( CMAKE_THREAD_LIBS_INIT )
+ CHECK_FUNCTION_EXISTS( pthread_setname_np HAVE_FUNC_PTHREAD_SETNAME_NP )
+endif( CMAKE_THREAD_LIBS_INIT )
+
if(WITH_CHECK_CONFIG_FILE)
configure_file(${PROJECT_SOURCE_DIR}/cmake/config.h.cmake ${PROJECT_BINARY_DIR}/include/dlt/config.h)
endif(WITH_CHECK_CONFIG_FILE)
diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c
index e3565af..6bc1aaa 100644
--- a/src/lib/dlt_user.c
+++ b/src/lib/dlt_user.c
@@ -2949,7 +2949,9 @@ void dlt_user_trace_network_segmented_thread(void *unused)
{
/* Unused on purpose. */
(void)unused;
-#ifdef linux
+#ifdef DLT_USE_PTHREAD_SETNAME_NP
+ pthread_setname_np(dlt_user.dlt_segmented_nwt_handle, "dlt_segmented");
+#elif linux
prctl(PR_SET_NAME, "dlt_segmented", 0, 0, 0);
#endif
pthread_cleanup_push(dlt_user_cleanup_handler, NULL);
@@ -3542,7 +3544,9 @@ void dlt_user_housekeeperthread_function(__attribute__((unused)) void *ptr)
}
#endif
-#ifdef linux
+#ifdef DLT_USE_PTHREAD_SETNAME_NP
+ pthread_setname_np(dlt_housekeeperthread_handle, "dlt_housekeeper");
+#elif linux
prctl(PR_SET_NAME, "dlt_housekeeper", 0, 0, 0);
#endif