[project @ 2004-02-17 11:22:22 by simonmar]
authorsimonmar <unknown>
Tue, 17 Feb 2004 11:22:23 +0000 (11:22 +0000)
committersimonmar <unknown>
Tue, 17 Feb 2004 11:22:23 +0000 (11:22 +0000)
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
include/HsBase.h

index 5a1df90..4a91d58 100644 (file)
@@ -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
                     
index a63c087..33f44f4 100644 (file)
@@ -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__ */