[project @ 2001-11-26 20:04:00 by sof]
authorsof <unknown>
Mon, 26 Nov 2001 20:04:00 +0000 (20:04 +0000)
committersof <unknown>
Mon, 26 Nov 2001 20:04:00 +0000 (20:04 +0000)
commit9746e23a7eec9cce118f0f5e69aa95168143a7d7
tree2723b11f90e31b68dbe57772519929f3bb3fb208
parent254849fcd88bbb7b553141556400194c1bd9f24f
[project @ 2001-11-26 20:04:00 by sof]
Make the IO implementation work with WinSock once again.

When creating sockets with WinSock, you don't get back
a file descriptor, but a SOCKET (which just so happens
to map to the same type as a 'normal' file descriptor).
This SOCKET value cannot be used with the CRT ops
read(), write(), close(), but you have to use the
socket-specific operations (recv(), send(), and closesocket(),
respectively) instead.

To keep track of this distinction between file and
socket file descriptors, the following changes were
made:

* a Handle__ has got a new field, haIsStream, which is True
  for sockets / streams.
  (this field is essentially unused in non-Win32 settings,
   but I decided not to conditionalise its presence).
* PrelHandle.openFd now takes an extra (Maybe FDType) argument,
  which lets you force what type of FD we're converting into
  a Handle (this is crucial for WinSock SOCKETs, since we don't
  want to attempt fstat()ing them).

Fixes breakage that was introduced with May 2001 (or earlier)
rewrite of the IO layer. This commit build upon recent IO changes
to HEAD, so merging it to STABLE will require importing those
changes too (I'll let others be the judge whether this should
be done or not).
ghc/lib/std/PrelHandle.hs
ghc/lib/std/PrelIO.hs
ghc/lib/std/PrelIOBase.lhs
ghc/lib/std/cbits/HsStd.h
ghc/lib/std/cbits/PrelIOUtils.c
ghc/lib/std/cbits/PrelIOUtils.h