Skip to content
Snippets Groups Projects
Forked from Alchemy Viewer / Alchemy Viewer
Source project has a limited visibility.
  • Nat Goodspeed's avatar
    aa112ef1
    DRTVWR-575: Fix bug in macOS micro_sleep(). · aa112ef1
    Nat Goodspeed authored
    The compiler was deducing an unsigned type for the difference (U64 desired
    microseconds - half KERNEL_SLEEP_INTERVAL_US). When the desired sleep was less
    than that constant, the difference went hugely positive, resulting in a very
    long snooze.
    
    Amusingly, forcing that U64 result into an S32 num_sleep_intervals worked only
    *because* of integer truncation: the high-order bits were discarded, resulting
    in a negative result as intended.
    
    Ensuring that both integer operands are signed at the outset, though, produces
    a more formally correct result.
    aa112ef1
    History
    DRTVWR-575: Fix bug in macOS micro_sleep().
    Nat Goodspeed authored
    The compiler was deducing an unsigned type for the difference (U64 desired
    microseconds - half KERNEL_SLEEP_INTERVAL_US). When the desired sleep was less
    than that constant, the difference went hugely positive, resulting in a very
    long snooze.
    
    Amusingly, forcing that U64 result into an S32 num_sleep_intervals worked only
    *because* of integer truncation: the high-order bits were discarded, resulting
    in a negative result as intended.
    
    Ensuring that both integer operands are signed at the outset, though, produces
    a more formally correct result.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.