This is the mail archive of the
cygwin-patches@cygwin.com
mailing list for the Cygwin project.
Re: time(time_t*) problem
- From: David MacMahon <cygwin at smartsc dot com>
- To: cygwin-patches at cygwin dot com
- Date: Thu, 25 Jul 2002 09:01:42 -0700
- Subject: Re: time(time_t*) problem
- References: <20020724053334.GA2665@redhat.com>
On Wed, Jul 24, 2002 at 01:33:34AM -0400, Christopher Faylor wrote:
> On Tue, Jul 23, 2002 at 10:34:02PM -0700, David MacMahon wrote:
> >(sorry, I didn't do a Changelog >entry).
>
> Why?
I was a little bit rushed (OK, lazy) at the time. Below is a better
submission. Do you prefer these to be inline (as below) or as
attachments (or both)?
Dave
2002-07-24 David MacMahon <davidm@smartsc.com>
* times.cc (to_time_t): Always round time_t down to nearest second.
Index: src/winsup/cygwin/times.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/times.cc,v
retrieving revision 1.38
diff -u -r1.38 times.cc
--- src/winsup/cygwin/times.cc 8 Jun 2002 01:24:58 -0000 1.38
+++ src/winsup/cygwin/times.cc 25 Jul 2002 00:09:08 -0000
@@ -212,7 +212,6 @@
stuffed into two long words.
A time_t is the number of seconds since jan 1 1970. */
- long rem;
long long x = ((long long) ptr->dwHighDateTime << 32) + ((unsigned)ptr->dwLowDateTime);
/* pass "no time" as epoch */
@@ -220,10 +219,7 @@
return 0;
x -= FACTOR; /* number of 100ns between 1601 and 1970 */
- rem = x % ((long long)NSPERSEC);
- rem += (NSPERSEC / 2);
x /= (long long) NSPERSEC; /* number of 100ns in a second */
- x += (long long) (rem / NSPERSEC);
return x;
}
--
David MacMahon, President
Smart Software Consulting
http://www.smartsc.com