#include "timeUtils.h"
#endif
-/* in ghc_errno.c */
-int *ghcErrno(void);
-
/* in system.c */
HsInt systemCmd(HsAddr cmd);
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;
#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); }
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);
}
#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
return 0;
#else
return ENOENT;
-#endif
+#endif
}
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
INLINE int __hsposix_SIG_SETMASK() { return SIG_SETMASK; }
#endif /* mingw32_TARGET_OS */
+// These 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));
+}
+
+INLINE int __hscore_stat(char *file, struct stat *buf) {
+ return (stat(file,buf));
+}
+
+INLINE int __hscore_fstat(int fd, struct stat *buf) {
+ return (fstat(fd,buf));
+}
+
#endif /* __HSBASE_H__ */