Commit e52d22b6 authored by Anders Kaseorg's avatar Anders Kaseorg Committed by John Hood
Browse files

Timestamp: Prevent integer overflow on Darwin PPC 32-bit



A Darwin PPC 32-bit user observes huge values numer == 1000000000 and
denom == 18431683 returned from mach_timebase_info().  For these
values, mach_absolute_time() * numer overflows uint64_t every 1000.82
seconds, and 1000000 * denom always overflows uint32_t, with the
effect of making time run backwards at -11190660 times its usual
speed.

This bug was masked on Darwin x86 64-bit, where numer == denom == 1.

Fix it by doing the conversion with double arithmetic instead.

Closes #479.

Signed-off-by: default avatarAnders Kaseorg <andersk@mit.edu>
parent cfc29387
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment