From 9aab4125498301f37c769e761cdababdab196b63 Mon Sep 17 00:00:00 2001 From: Ivan Zhakov Date: Wed, 29 Jun 2022 14:46:01 +0000 Subject: On 'thread-name' branch: Check pthread_setname_np()/pthread_getname_np() support. * threadproc/unix/thread.c (apr_thread_name_set, apr_thread_name_get): Return APR_ENOTIMPL if not HAVE_PTHREAD_SETNAME_NP. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/thread-name@1902352 13f79535-47bb-0310-9956-ffa450edef68 --- threadproc/unix/thread.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/threadproc/unix/thread.c b/threadproc/unix/thread.c index e88592201..01d241751 100644 --- a/threadproc/unix/thread.c +++ b/threadproc/unix/thread.c @@ -286,6 +286,7 @@ APR_DECLARE(apr_status_t) apr_thread_name_set(const char *name, apr_thread_t *thread, apr_pool_t *pool) { +#if HAVE_PTHREAD_SETNAME_NP pthread_t td; size_t name_len; @@ -306,12 +307,16 @@ APR_DECLARE(apr_status_t) apr_thread_name_set(const char *name, } return pthread_setname_np(td, name); +#else + return APR_ENOTIMPL; +#endif } APR_DECLARE(apr_status_t) apr_thread_name_get(char **name, apr_thread_t *thread, apr_pool_t *pool) { +#if HAVE_PTHREAD_SETNAME_NP pthread_t td; if (thread) { td = *thread->td; @@ -322,6 +327,9 @@ APR_DECLARE(apr_status_t) apr_thread_name_get(char **name, *name = apr_pcalloc(pool, TASK_COMM_LEN); return pthread_getname_np(td, *name, TASK_COMM_LEN); +#else + return APR_ENOTIMPL; +#endif } APR_DECLARE(apr_os_thread_t) apr_os_thread_current(void) -- cgit v1.2.1