From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 1FDDC3B5 for ; Fri, 28 Apr 2017 12:18:20 +0200 (CEST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP; 28 Apr 2017 03:18:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,387,1488873600"; d="scan'208";a="93233672" Received: from sivswdev01.ir.intel.com ([10.237.217.45]) by orsmga005.jf.intel.com with ESMTP; 28 Apr 2017 03:18:18 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson Date: Fri, 28 Apr 2017 11:18:15 +0100 Message-Id: <20170428101815.24090-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.8.4 Subject: [dpdk-dev] [PATCH] examples/performance-thread: fix compilation on FreeBSD 10.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Apr 2017 10:18:21 -0000 While later releases in the FreeBSD 10 series have a CPU_COUNT macro defined, FreeBSD 10.0 and 10.1 do not have this macro. Therefore we provide a basic fallback implementation of the macro for platforms where it is not defined. Fixes: 433ba6228f9a ("examples/performance-thread: add pthread_shim app") Signed-off-by: Bruce Richardson --- examples/performance-thread/pthread_shim/pthread_shim.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/examples/performance-thread/pthread_shim/pthread_shim.c b/examples/performance-thread/pthread_shim/pthread_shim.c index 7167311..113bafa 100644 --- a/examples/performance-thread/pthread_shim/pthread_shim.c +++ b/examples/performance-thread/pthread_shim/pthread_shim.c @@ -48,6 +48,21 @@ #define POSIX_ERRNO(x) (x) +/* some releases of FreeBSD 10, e.g. 10.0, don't have CPU_COUNT macro */ +#ifndef CPU_COUNT +#define CPU_COUNT(x) __cpu_count(x) + +static inline unsigned int +__cpu_count(const rte_cpuset_t *cpuset) +{ + unsigned int i, count = 0; + for (i = 0; i < RTE_MAX_LCORE; i++) + if (CPU_ISSET(i, cpuset)) + count++; + return count; +} +#endif + /* * this flag determines at run time if we override pthread * calls and map then to equivalent lthread calls -- 2.9.3