diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2014-10-18 17:08:52 +0200 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2014-10-18 17:08:52 +0200 |
commit | 5970f506e6f8baa125063c12cfe7cd2bb3747295 (patch) | |
tree | e3042b3ae1b3ab7b1bd95f9925ace150f9a9ebcd | |
parent | c46a7fecc212573cc7864a25a762e9e6849f7257 (diff) | |
parent | 1b53296fba0d36f6144c7797e96bf95b33a4cd7e (diff) |
Merge pull request #5 from hvr/pr-LFS
Fix potential LFS related issues
-rw-r--r-- | System/Posix/Directory/Common.hsc | 8 | ||||
-rw-r--r-- | System/Posix/Files.hsc | 4 | ||||
-rw-r--r-- | System/Posix/Files/ByteString.hsc | 4 | ||||
-rw-r--r-- | System/Posix/SharedMem.hsc | 4 | ||||
-rw-r--r-- | changelog.md | 4 | ||||
-rw-r--r-- | configure.ac | 3 |
6 files changed, 19 insertions, 8 deletions
diff --git a/System/Posix/Directory/Common.hsc b/System/Posix/Directory/Common.hsc index 86d87ca..7cc61af 100644 --- a/System/Posix/Directory/Common.hsc +++ b/System/Posix/Directory/Common.hsc @@ -62,20 +62,20 @@ newtype DirStreamOffset = DirStreamOffset COff #ifdef HAVE_SEEKDIR seekDirStream :: DirStream -> DirStreamOffset -> IO () seekDirStream (DirStream dirp) (DirStreamOffset off) = - c_seekdir dirp off + c_seekdir dirp (fromIntegral off) -- TODO: check for CLong/COff overflow foreign import ccall unsafe "seekdir" - c_seekdir :: Ptr CDir -> COff -> IO () + c_seekdir :: Ptr CDir -> CLong -> IO () #endif #ifdef HAVE_TELLDIR tellDirStream :: DirStream -> IO DirStreamOffset tellDirStream (DirStream dirp) = do off <- c_telldir dirp - return (DirStreamOffset off) + return (DirStreamOffset (fromIntegral off)) -- TODO: check for overflow foreign import ccall unsafe "telldir" - c_telldir :: Ptr CDir -> IO COff + c_telldir :: Ptr CDir -> IO CLong #endif changeWorkingDirectoryFd :: Fd -> IO () diff --git a/System/Posix/Files.hsc b/System/Posix/Files.hsc index c8b5ddf..1822294 100644 --- a/System/Posix/Files.hsc +++ b/System/Posix/Files.hsc @@ -1,6 +1,8 @@ #ifdef __GLASGOW_HASKELL__ {-# LANGUAGE Trustworthy #-} #endif +{-# LANGUAGE CApiFFI #-} + ----------------------------------------------------------------------------- -- | -- Module : System.Posix.Files @@ -420,7 +422,7 @@ setFileSize file off = withFilePath file $ \s -> throwErrnoPathIfMinus1_ "setFileSize" file (c_truncate s off) -foreign import ccall unsafe "truncate" +foreign import capi unsafe "HsUnix.h truncate" c_truncate :: CString -> COff -> IO CInt -- ----------------------------------------------------------------------------- diff --git a/System/Posix/Files/ByteString.hsc b/System/Posix/Files/ByteString.hsc index 80f0bea..cb68668 100644 --- a/System/Posix/Files/ByteString.hsc +++ b/System/Posix/Files/ByteString.hsc @@ -1,6 +1,8 @@ #ifdef __GLASGOW_HASKELL__ {-# LANGUAGE Trustworthy #-} #endif +{-# LANGUAGE CApiFFI #-} + ----------------------------------------------------------------------------- -- | -- Module : System.Posix.Files.ByteString @@ -420,7 +422,7 @@ setFileSize file off = withFilePath file $ \s -> throwErrnoPathIfMinus1_ "setFileSize" file (c_truncate s off) -foreign import ccall unsafe "truncate" +foreign import capi unsafe "HsUnix.h truncate" c_truncate :: CString -> COff -> IO CInt -- ----------------------------------------------------------------------------- diff --git a/System/Posix/SharedMem.hsc b/System/Posix/SharedMem.hsc index 1d7a80a..c85e4b7 100644 --- a/System/Posix/SharedMem.hsc +++ b/System/Posix/SharedMem.hsc @@ -19,12 +19,12 @@ module System.Posix.SharedMem (ShmOpenFlags(..), shmOpen, shmUnlink) where +#include "HsUnix.h" + #include <sys/types.h> #include <sys/mman.h> #include <fcntl.h> -#include "HsUnix.h" - import System.Posix.Types #if defined(HAVE_SHM_OPEN) || defined(HAVE_SHM_UNLINK) import Foreign.C diff --git a/changelog.md b/changelog.md index ae5b726..66caaeb 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,4 @@ +<<<<<<< HEAD # Changelog for [`unix` package](http://hackage.haskell.org/package/unix) ## 2.7.0.2 *TBA* @@ -9,6 +10,9 @@ CPP macros for required getgrgid_r and getgrnam_r functions definition so the fix is to change from C ABI calling convention to C API calling convention + * Fix potential type-mismatch in `telldir`/`seekdir` FFI imports + + * Use CAPI FFI import for `truncate` to make sure the LFS-version is used. ## 2.7.0.1 *Mar 2014* diff --git a/configure.ac b/configure.ac index 41274dc..c10bf89 100644 --- a/configure.ac +++ b/configure.ac @@ -18,6 +18,9 @@ AC_C_CONST dnl ** Enable large file support. NB. do this before testing the type of dnl off_t, because it will affect the result of that test. +dnl +dnl WARNING: It's essential this check agrees with HsBaseConfig.h as otherwise +dnl the definitions of COff/coff_t don't line up AC_SYS_LARGEFILE AC_CHECK_HEADERS([dirent.h fcntl.h grp.h limits.h pwd.h signal.h string.h]) |