From 1de80964b5604669a07fa710f5cf67093d1f8c75 Mon Sep 17 00:00:00 2001 From: simonmar Date: Tue, 17 Feb 2004 11:22:23 +0000 Subject: [PATCH] [project @ 2004-02-17 11:22:22 by simonmar] Use C wrappers for lseek() and open(). On Linux, these functions are macro'd to different versions when large file support is on, so to make the libraries compilable with the NCG we need to use C wrappers for these functions. --- System/Posix/Internals.hs | 7 ++----- include/HsBase.h | 12 ++++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/System/Posix/Internals.hs b/System/Posix/Internals.hs index 5a1df90..4a91d58 100644 --- a/System/Posix/Internals.hs +++ b/System/Posix/Internals.hs @@ -350,13 +350,13 @@ foreign import ccall unsafe "HsBase.h getcwd" foreign import ccall unsafe "HsBase.h isatty" c_isatty :: CInt -> IO CInt -foreign import ccall unsafe "HsBase.h lseek" +foreign import ccall unsafe "HsBase.h __hscore_lseek" c_lseek :: CInt -> COff -> CInt -> IO COff foreign import ccall unsafe "HsBase.h __hscore_lstat" lstat :: CString -> Ptr CStat -> IO CInt -foreign import ccall unsafe "HsBase.h open" +foreign import ccall unsafe "HsBase.h __hscore_open" c_open :: CString -> CInt -> CMode -> IO CInt foreign import ccall unsafe "HsBase.h opendir" @@ -368,9 +368,6 @@ foreign import ccall unsafe "HsBase.h __hscore_mkdir" foreign import ccall unsafe "HsBase.h read" c_read :: CInt -> Ptr CChar -> CSize -> IO CSsize -foreign import ccall unsafe "HsBase.h readdir" - c_readdir :: Ptr CDir -> IO (Ptr CDirent) - foreign import ccall unsafe "dirUtils.h __hscore_renameFile" c_rename :: CString -> CString -> IO CInt diff --git a/include/HsBase.h b/include/HsBase.h index a63c087..33f44f4 100644 --- a/include/HsBase.h +++ b/include/HsBase.h @@ -675,5 +675,17 @@ INLINE int __hsposix_SIG_UNBLOCK() { return SIG_UNBLOCK; } INLINE int __hsposix_SIG_SETMASK() { return SIG_SETMASK; } #endif /* mingw32_TARGET_OS */ +// These two are wrapped because on some OSs (eg. Linux) they are +// macros which redirect to the 64-bit-off_t versions when large file +// support is enabled. +// +INLINE int __hscore_open(char *file, int how, mode_t mode) { + return (open(file,how,mode)); +} + +INLINE off_t __hscore_lseek(int fd, off_t off, int whence) { + return (lseek(fd,off,whence)); +} + #endif /* __HSBASE_H__ */ -- 1.7.10.4