www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/31/21:10:57

Date: Mon, 31 Mar 1997 20:57:17 -0500 (EST)
From: firewind <firewind AT constellation DOT stu DOT rpi DOT edu>
To: John K Murphy <john DOT k DOT murphy AT juno DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: rawclock() not working right?
In-Reply-To: <19970331.170447.12510.0.john.k.murphy@juno.com>
Message-ID: <Pine.LNX.3.96.970331205122.849A-100000@constellation.stu.rpi.edu>
MIME-Version: 1.0


On Mon, 31 Mar 1997, John K Murphy wrote:

> I was looking for something to seed the random # generator, and
> rawclock() looked like a good choice, since it is supposed to give the
> number of clock_ticks since midnight.  I tested it, and found out
> rawclock() gives the number of something (clock_tics?) since it's first
> call, which always returns 0.  Is this a bug in DGJPP or a mistake in the
> documentation... or does it work correctly on anybody's computer?

This question has come up before; I looked at the source then, and it made
no sense, and still makes no sense. Here's the important part:

  if (base == 0) 
    base = rv; 
  return rv - base;

base is assigned 0 at the beginning of the function and never changed.
Then, the test passes, and 0 gets assigned to rv! I removed the assignment
and recompiled to an object file I linked with a test program, and it gave
results that appeared to be correct.

So, to answer your question, yes it's a bug, but it's easily fixable.

firewind


- Raw text -


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