diff options
author | Ben Gamari <ben@smart-cactus.org> | 2018-02-20 00:26:45 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-02-20 13:15:40 -0500 |
commit | abfe10487d2dba49bf511297f14575f9089cc5b1 (patch) | |
tree | 7416a6fcd2091f9d92fc6740af07d5e37ee9e03d /iserv/src/GHCi/Utils.hsc | |
parent | f4336593a390e6317ac2852d8defb54bfa633d3e (diff) | |
download | haskell-abfe10487d2dba49bf511297f14575f9089cc5b1.tar.gz |
Revert "Move `iserv` into `utils` and change package name
See Phab:D4377 for the rationale. We will try this again.
This reverts commit 7c173b9043f7a9a5da46c5b0cc5fc3b38d1a7019.
Diffstat (limited to 'iserv/src/GHCi/Utils.hsc')
-rw-r--r-- | iserv/src/GHCi/Utils.hsc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/iserv/src/GHCi/Utils.hsc b/iserv/src/GHCi/Utils.hsc new file mode 100644 index 0000000000..b90cfacb5f --- /dev/null +++ b/iserv/src/GHCi/Utils.hsc @@ -0,0 +1,25 @@ +{-# LANGUAGE CPP #-} +module GHCi.Utils + ( getGhcHandle + ) where + +import Foreign.C +import GHC.IO.Handle (Handle()) +#ifdef mingw32_HOST_OS +import GHC.IO.Handle.FD (fdToHandle) +#else +import System.Posix +#endif + +#include <fcntl.h> /* for _O_BINARY */ + +-- | Gets a GHC Handle File description from the given OS Handle or POSIX fd. +getGhcHandle :: CInt -> IO Handle +#ifdef mingw32_HOST_OS +getGhcHandle handle = _open_osfhandle handle (#const _O_BINARY) >>= fdToHandle + +foreign import ccall "io.h _open_osfhandle" _open_osfhandle :: + CInt -> CInt -> IO CInt +#else +getGhcHandle fd = fdToHandle $ Fd fd +#endif |