[commit: packages/unix] master, safe710fixes, safe710fixes-again, safefixes710again: Use CAPI FFI imports for `truncate` (bc4bd17)

git at git.haskell.org git at git.haskell.org
Thu Mar 19 15:50:15 UTC 2015


Repository : ssh://git@git.haskell.org/unix

On branches: master,safe710fixes,safe710fixes-again,safefixes710again
Link       : http://ghc.haskell.org/trac/ghc/changeset/bc4bd179bda49b615a1c40df7402ddf80bf775b2/unix

>---------------------------------------------------------------

commit bc4bd179bda49b615a1c40df7402ddf80bf775b2
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Thu Aug 7 12:33:51 2014 +0200

    Use CAPI FFI imports for `truncate`
    
    This makes sure we pick up the LFS version of `truncate` in case `off_t`
    is affected by CPP defines such as `_FILE_OFFSET_BITS`.


>---------------------------------------------------------------

bc4bd179bda49b615a1c40df7402ddf80bf775b2
 System/Posix/Files.hsc            | 4 +++-
 System/Posix/Files/ByteString.hsc | 4 +++-
 changelog.md                      | 2 ++
 configure.ac                      | 3 +++
 4 files changed, 11 insertions(+), 2 deletions(-)

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/changelog.md b/changelog.md
index c481922..66caaeb 100644
--- a/changelog.md
+++ b/changelog.md
@@ -12,6 +12,8 @@
     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*
 
   * Bundled with GHC 7.8.1
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])



More information about the ghc-commits mailing list