projects
/
gnulib.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
dbf1e21
)
Two more fixes to revised gettimeofday module.
author
Bruno Haible
<bruno@clisp.org>
Wed, 17 Jan 2007 11:48:22 +0000
(11:48 +0000)
committer
Bruno Haible
<bruno@clisp.org>
Wed, 17 Jan 2007 11:48:22 +0000
(11:48 +0000)
ChangeLog
patch
|
blob
|
history
lib/gettimeofday.c
patch
|
blob
|
history
diff --git
a/ChangeLog
b/ChangeLog
index
6081d0a
..
2e845d2
100644
(file)
--- a/
ChangeLog
+++ b/
ChangeLog
@@
-1,3
+1,9
@@
+2007-01-17 Bruno Haible <bruno@clisp.org>
+
+ * 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.
+
2005-10-08 Martin Lambers <marlam@marlam.de>
2005-10-08 Paul Eggert <eggert@cs.ucla.edu>
2007-01-16 Bruno Haible <bruno@clisp.org>
2005-10-08 Martin Lambers <marlam@marlam.de>
2005-10-08 Paul Eggert <eggert@cs.ucla.edu>
2007-01-16 Bruno Haible <bruno@clisp.org>
diff --git
a/lib/gettimeofday.c
b/lib/gettimeofday.c
index
e0afa49
..
38094b0
100644
(file)
--- a/
lib/gettimeofday.c
+++ b/
lib/gettimeofday.c
@@
-98,8
+98,8
@@
tzset (void)
#endif
#endif
-/* This is a wrapper for gettimeofday.
- It is used only on systems that lack this function, or for whose
+/* 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
implementation of this function causes problems. */
int
@@
-107,9
+107,9
@@
gettimeofday (struct timeval *restrict tv, void *restrict tz)
#undef gettimeofday
{
#if HAVE_GETTIMEOFDAY
#undef gettimeofday
{
#if HAVE_GETTIMEOFDAY
+ extern int gettimeofday (/* unspecified arguments */);
# if GETTIMEOFDAY_CLOBBERS_LOCALTIME
extern struct tm *localtime (const time_t *);
# 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. */
/* Save and restore the contents of the buffer used for localtime's result
around the call to gettimeofday. */
@@
-128,26
+128,37
@@
gettimeofday (struct timeval *restrict tv, void *restrict tz)
return result;
return result;
+# else
+
+ return gettimeofday (tv, tz);
+
# endif
#else
# 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;
# if HAVE__FTIME
struct _timeb timebuf;
-
+
_ftime (&timebuf);
tv->tv_sec = timebuf.time;
_ftime (&timebuf);
tv->tv_sec = timebuf.time;
- tv->tv_usec = timebuf.millitm * 1000;
+ tv->tv_usec = timebuf.millitm * 1000
+ 999
;
return 0;
# else
time_t t = time (NULL);
return 0;
# else
time_t t = time (NULL);
-
+
if (t == (time_t) -1)
return -1;
tv->tv_sec = t;
if (t == (time_t) -1)
return -1;
tv->tv_sec = t;
- tv->tv_usec =
0
;
+ tv->tv_usec =
999999
;
return 0;
return 0;