From: Ivan Maidanski Date: Fri, 4 Jan 2019 16:37:50 +0000 (+0300) Subject: Fix BSD_TIME variant of MS_TIME_DIFF for the case of a.tv_usec < b.tv_usec X-Git-Tag: upstream/8.0.4~367 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=54e87d662eeb17459b0f33eb6fa423126ae4bca9;p=platform%2Fupstream%2Flibgc.git Fix BSD_TIME variant of MS_TIME_DIFF for the case of a.tv_usec < b.tv_usec (fix of commit 6b2796b69) * include/private/gc_priv.h [!NO_CLOCK && BSD_TIME] (MS_TIME_DIFF): Cast the result of a.tv_usec-b.tv_usec to long (so that the result of the division should be negative if a.tv_usec is less than b.tv_usec). --- diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 3027c8f..8139cee 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -435,8 +435,8 @@ EXTERN_C_END getrusage(RUSAGE_SELF, &rusage); \ x = rusage.ru_utime; \ } while (0) -# define MS_TIME_DIFF(a,b) ((unsigned long)(a.tv_sec - b.tv_sec) * 1000 \ - + (unsigned long)(a.tv_usec - b.tv_usec) / 1000) +# define MS_TIME_DIFF(a,b) ((unsigned long)((long)(a.tv_sec-b.tv_sec) * 1000 \ + + (long)(a.tv_usec-b.tv_usec) / 1000)) #elif defined(MSWIN32) || defined(MSWINCE) # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN 1