[commit: unix] master: cope with missing telldir/seekdir (for Android) (b8fb0a0)

Simon Marlow marlowsd at gmail.com
Wed Jan 30 12:04:15 CET 2013


Repository : ssh://darcs.haskell.org//srv/darcs/packages/unix

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/b8fb0a0a96de36ab088e29f816f89b4e9b52916f

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

commit b8fb0a0a96de36ab088e29f816f89b4e9b52916f
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Wed Jan 30 09:20:47 2013 +0000

    cope with missing telldir/seekdir (for Android)
    
    Submitted by: Nathan Hüsken <nathan.huesken at posteo.de>

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

 System/Posix/Directory.hsc            |    4 ++++
 System/Posix/Directory/ByteString.hsc |    4 ++++
 System/Posix/Directory/Common.hsc     |    8 ++++++++
 configure.ac                          |    2 ++
 4 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/System/Posix/Directory.hsc b/System/Posix/Directory.hsc
index 71a70ce..d0ef4c0 100644
--- a/System/Posix/Directory.hsc
+++ b/System/Posix/Directory.hsc
@@ -29,8 +29,12 @@ module System.Posix.Directory (
    rewindDirStream,   
    closeDirStream,
    DirStreamOffset,
+#ifdef HAVE_TELLDIR
    tellDirStream,
+#endif
+#ifdef HAVE_SEEKDIR
    seekDirStream,
+#endif
 
    -- * The working dirctory
    getWorkingDirectory,
diff --git a/System/Posix/Directory/ByteString.hsc b/System/Posix/Directory/ByteString.hsc
index 3ac642b..bb9100c 100644
--- a/System/Posix/Directory/ByteString.hsc
+++ b/System/Posix/Directory/ByteString.hsc
@@ -29,8 +29,12 @@ module System.Posix.Directory.ByteString (
    rewindDirStream,   
    closeDirStream,
    DirStreamOffset,
+#ifdef HAVE_TELLDIR
    tellDirStream,
+#endif
+#ifdef HAVE_SEEKDIR
    seekDirStream,
+#endif
 
    -- * The working dirctory
    getWorkingDirectory,
diff --git a/System/Posix/Directory/Common.hsc b/System/Posix/Directory/Common.hsc
index a608be3..7e2dfc6 100644
--- a/System/Posix/Directory/Common.hsc
+++ b/System/Posix/Directory/Common.hsc
@@ -22,8 +22,12 @@ module System.Posix.Directory.Common (
        DirStream(..), CDir, CDirent, DirStreamOffset(..),
        rewindDirStream,
        closeDirStream,
+#ifdef HAVE_SEEKDIR
        seekDirStream,
+#endif
+#ifdef HAVE_TELLDIR
        tellDirStream,
+#endif
        changeWorkingDirectoryFd,
   ) where
 
@@ -57,13 +61,16 @@ foreign import ccall unsafe "closedir"
 
 newtype DirStreamOffset = DirStreamOffset COff
 
+#ifdef HAVE_SEEKDIR
 seekDirStream :: DirStream -> DirStreamOffset -> IO ()
 seekDirStream (DirStream dirp) (DirStreamOffset off) =
   c_seekdir dirp off
 
 foreign import ccall unsafe "seekdir"
   c_seekdir :: Ptr CDir -> COff -> IO ()
+#endif
 
+#ifdef HAVE_TELLDIR
 tellDirStream :: DirStream -> IO DirStreamOffset
 tellDirStream (DirStream dirp) = do
   off <- c_telldir dirp
@@ -71,6 +78,7 @@ tellDirStream (DirStream dirp) = do
 
 foreign import ccall unsafe "telldir"
   c_telldir :: Ptr CDir -> IO COff
+#endif
 
 changeWorkingDirectoryFd :: Fd -> IO ()
 changeWorkingDirectoryFd (Fd fd) = 
diff --git a/configure.ac b/configure.ac
index 7528c3e..e1eb68c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,6 +33,8 @@ AC_CHECK_FUNCS([nanosleep])
 AC_CHECK_FUNCS([ptsname])
 AC_CHECK_FUNCS([setitimer])
 AC_CHECK_FUNCS([readdir_r])
+dnl not available on android so check for it
+AC_CHECK_FUNCS([telldir seekdir])
 
 AC_CHECK_MEMBERS([struct stat.st_atim])
 AC_CHECK_MEMBERS([struct stat.st_mtim])





More information about the ghc-commits mailing list