[project @ 2004-02-17 11:22:22 by simonmar]
[haskell-directory.git] / include / HsBase.h
index 960aedd..33f44f4 100644 (file)
 #include "timeUtils.h"
 #endif
 
-/* in ghc_errno.c */
-int *ghcErrno(void);
-
 /* in system.c */
 HsInt systemCmd(HsAddr cmd);
 
@@ -131,7 +128,7 @@ HsInt rawSystem(HsAddr cmd, HsAddr args);
 int inputReady(int fd, int msecs, int isSock);
 
 /* in writeError.c */
-void writeErrString__(HsAddr msg_hdr, HsAddr msg, HsInt len);
+void writeErrString__(HsAddr msg, HsInt len);
 
 /* in Signals.c */
 extern HsInt nocldstop;
@@ -201,11 +198,16 @@ StgWord64 stg_integerToWord64 (StgInt sa, StgByteArray /* Really: mp_limb_t* */
 #ifndef INLINE
 # if defined(_MSC_VER)
 #  define INLINE extern __inline
+# elif defined(__HUGS__)
+#  define INLINE INLINE_ONLY
 # else
 #  define INLINE extern inline
 # endif
 #endif
 
+INLINE int __hscore_get_errno(void) { return errno; }
+INLINE void __hscore_set_errno(int e) { errno = e; }
+
 #if !defined(_MSC_VER)
 INLINE int __hscore_s_isreg(m)  { return S_ISREG(m);  }
 INLINE int __hscore_s_isdir(m)  { return S_ISDIR(m);  }
@@ -388,30 +390,18 @@ __hscore_setmode( HsInt fd, HsBool toBin )
   return setmode(fd,(toBin == HS_BOOL_TRUE) ? _O_BINARY : _O_TEXT);
 #else
   return 0;
-#endif  
+#endif
 }
 
 INLINE HsInt
-__hscore_PrelHandle_write( HsInt fd, HsBool isSock, HsAddr ptr, 
-                          HsInt off, int sz )
+__hscore_PrelHandle_write( HsInt fd, HsAddr ptr, HsInt off, int sz )
 {
-#if defined(mingw32_TARGET_OS) || defined(_MSC_VER)
-  if (isSock) {
-    return send(fd,(char *)ptr + off, sz, 0);
-  }
-#endif
   return write(fd,(char *)ptr + off, sz);
 }
 
 INLINE HsInt
-__hscore_PrelHandle_read( HsInt fd, HsBool isSock, HsAddr ptr, 
-                         HsInt off, int sz )
+__hscore_PrelHandle_read( HsInt fd, HsAddr ptr, HsInt off, int sz )
 {
-#if defined(mingw32_TARGET_OS) || defined(_MSC_VER)
-  if (isSock) {
-    return recv(fd,(char *)ptr + off, sz, 0);
-  }
-#endif
   return read(fd,(char *)ptr + off, sz);
 
 }
@@ -477,7 +467,7 @@ INLINE mode_t __hscore_S_IXUSR() { return S_IXUSR; }
 #if !defined(_MSC_VER)
 INLINE HsAddr
 __hscore_d_name( struct dirent* d )
-{ 
+{
 #if !defined(mingw32_TARGET_OS) && !defined(_MSC_VER)
   return (HsAddr)(&d->d_name);
 #else
@@ -493,7 +483,7 @@ __hscore_end_of_dir( void )
   return 0;
 #else
   return ENOENT;
-#endif  
+#endif
 }
 
 INLINE void
@@ -523,7 +513,7 @@ INLINE void
 __hscore_poke_lflag( struct termios* ts, tcflag_t t ) { ts->c_lflag = t; }
 
 INLINE unsigned char*
-__hscore_ptr_c_cc( struct termios* ts ) 
+__hscore_ptr_c_cc( struct termios* ts )
 { return (unsigned char*) &ts->c_cc; }
 
 INLINE HsInt
@@ -685,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__ */