From: "A. Sinan Unur" Newsgroups: comp.os.msdos.djgpp Subject: Re: rawclock() bug, not just in docs Date: Mon, 18 Aug 1997 17:26:52 -0400 Organization: Cornell University http://www.cornell.edu Lines: 59 Sender: asu1 AT cornell DOT edu (Verified) Message-ID: <33F8BE1C.19DF@cornell.edu> References: <33F8AAC0 DOT 2114 AT geocities DOT nospam DOT com> Reply-To: asu1 AT cornell DOT edu NNTP-Posting-Host: cu-dialup-0025.cit.cornell.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Mark Slagell wrote: > It must be simply taking the system's ticks since midnight at first > call and subtracting that with each subsequent call, I guess that > would explain it. This is hard to work around because reading ticks > via __dpmi_int() or int86() causes the date not to advance at > midnight, at least on my machine. here is the source to rawclock: /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include #include #include unsigned long rawclock(void) { static unsigned long base = 0; unsigned long rv; rv = _farpeekl(_dos_ds, 0x46c); if (base == 0) base = rv; return rv - base; } you seem to be right about this. if the counter at 0x46c resets at midnight, you will get erronous results. one workaround might be to do the following: unsigned long rawclock(void) { static unsigned long base = 0; unsigned long rv; rv = _farpeekl(_dos_ds, 0x46c); if (base == 0) base = rv; if( rv < base ) /* see if the counter has reset */ { rv += ULONG_MAX - base; /* adjust ticks elapsed */ base = rv - (ULONG_MAX - base); /* adjust base */ } return rv - base; } would this be acceptable? -- Sinan ******************************************************************* A. Sinan Unur WWWWWW |--O+O mailto:sinan DOT unur AT cornell DOT edu C ^ http://www.people.cornell.edu/pages/asu1/ \ ~/ Unsolicited e-mail is _not_ welcome, and will be billed for. *******************************************************************