From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id E46275A6C for ; Thu, 19 Nov 2015 18:44:34 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 19 Nov 2015 09:44:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,318,1444719600"; d="scan'208";a="689673498" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga003.jf.intel.com with ESMTP; 19 Nov 2015 09:44:32 -0800 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id tAJHiVCa004962; Thu, 19 Nov 2015 17:44:31 GMT Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id tAJHiSNA017176; Thu, 19 Nov 2015 17:44:28 GMT Received: (from fyigit@localhost) by sivswdev02.ir.intel.com with id tAJHiSxd017171; Thu, 19 Nov 2015 17:44:28 GMT From: Ferruh Yigit To: dev@dpdk.org Date: Thu, 19 Nov 2015 17:44:26 +0000 Message-Id: <1447955066-17131-1-git-send-email-ferruh.yigit@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <20151119165935.GA4888@sivlogin002.ir.intel.com> References: <20151119165935.GA4888@sivlogin002.ir.intel.com> Subject: [dpdk-dev] [PATCH] eal: fix compile error for old glibc caused by pthread_setname_np() X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2015 17:44:35 -0000 Fixes: 67b6d3039e9e ("eal: set name to threads") pthread_setname_np() function added in glibc 2.12, using this function in older glibc versions cause compile error: error: implicit declaration of function "pthread_setname_np" This patch adds "rte_thread_setname" macro and set it according glibc >= 2.12 check, thread naming disabled for older glibc versions, glibc versions that support "pthread_setname_np" will keep using this function. Signed-off-by: Ferruh Yigit --- examples/tep_termination/main.c | 2 +- examples/vhost/main.c | 2 +- examples/vhost_xen/main.c | 2 +- lib/librte_eal/common/eal_thread.h | 6 ++++++ lib/librte_eal/linuxapp/eal/eal.c | 2 +- lib/librte_eal/linuxapp/eal/eal_interrupts.c | 2 +- lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c | 2 +- lib/librte_eal/linuxapp/eal/eal_timer.c | 2 +- 8 files changed, 13 insertions(+), 7 deletions(-) diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c index 2b67e64..f97d552 100644 --- a/examples/tep_termination/main.c +++ b/examples/tep_termination/main.c @@ -1249,7 +1249,7 @@ main(int argc, char *argv[]) if (ret != 0) rte_exit(EXIT_FAILURE, "Cannot create print-stats thread\n"); snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, "print-stats"); - ret = pthread_setname_np(tid, thread_name); + ret = rte_thread_setname(tid, thread_name); if (ret != 0) RTE_LOG(ERR, VHOST_CONFIG, "Cannot set print-stats name\n"); } diff --git a/examples/vhost/main.c b/examples/vhost/main.c index c081b18..9bfda6d 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -3027,7 +3027,7 @@ main(int argc, char *argv[]) /* Set thread_name for aid in debugging. */ snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, "print-stats"); - ret = pthread_setname_np(tid, thread_name); + ret = rte_thread_setname(tid, thread_name); if (ret != 0) RTE_LOG(ERR, VHOST_CONFIG, "Cannot set print-stats name\n"); diff --git a/examples/vhost_xen/main.c b/examples/vhost_xen/main.c index 3fcc138..ca725f2 100644 --- a/examples/vhost_xen/main.c +++ b/examples/vhost_xen/main.c @@ -1510,7 +1510,7 @@ main(int argc, char *argv[]) /* Set thread_name for aid in debugging. */ snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, "print-xen-stats"); - ret = pthread_setname_np(tid, thread_name); + ret = rte_thread_setname(tid, thread_name); if (ret != 0) RTE_LOG(ERR, VHOST_CONFIG, "Cannot set print-stats name\n"); diff --git a/lib/librte_eal/common/eal_thread.h b/lib/librte_eal/common/eal_thread.h index e4e76b9..58e410d 100644 --- a/lib/librte_eal/common/eal_thread.h +++ b/lib/librte_eal/common/eal_thread.h @@ -36,6 +36,12 @@ #include +#if __GLIBC_PREREQ(2, 12) +#define rte_thread_setname(...) pthread_setname_np(__VA_ARGS__) +#else +#define rte_thread_setname(...) 0 +#endif + /** * basic loop of thread, called for each thread by eal_init(). * diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index 06536f2..635ec36 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -859,7 +859,7 @@ rte_eal_init(int argc, char **argv) /* Set thread_name for aid in debugging. */ snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, "lcore-slave-%d", i); - ret = pthread_setname_np(lcore_config[i].thread_id, + ret = rte_thread_setname(lcore_config[i].thread_id, thread_name); if (ret != 0) RTE_LOG(ERR, EAL, diff --git a/lib/librte_eal/linuxapp/eal/eal_interrupts.c b/lib/librte_eal/linuxapp/eal/eal_interrupts.c index 95beb4c..470d6a1 100644 --- a/lib/librte_eal/linuxapp/eal/eal_interrupts.c +++ b/lib/librte_eal/linuxapp/eal/eal_interrupts.c @@ -887,7 +887,7 @@ rte_eal_intr_init(void) /* Set thread_name for aid in debugging. */ snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, "eal-intr-thread"); - ret_1 = pthread_setname_np(intr_thread, thread_name); + ret_1 = rte_thread_setname(intr_thread, thread_name); if (ret_1 != 0) RTE_LOG(ERR, EAL, "Failed to set thread name for interrupt handling\n"); diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c index 277565d..d9188fd 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio_mp_sync.c @@ -394,7 +394,7 @@ pci_vfio_mp_sync_setup(void) /* Set thread_name for aid in debugging. */ snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, "pci-vfio-sync"); - ret = pthread_setname_np(socket_thread, thread_name); + ret = rte_thread_setname(socket_thread, thread_name); if (ret) RTE_LOG(ERR, EAL, "Failed to set thread name for secondary processes!\n"); diff --git a/lib/librte_eal/linuxapp/eal/eal_timer.c b/lib/librte_eal/linuxapp/eal/eal_timer.c index e0642de..9ceff33 100644 --- a/lib/librte_eal/linuxapp/eal/eal_timer.c +++ b/lib/librte_eal/linuxapp/eal/eal_timer.c @@ -219,7 +219,7 @@ rte_eal_hpet_init(int make_default) * Set thread_name for aid in debugging. */ snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, "hpet-msb-inc"); - ret = pthread_setname_np(msb_inc_thread_id, thread_name); + ret = rte_thread_setname(msb_inc_thread_id, thread_name); if (ret != 0) RTE_LOG(ERR, EAL, "ERROR: Cannot set HPET timer thread name!\n"); -- 2.5.0