Skip to content
Snippets Groups Projects
Forked from The Tor Project / Core / Tor
Source project has a limited visibility.
  • Nick Mathewson's avatar
    d97fca16
    Fix an integer overflow related to monotonic time on windows. · d97fca16
    Nick Mathewson authored
    To maintain precision, to get nanoseconds, we were multiplying our
    tick count by a billion, then dividing by ticks-per-second.  But
    that apparently isn't such a great idea, since ticks-per-second is
    sometimes a billion on its own, so our intermediate result was
    giving us attoseconds.
    
    When you're counting in attoseconds, you can only fit about 9
    seconds into an int64_t, which is not so great for our purposes.
    
    Instead, we now simplify the 1000000000/1000000000 fraction before
    we start messing with nanoseconds.  This has potential to mess us
    up if some future MS version declares that performance counters will
    use 1,000,000,007 units per second, but let's burn that bridge when
    we come to it.
    d97fca16
    History
    Fix an integer overflow related to monotonic time on windows.
    Nick Mathewson authored
    To maintain precision, to get nanoseconds, we were multiplying our
    tick count by a billion, then dividing by ticks-per-second.  But
    that apparently isn't such a great idea, since ticks-per-second is
    sometimes a billion on its own, so our intermediate result was
    giving us attoseconds.
    
    When you're counting in attoseconds, you can only fit about 9
    seconds into an int64_t, which is not so great for our purposes.
    
    Instead, we now simplify the 1000000000/1000000000 fraction before
    we start messing with nanoseconds.  This has potential to mess us
    up if some future MS version declares that performance counters will
    use 1,000,000,007 units per second, but let's burn that bridge when
    we come to it.