DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] eal: fix compile error for old glibc caused by CLOCK_MONOTONIC_RAW
Date: Thu, 19 Nov 2015 11:23:42 +0000	[thread overview]
Message-ID: <1447932222-17018-1-git-send-email-ferruh.yigit@intel.com> (raw)
In-Reply-To: <103431910.iACTIb73WP@xps13>

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 <ferruh.yigit@intel.com>
---
 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

  parent reply	other threads:[~2015-11-19 11:23 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-18 13:32 [dpdk-dev] Compile errors with libc < 2.12 Ferruh Yigit
2015-11-18 14:24 ` Thomas Monjalon
2015-11-19 11:22   ` [dpdk-dev] [PATCH] Revert "eal: set name to threads" Ferruh Yigit
2015-11-19 11:49     ` Panu Matilainen
2015-11-19 12:32       ` Thomas Monjalon
2015-11-19 13:39         ` Ferruh Yigit
2015-11-19 16:59           ` Ferruh Yigit
2015-11-19 17:44             ` [dpdk-dev] [PATCH] eal: fix compile error for old glibc caused by pthread_setname_np() Ferruh Yigit
2015-11-20 12:21               ` [dpdk-dev] [PATCH] eal: fix compile error for old glibc caused by pthread_setname_np()# Bruce Richardson
2015-11-24 14:26                 ` Ferruh Yigit
2015-11-24 17:54               ` [dpdk-dev] [PATCH] eal: fix compile error for old glibc caused by pthread_setname_np() Thomas Monjalon
2015-11-24 18:47                 ` Ferruh Yigit
2015-11-25 11:13                   ` [dpdk-dev] [PATCH v2] " Ferruh Yigit
2015-11-25 11:18                     ` Thomas Monjalon
2015-11-25 11:24                       ` Ferruh Yigit
2015-11-25 11:30                         ` Thomas Monjalon
2015-11-25 13:41                     ` Thomas Monjalon
2015-11-25 13:51                     ` Roger B. Melton
2015-11-25 14:03                       ` Thomas Monjalon
2015-11-25 14:20                         ` Roger B. Melton
2015-11-19 11:23   ` Ferruh Yigit [this message]
2015-11-20 17:02     ` [dpdk-dev] [PATCH] eal: fix compile error for old glibc caused by CLOCK_MONOTONIC_RAW Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1447932222-17018-1-git-send-email-ferruh.yigit@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).