[PATCH] gettimeofday time travels

Philip Aston paston@bea.com
Mon Apr 15 14:27:00 GMT 2002


(Resent with appropriate subject in case the original was missed in
the discussion thread).
How about the attached quick and dirty fix?
- Phil
2002年04月14日 Philip Aston <philipa@mail.com>
	* times.cc (hires::usecs): Sync counter every ten minutes to
	work around suspend bug.
Index: cygwin/times.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/times.cc,v
retrieving revision 1.30
diff -u -u -p -r1.30 times.cc
--- cygwin/times.cc	28 Mar 2002 05:20:53 -0000	1.30
+++ cygwin/times.cc	14 Apr 2002 15:09:04 -0000
@@ -599,5 +599,14 @@ hires::usecs (bool justdelta)
 
 // FIXME: Use round() here?
 now.QuadPart = (LONGLONG) (freq * (double) (now.QuadPart - primed_pc.QuadPart));
+
+ /* Reinitialise every ten minutes. Cheap hack to correct time after
+ suspend and resume. */
+ if (now.QuadPart > 600000000l)
+ {
+ inited = 0;
+ return usecs(justdelta);
+ }
+
 return justdelta ? now.QuadPart : primed_ft.QuadPart + now.QuadPart;
 }
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/


More information about the Cygwin mailing list

AltStyle によって変換されたページ (->オリジナル) /