aboutsummaryrefslogtreecommitdiffhomepage
path: root/System
diff options
context:
space:
mode:
authorGravatar Herbert Valerio Riedel <hvr@gnu.org>2014-08-07 12:23:07 +0200
committerGravatar Herbert Valerio Riedel <hvr@gnu.org>2014-10-18 16:54:28 +0200
commit43343c151f9824a44bd6e353610fdeb23f910c72 (patch)
treeb3a54ddafd5f7713b21c64fd7fbe430c1ba32f54 /System
parentc46a7fecc212573cc7864a25a762e9e6849f7257 (diff)
Use correct POSIX offset-type for tell/seekdir
This fixes the FFI imports to use the proper `CLong` type over the previous incorrect `COff` type, as using the wrong argument type can cause problems when the `long` and `off_t` types have different size. Historic note from the manual page: In glibc up to version 2.1.1, the return type of telldir() was off_t. POSIX.1-2001 specifies long, and this is the type used since glibc 2.1.2 (released in 1999).
Diffstat (limited to 'System')
-rw-r--r--System/Posix/Directory/Common.hsc8
1 files changed, 4 insertions, 4 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 ()