dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] pnet ChangeLog configure.in support/time.c


From: Radek Polak
Subject: [dotgnu-pnet-commits] pnet ChangeLog configure.in support/time.c
Date: Mon, 10 Sep 2007 08:38:24 +0000

CVSROOT:        /sources/dotgnu-pnet
Module name:    pnet
Changes by:     Radek Polak <radekp>    07/09/10 08:38:24

Modified files:
        .              : ChangeLog configure.in 
        support        : time.c 

Log message:
        fix tick count computing

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3491&r2=1.3492
http://cvs.savannah.gnu.org/viewcvs/pnet/configure.in?cvsroot=dotgnu-pnet&r1=1.227&r2=1.228
http://cvs.savannah.gnu.org/viewcvs/pnet/support/time.c?cvsroot=dotgnu-pnet&r1=1.18&r2=1.19

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3491
retrieving revision 1.3492
diff -u -b -r1.3491 -r1.3492
--- ChangeLog   22 Aug 2007 19:21:28 -0000      1.3491
+++ ChangeLog   10 Sep 2007 08:38:23 -0000      1.3492
@@ -1,3 +1,12 @@
+2007-09-10  Radek Polak  <address@hidden>
+
+       * configure.in: Added check for clock_gettime.
+
+       * support/time.c: Replaced code that is computing tick count using
+       bootime and current time with apropriate system calls. Computing ticks
+       from current time can't work good when date or time is changed.
+       Original patch by Brubbel - thanks.
+
 2007-08-22  Ivan de Jesus Deras Tabora  <address@hidden>
 
        * engine/verify_obj.c: Fixed IL_OP_BOX to be ECMA 335 compliant.  Now

Index: configure.in
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/configure.in,v
retrieving revision 1.227
retrieving revision 1.228
diff -u -b -r1.227 -r1.228
--- configure.in        1 Jun 2007 17:16:02 -0000       1.227
+++ configure.in        10 Sep 2007 08:38:23 -0000      1.228
@@ -366,6 +366,7 @@
 AC_CHECK_LIB(dl, dlopen)
 AC_CHECK_LIB(socket, connect)
 AC_CHECK_LIB(nsl, gethostbyname)
+AC_CHECK_LIB(rt, clock_gettime)
 have_libz=no
 if test "x$suppress_libm" = "xno" ; then
        AC_CHECK_LIB(z, inflate,
@@ -606,6 +607,7 @@
 AC_CHECK_FUNCS(acos asin atan atan2 ceil cos cosh exp floor remainder)
 AC_CHECK_FUNCS(log log10 pow rint sin sinh sqrt tan tanh)
 AC_CHECK_FUNCS(wctomb wcrtomb mbtowc mbrtowc nl_langinfo setlocale)
+AC_CHECK_FUNCS(clock_gettime)
 AC_CHECK_FUNCS(usleep gethostbyname gethostbyaddr isatty getpwuid geteuid)
 AC_CHECK_FUNCS(opendir readdir readdir_r closedir chdir access)
 AC_CHECK_FUNCS(cygwin_conv_to_win32_path snprintf rename utime)

Index: support/time.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/support/time.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- support/time.c      2 Nov 2006 18:22:40 -0000       1.18
+++ support/time.c      10 Sep 2007 08:38:23 -0000      1.19
@@ -49,14 +49,12 @@
        || defined(__linux) || defined(__linux__))
        
        #include <sys/sysinfo.h>
-       #define USE_BOOTTIME 1
 #endif
 
 #if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_SYSCTL) \
        && defined(__FreeBSD__)
        
        #include <sys/sysctl.h>
-       #define USE_BOOTTIME 1
 #endif
 
 #ifdef __cplusplus
@@ -111,10 +109,6 @@
 #endif
 }
 
-#if defined(USE_BOOTTIME)
-static ILCurrTime bootTime;
-#endif
-
 int ILGetSinceRebootTime(ILCurrTime *timeValue)
 {
 #ifdef IL_WIN32_PLATFORM
@@ -126,14 +120,10 @@
        timeValue->nsecs = (tick % 1000) * 1000000;
 
        return 1;
-#elif defined(USE_BOOTTIME) && defined(__FreeBSD__) 
+#elif defined(__FreeBSD__)
        int len, mib[2];        
        struct timeval tv;
 
-       ILGetCurrTime(timeValue);
-
-       if (bootTime.secs == 0 && bootTime.nsecs == 0)
-       {
                mib[0] = CTL_KERN;
                mib[1] = KERN_BOOTTIME;
 
@@ -144,59 +134,22 @@
                        return 0;
                }
 
-               ILThreadAtomicStart();
-
-               bootTime.secs = ((ILInt64)(tv.tv_sec)) + EPOCH_ADJUST;
-               bootTime.nsecs = (ILUInt32)(tv.tv_usec * 1000);
+       timeValue.secs = ((ILInt64)(tv.tv_sec));
+       timeValue.nsecs = (ILUInt32)(tv.tv_usec * 1000);
 
-               ILThreadAtomicEnd();
-       }
-       
-#elif defined(USE_BOOTTIME) && (defined(linux) \
-       || defined(__linux) || defined(__linux__))
+       return 1;
 
-       struct sysinfo si;
+#elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
        
-       ILGetCurrTime(timeValue);
+       struct timespec tp;
 
-       if (bootTime.secs == 0 && bootTime.nsecs == 0)
-       {
-               if (sysinfo(&si) != 0)
+       if(clock_gettime(CLOCK_MONOTONIC, &tp) != 0)
                {
                        return 0;
                }
                
-               ILThreadAtomicStart();          
-               bootTime.secs = timeValue->secs - si.uptime;
-
-               /* sysinfo() is only accurate to the second so
-                  use the nsec value from the curren time.
-                  This allows subsequent calls to this function
-                  to get nsec time-differential precision  */
-
-               bootTime.nsecs = timeValue->nsecs;
-               ILThreadAtomicEnd();
-       }
-#endif
-
-#if defined(USE_BOOTTIME)
-       /* Subtract the current time from the time since the system
-          was started */
-
-       if(timeValue->nsecs < bootTime.nsecs)
-       {
-               timeValue->nsecs = 
-                       timeValue->nsecs - bootTime.nsecs + 1000000000;
-               timeValue->secs =
-                       timeValue->secs - bootTime.secs - 1;
-       }
-       else
-       {
-               timeValue->nsecs =
-                       timeValue->nsecs - bootTime.nsecs;                      
-               timeValue->secs =
-                       timeValue->secs - bootTime.secs;
-       }       
+       timeValue->secs = tp.tv_sec;
+       timeValue->nsecs = tp.tv_nsec;
 
        return 1;
        




reply via email to

[Prev in Thread] Current Thread [Next in Thread]