Re: 7.4.1 ... slight change of scheduale ...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Neil Conway <neilc(at)samurai(dot)com>, "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: 7.4.1 ... slight change of scheduale ...
Date: 2003-12-07 01:29:04
Message-ID: 17255.1070760544@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> Tom Lane wrote:
>> That's no fix --- it will break the code on compilers without long long.

> Here are the emails describing the problem. Seems they should see how
> we do time differences in the backend as an example.

Now that I look at it, the code is already depending on long long, which
is silly given the low need for accuracy. For portability it should be
double instead:

double diff;
...

gettimeofday(&now, 0);
diff = (int) (now.tv_sec - then.tv_sec) * 1000000.0 + (int) (now.tv_usec - then.tv_usec);
sleep_secs = args->sleep_base_value + args->sleep_scaling_factor * diff / 1000000.0;

(the (int) casts avoid assuming that the tv_sec and tv_usec fields are
of signed integer types). There's a "%lld" format string to fix too.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Fetter 2003-12-07 01:53:07 Double Backslash example patch
Previous Message Dann Corbit 2003-12-07 01:28:07 Re: Double linked list with one pointer