delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/22/01:39:35

Date: Wed, 21 May 1997 22:33:32 -0700 (PDT)
Message-Id: <199705220533.WAA06133@adit.ap.net>
Mime-Version: 1.0
To: djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Bug in libc.a, specifically rawclock()

The rawclock() function in DJGPP 2.01 is either mis-written or
mis-documented. The info docs say it returns timer ticks (1/18 sec) since
midnight. Actually it returns timer ticks since *its first call*, something
like what clock() does. This makes it useless as a random number generator
seed, which actually seems to be its *only* useful purpose.

The relevant code is in src/libc/compat/time/rawclock.c. To make it perform
as documented, the function might be changed to:

unsigned long rawclock(void)
{
        return _farpeekl(_dos_ds,0x46c); /* BIOS keeps tick count since
midnight here */
}

of course leaving all the #includes intact, and then compiling and "ar
rs"'ing into libc.a. Either that or the documentation needs to be changed.

Any questions or comments to me at <eldredge AT ap DOT net>. I am not on the
mailing list.
Thanks.


					--Nate <eldredge AT ap DOT net>


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019