rts/win32/IOManager: Fix integer types
authorBen Gamari <bgamari.foss@gmail.com>
Sat, 17 Dec 2016 23:08:00 +0000 (18:08 -0500)
committerBen Gamari <ben@smart-cactus.org>
Sat, 17 Dec 2016 23:09:40 +0000 (18:09 -0500)
commit2d1beb1ec84c2d22c6be83944ef4ea8626abd76a
tree2a722f9d0e9abf2dc40c35e387c3df0fd82729c5
parent3dbd2b097aeb9217f4a7fc87e610e6983ebbce7b
rts/win32/IOManager: Fix integer types

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
rts/win32/AsyncIO.c
rts/win32/AsyncIO.h
rts/win32/IOManager.c
rts/win32/IOManager.h