Skip to content
  • Ben Gamari's avatar
    rts/win32/IOManager: Fix integer types · 2d1beb1e
    Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
    This code has been broken on 64-bit systems for some time: the length
    and timeout arguments of `addIORequest` and `addDelayRequest`,
    respectively, were declared as `int`. However, they were passed Haskell
    integers from their respective primops. Integer overflow and madness
    ensued. This resulted in #7325 and who knows what else.
    
    Also, there were a few left-over `BOOL`s in here which were not passed
    to Windows system calls; these were changed to C99 `bool`s.
    
    However, there is still a bit of signedness inconsistency within the
    `delay#` call-chain,
    
     * `GHC.Conc.IO.threadDelay` and the `delay#` primop accept `Int`
       arguments
    
     * The `delay#` implementation in `PrimOps.cmm` expects the timeout as
       a `W_`
    
     * `AsyncIO.c:addDelayRequest` expects an `HsInt` (was `int` prior to
       this patch)
    
     * `IOManager.c:AddDelayRequest` expects an `HsInt`` (was `int`)
    
     * The Windows `Sleep` function expects a `DWORD` (which is unsigned)
    
    Test Plan: Validate on Windows
    
    Reviewers: erikd, austin, simonmar, Phyx
    
    Reviewed By: Phyx
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2861
    
    GHC Trac Issues: #7325
    2d1beb1e