bug-gnulib
[Top][All Lists]
Advanced

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

Re: Status of the win32 gettimeofday module


From: Bruno Haible
Subject: Re: Status of the win32 gettimeofday module
Date: Wed, 17 Jan 2007 12:43:52 +0100
User-agent: KMail/1.9.1

Two additional modifications:
- Code was missing for the case
  HAVE_GETTIMEOFDAY && !HAVE_GETTIMEOFDAY_POSIX_SIGNATURE.
- Coreutils has a comment explaining why it is useful to compute the
  microseconds as
     milliseconds * 1000 + 999
  rather than as
     milliseconds * 1000.

2007-01-17  Bruno Haible  <address@hidden>

        * lib/gettimeofday.c (gettimeofday): Add code for the case
        HAVE_GETTIMEOFDAY && !GETTIMEOFDAY_CLOBBERS_LOCALTIME. Use the
        maximum possible value for tv->tv_usec, rather than the minimum one.

*** lib/gettimeofday.c  17 Jan 2007 01:04:18 -0000      1.10
--- lib/gettimeofday.c  17 Jan 2007 11:40:37 -0000
***************
*** 98,105 ****
  
  #endif
  
! /* This is a wrapper for gettimeofday.  
!    It is used only on systems that lack this function, or for whose 
     implementation of this function causes problems. */
  
  int
--- 98,105 ----
  
  #endif
  
! /* This is a wrapper for gettimeofday.
!    It is used only on systems that lack this function, or for whose
     implementation of this function causes problems. */
  
  int
***************
*** 107,115 ****
  #undef gettimeofday
  {
  #if HAVE_GETTIMEOFDAY
  # if GETTIMEOFDAY_CLOBBERS_LOCALTIME
    extern struct tm *localtime (const time_t *);
-   extern int gettimeofday (/* unspecified arguments */);
  
    /* Save and restore the contents of the buffer used for localtime's result
       around the call to gettimeofday. */
--- 107,115 ----
  #undef gettimeofday
  {
  #if HAVE_GETTIMEOFDAY
+   extern int gettimeofday (/* unspecified arguments */);
  # if GETTIMEOFDAY_CLOBBERS_LOCALTIME
    extern struct tm *localtime (const time_t *);
  
    /* Save and restore the contents of the buffer used for localtime's result
       around the call to gettimeofday. */
***************
*** 128,153 ****
  
    return result;
  
  # endif
  #else
  # if HAVE__FTIME
  
    struct _timeb timebuf;
!   
    _ftime (&timebuf);
    tv->tv_sec = timebuf.time;
!   tv->tv_usec = timebuf.millitm * 1000;
  
    return 0;
  
  # else
  
    time_t t = time (NULL);
!   
    if (t == (time_t) -1)
      return -1;
    tv->tv_sec = t;
!   tv->tv_usec = 0;
  
    return 0;
  
--- 128,164 ----
  
    return result;
  
+ # else
+ 
+   return gettimeofday (tv, tz);
+ 
  # endif
  #else
+ 
+   /* The clock does not have microsecond resolution, so get the maximum
+      possible value for the current time that is consistent with the
+      reported clock.  That way, files are not considered to be in the
+      future merely because their time stamps have higher resolution
+      than the clock resolution.  */
+ 
  # if HAVE__FTIME
  
    struct _timeb timebuf;
! 
    _ftime (&timebuf);
    tv->tv_sec = timebuf.time;
!   tv->tv_usec = timebuf.millitm * 1000 + 999;
  
    return 0;
  
  # else
  
    time_t t = time (NULL);
! 
    if (t == (time_t) -1)
      return -1;
    tv->tv_sec = t;
!   tv->tv_usec = 999999;
  
    return 0;
  




reply via email to

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