Mail Archives: djgpp/2000/06/14/16:30:22.1
I'm running v2.03. The failure only occurs when booting directly to MS-DOS
(it doesn't fail in a dos box under Win98SE). Here is small test case. Use
the "time" command to set the time 15 seconds or so before midnight and run
the test.
=====================================
#include <stdio.h>
#include <time.h>
int delay_clock(unsigned long max_ticks);
int main(int argc, char *argv[]) {
int status;
unsigned i;
for (i=0; i< 20*1000;i++) { //20 sec
status = delay_clock(1000);
if (status != 0) {
printf("Error: delay_clock has failed\n");
exit(1);
} // error
} //for
return 0;
} // main
int delay_clock(unsigned long max_ticks) {
unsigned long int
diff_time;
uclock_t
starttime,
endtime;
starttime = uclock();
endtime = starttime;
diff_time = (unsigned long int) (endtime - starttime);
while ( diff_time < max_ticks) {
endtime = uclock();
diff_time = (unsigned long int) (endtime - starttime);
if ((diff_time & 0x80000000) == 0x80000000) {
printf("Error: uclock timer has overflowed.\n");
printf(" starttime=%08lx, endtime=%08lx, diff_time=%08lx\n",
(unsigned long int) starttime, (unsigned long int) endtime, diff_time);
exit(1);
} // crazy timer
} /* while delay */
return 0;
} /* delay_clock */
==================
Eli Zaretskii wrote:
> On Mon, 12 Jun 2000, Tim Updegrove wrote:
>
> > My program runs 12 seconds but if it tries to run through midnight then
> > it fails because a uclock() value after midnight is less than a uclock()
> > value before midnight.
>
> `uclock' is written to handle the midnight case, so it should work.
> Please post the shortest test program that can be used to reproduce
> the problem.
>
> What version of DJGPP is this, btw? If it's 2.02, please upgrade to
> v2.03 where `uclock' is more reliable on Windows.
>
> Are you running this on DOS or on Windows?
- Raw text -