Mail Archives: djgpp/1997/08/19/05:48:37
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 <time.h>
#include <go32.h>
#include <libc/farptrgs.h>
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.
*******************************************************************
- Raw text -