delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/13/07:03:47

Newsgroups: comp.os.msdos.djgpp
From: bshadwick AT juno DOT com (Ben N Shadwick)
Subject: rawclock() and other time.h functions
Message-ID: <resurrect.19970610.134653.8846.0.bshadwick@juno.com>
Supersedes: <19970610 DOT 134653 DOT 8846 DOT 0 DOT bshadwick AT juno DOT com>
Approved: bshadwick AT juno DOT com
Comment: reposted by hweede AT berlin DOT snafu DOT de after erroneous cancellation
Organization: None provided
Date: Tue, 10 Jun 1997 20:46:52 GMT
Dj-Gateway: from mailing list djgpp AT delorie DOT com
Lines: 51
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I was going to use rawclock() to seed the random number generator in a
DJGPP/Allegro program I'm writing, as the info file, libc.inf, said that
rawclock() returns the number of clock ticks since midnight (I was hoping
that it would be similar to saying RANDOMIZE TIMER in BASIC <hehe>).
Here, I'll quote it for you:

"rawclock
========
Syntax
------
#include <time.h>
unsigned long rawclock(void);

Description
-----------
Returns the number of clock tics (18.2 per second) since midnight.

Return Value
------------
The number of tics."

Well, the problem is, it doesn't return the number of clock ticks since
midnight, but rather the number of somethings (clock ticks I suppose)
since the first time it was called! I know that some of the time.h
functions are specifically described as returning the number of something
since the first call, but I also know that (as you can see) rawclock()
isn't supposed to work that way (according to the reference manual,
anyways).

Is there something I didn't do? Do I have to call some function or set
some flag to set it up? I know it's not caused by anything other than
DJGPP itself, as this small program I just made yields the same results:

#include <stdio.h>
#include <time.h>
#include <conio.h>

int main(int argc, char *argv[]) /U2 /bin /cdrom /core /dev /devices /etc /export /home /kernel /lib /local /lost+found /mnt /net /opt /platform /proc /root /sbin /space /sqlnet.log /tmp /u /usr /var /vol /xfn :P */
{
while(!kbhit())
printf("%lu\n", rawclock());
}

Thanx for your help, everybody!

=====
Ben Shadwick, Sysop, Mars Base BBS, (360)882-0773, Vancouver, WA, USA
Unofficial member, TheGods/DemiUrg Software,
http://www.swiftsite.com/thegods
email: bshadwick AT juno DOT com (please reply to newsgroup posts via email too)
DJGPP or bust! Going my way?

- Raw text -


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