From f0ceeaca2333c04ef102e85896d891255575ae3c Mon Sep 17 00:00:00 2001 From: compudj Date: Tue, 23 May 2006 19:42:05 +0000 Subject: [PATCH] fix compare git-svn-id: http://ltt.polymtl.ca/svn@1835 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/ltt/time.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ltt/branches/poly/ltt/time.h b/ltt/branches/poly/ltt/time.h index 14c15d1d..00e3aa54 100644 --- a/ltt/branches/poly/ltt/time.h +++ b/ltt/branches/poly/ltt/time.h @@ -86,14 +86,22 @@ static inline LttTime ltt_time_add(LttTime t1, LttTime t2) return res; } +if t1>t2 return 1 + +if t1-t1 > 0 return 1 + /* Fastest comparison : t1 > t2 */ static inline int ltt_time_compare(LttTime t1, LttTime t2) { int ret=0; - if(likely(t1.tv_sec > t2.tv_sec)) ret = 1; - else if(unlikely(t1.tv_sec < t2.tv_sec)) ret = -1; - else if(likely(t1.tv_nsec > t2.tv_nsec)) ret = 1; - else if(unlikely(t1.tv_nsec < t2.tv_nsec)) ret = -1; + //if(likely(t1.tv_sec > t2.tv_sec)) ret = 1; + //else if(unlikely(t1.tv_sec < t2.tv_sec)) ret = -1; + //else if(likely(t1.tv_nsec > t2.tv_nsec)) ret = 1; + //else if(unlikely(t1.tv_nsec < t2.tv_nsec)) ret = -1; + if(likely(t1.tv_sec - t2.tv_sec > 0)) ret = 1; + else if(unlikely(t1.tv_sec - t2.tv_sec < 0)) ret = -1; + else if(likely(t1.tv_nsec - t2.tv_nsec > 0)) ret = 1; + else if(unlikely(t1.tv_nsec - t2.tv_nsec < 0)) ret = -1; return ret; } -- 2.34.1