diff options
author | Tamar Christina <tamar@zhox.com> | 2016-09-01 21:30:07 +0100 |
---|---|---|
committer | Tamar Christina <tamar@zhox.com> | 2016-09-01 21:31:52 +0100 |
commit | e5ecb2010514405ac1b9b1285a8a65c00a5fd4e0 (patch) | |
tree | 866ae612180fb7fab7af9281d8f43980ec6718e1 /libraries | |
parent | f233f00b1915ac6c0a200b8017a9f07deefd401e (diff) | |
download | haskell-e5ecb2010514405ac1b9b1285a8a65c00a5fd4e0.tar.gz |
Added support for deprecated POSIX functions on Windows.
Summary:
With the introduction of 8.0.1 We've stopped supporting in GHCi
the use of POSIX functions under their deprecated names on Windows.
This to be compatible with object and libraries from the most
popular compilers on the platform (Microsoft and Intel compilers).
However this brings a confusing disparity between the compiled and
interpreted behavior since MingW-W64 does support the deprecated names.
Also It seems clear that package writers won't update their packages to
properly support Windows. As such I have added redirects in the RTS
for the deprecated functions as listed on
https://msdn.microsoft.com/en-us/library/ms235384.aspx.
This won't export the functions (as in, they won't be in the symbol table
of compiled code for the RTS.) but we inject them into the symbol table
of the dynamic linker at startup.
Test Plan:
./validate
and
make test TEST="ffi017 ffi021"
Reviewers: thomie, simonmar, RyanGlScott, bgamari, austin, hvr, erikd
Reviewed By: simonmar, bgamari
Subscribers: RyanGlScott, #ghc_windows_task_force
Differential Revision: https://phabricator.haskell.org/D2500
GHC Trac Issues: #12209, #12497, #12496
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/base/System/Posix/Internals.hs | 63 |
1 files changed, 17 insertions, 46 deletions
diff --git a/libraries/base/System/Posix/Internals.hs b/libraries/base/System/Posix/Internals.hs index 630f251669..7bb26fa395 100644 --- a/libraries/base/System/Posix/Internals.hs +++ b/libraries/base/System/Posix/Internals.hs @@ -378,32 +378,35 @@ being done. See #11223 See https://msdn.microsoft.com/en-us/library/ms235384.aspx for more. + +However since we can't hope to get people to support Windows +packages we should support the deprecated names. See #12497 -} -#if defined(mingw32_HOST_OS) -foreign import ccall unsafe "io.h _lseeki64" - c_lseek :: CInt -> Int64 -> CInt -> IO Int64 +foreign import capi unsafe "unistd.h lseek" + c_lseek :: CInt -> COff -> CInt -> IO COff -foreign import ccall unsafe "HsBase.h _access" +foreign import ccall unsafe "HsBase.h access" c_access :: CString -> CInt -> IO CInt -foreign import ccall unsafe "HsBase.h _chmod" +foreign import ccall unsafe "HsBase.h chmod" c_chmod :: CString -> CMode -> IO CInt -foreign import ccall unsafe "HsBase.h _close" +foreign import ccall unsafe "HsBase.h close" c_close :: CInt -> IO CInt -foreign import ccall unsafe "HsBase.h _creat" +foreign import ccall unsafe "HsBase.h creat" c_creat :: CString -> CMode -> IO CInt -foreign import ccall unsafe "HsBase.h _dup" +foreign import ccall unsafe "HsBase.h dup" c_dup :: CInt -> IO CInt -foreign import ccall unsafe "HsBase.h _dup2" +foreign import ccall unsafe "HsBase.h dup2" c_dup2 :: CInt -> CInt -> IO CInt -foreign import ccall unsafe "HsBase.h _isatty" +foreign import ccall unsafe "HsBase.h isatty" c_isatty :: CInt -> IO CInt +#if defined(mingw32_HOST_OS) -- See Note: Windows types foreign import capi unsafe "HsBase.h _read" c_read :: CInt -> Ptr Word8 -> CUInt -> IO CInt @@ -423,44 +426,12 @@ foreign import capi unsafe "HsBase.h _write" foreign import capi safe "HsBase.h _write" c_safe_write :: CInt -> Ptr Word8 -> CUInt -> IO CInt -foreign import ccall unsafe "HsBase.h _unlink" - c_unlink :: CString -> IO CInt - foreign import ccall unsafe "HsBase.h _pipe" c_pipe :: Ptr CInt -> IO CInt - -foreign import capi unsafe "HsBase.h _utime" - c_utime :: CString -> Ptr CUtimbuf -> IO CInt - -foreign import ccall unsafe "HsBase.h _getpid" - c_getpid :: IO CPid #else -- We use CAPI as on some OSs (eg. Linux) this is wrapped by a macro -- which redirects to the 64-bit-off_t versions when large file -- support is enabled. -foreign import capi unsafe "unistd.h lseek" - c_lseek :: CInt -> COff -> CInt -> IO COff - -foreign import ccall unsafe "HsBase.h access" - c_access :: CString -> CInt -> IO CInt - -foreign import ccall unsafe "HsBase.h chmod" - c_chmod :: CString -> CMode -> IO CInt - -foreign import ccall unsafe "HsBase.h close" - c_close :: CInt -> IO CInt - -foreign import ccall unsafe "HsBase.h creat" - c_creat :: CString -> CMode -> IO CInt - -foreign import ccall unsafe "HsBase.h dup" - c_dup :: CInt -> IO CInt - -foreign import ccall unsafe "HsBase.h dup2" - c_dup2 :: CInt -> CInt -> IO CInt - -foreign import ccall unsafe "HsBase.h isatty" - c_isatty :: CInt -> IO CInt -- See Note: Windows types foreign import capi unsafe "HsBase.h read" @@ -481,18 +452,18 @@ foreign import capi unsafe "HsBase.h write" foreign import capi safe "HsBase.h write" c_safe_write :: CInt -> Ptr Word8 -> CSize -> IO CSsize -foreign import ccall unsafe "HsBase.h unlink" - c_unlink :: CString -> IO CInt - foreign import ccall unsafe "HsBase.h pipe" c_pipe :: Ptr CInt -> IO CInt +#endif + +foreign import ccall unsafe "HsBase.h unlink" + c_unlink :: CString -> IO CInt foreign import capi unsafe "HsBase.h utime" c_utime :: CString -> Ptr CUtimbuf -> IO CInt foreign import ccall unsafe "HsBase.h getpid" c_getpid :: IO CPid -#endif foreign import ccall unsafe "HsBase.h __hscore_stat" c_stat :: CFilePath -> Ptr CStat -> IO CInt |