From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id AF8545A6C for ; Thu, 19 Nov 2015 12:23:49 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 19 Nov 2015 03:23:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,317,1444719600"; d="scan'208";a="854509059" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 19 Nov 2015 03:23:47 -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 tAJBNku4006174; Thu, 19 Nov 2015 11:23:47 GMT Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id tAJBNkGS017055; Thu, 19 Nov 2015 11:23:46 GMT Received: (from fyigit@localhost) by sivswdev02.ir.intel.com with id tAJBNkeT017051; Thu, 19 Nov 2015 11:23:46 GMT From: Ferruh Yigit To: dev@dpdk.org Date: Thu, 19 Nov 2015 11:23:42 +0000 Message-Id: <1447932222-17018-1-git-send-email-ferruh.yigit@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <103431910.iACTIb73WP@xps13> References: <103431910.iACTIb73WP@xps13> Subject: [dpdk-dev] [PATCH] eal: fix compile error for old glibc caused by CLOCK_MONOTONIC_RAW 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 11:23:50 -0000 Fixes: d08d304508a8 ("eal/linux: make alarm not affected by system time jump") CLOCK_MONOTONIC_RAW added in glibc 2.12, using this define in older glibc versions cause compile error: 'error: identifier "CLOCK_MONOTONIC_RAW" is undefined' This patch replaces "CLOCK_MONOTONIC_RAW" with "CLOCK_MONOTONIC" for older glibc versions, versions that support "CLOCK_MONOTONIC_RAW" will keep using this clock type. Signed-off-by: Ferruh Yigit --- lib/librte_eal/linuxapp/eal/eal_alarm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_alarm.c b/lib/librte_eal/linuxapp/eal/eal_alarm.c index ff57323..8b042ab 100644 --- a/lib/librte_eal/linuxapp/eal/eal_alarm.c +++ b/lib/librte_eal/linuxapp/eal/eal_alarm.c @@ -63,6 +63,12 @@ #define MS_PER_S 1000 #define US_PER_S (US_PER_MS * MS_PER_S) +#ifdef CLOCK_MONOTONIC_RAW /* Defined in glibc bits/time.h */ +#define CLOCK_TYPE_ID CLOCK_MONOTONIC_RAW +#else +#define CLOCK_TYPE_ID CLOCK_MONOTONIC +#endif + struct alarm_entry { LIST_ENTRY(alarm_entry) next; struct timeval time; @@ -104,7 +110,7 @@ eal_alarm_callback(struct rte_intr_handle *hdl __rte_unused, rte_spinlock_lock(&alarm_list_lk); while ((ap = LIST_FIRST(&alarm_list)) !=NULL && - clock_gettime(CLOCK_MONOTONIC_RAW, &now) == 0 && + clock_gettime(CLOCK_TYPE_ID, &now) == 0 && (ap->time.tv_sec < now.tv_sec || (ap->time.tv_sec == now.tv_sec && (ap->time.tv_usec * NS_PER_US) <= now.tv_nsec))) { ap->executing = 1; @@ -152,7 +158,7 @@ rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback cb_fn, void *cb_arg) return -ENOMEM; /* use current time to calculate absolute time of alarm */ - clock_gettime(CLOCK_MONOTONIC_RAW, &now); + clock_gettime(CLOCK_TYPE_ID, &now); new_alarm->cb_fn = cb_fn; new_alarm->cb_arg = cb_arg; -- 2.5.0