Re: patch for wanna-build (sysinfo/getloadavg)
On Thu, Jul 24, 2003 at 12:14:57AM +0100, Roger Leigh wrote:
> Robert Millan <email@example.com> writes:
> > Some days ago I posted this small patch for building wanna-build on
> > GNU, and asked for revision, but didn't get any response.
> > It attempts to replace the linux-specific sysinfo() with getloadavg(),
> > but there's a type conversion issue and i'd like to make sure i did it
> > correctly, please could anyone verify this:
> > --- wanna-build.old/buildd-mail-wrapper.c 1999-07-21 14:53:22.000000000 +0200
> > +++ wanna-build/buildd-mail-wrapper.c 2003-07-15 21:06:59.000000000 +0200
> This seems rather complex! Why not just do something like:
> waittime = (long) (loadavg / 16384) * 6 + 20;
> If you don't need SI_LOAD_SHIFT (Linux-specific??), it can probably be
> even simpler.
Can I cast a double to long like that? What kind of truncating happens if
loadavg is bigger than LONG_MAX? Does a division with 2^14 garantee it
will fit nicely?
"[..] but the delight and pride of Aule is in the deed of making, and in the
thing made, and neither in possession nor in his own mastery; wherefore he
gives and hoards not, and is free from care, passing ever on to some new work."
-- J.R.R.T, Ainulindale (Silmarillion)