[project @ 2005-01-01 23:59:58 by krasimir]
[ghc-base.git] / include / HsBase.h
index 74f20f7..b5d5fdb 100644 (file)
 #include <fcntl.h>
 #include "timeUtils.h"
 #include <shlobj.h>
+#include <share.h>
 #endif
 
 #if HAVE_SYS_SELECT_H
@@ -494,11 +495,7 @@ INLINE mode_t __hscore_S_IXUSR() { return S_IXUSR; }
 INLINE HsAddr
 __hscore_d_name( struct dirent* d )
 {
-#if defined(STRUCT_DIRENT_FLAT_LAYOUT)
-  return (HsAddr)(&d->d_name);
-#else
   return (HsAddr)(d->d_name);
-#endif
 }
 
 INLINE HsInt
@@ -697,14 +694,21 @@ INLINE int __hsposix_SIG_SETMASK() { return SIG_SETMASK; }
 
 #endif /* mingw32_TARGET_OS */
 
+INLINE int __hscore_open(char *file, int how, mode_t mode) {
+#ifdef mingw32_TARGET_OS
+       if ((how & O_WRONLY) || (how & O_RDWR) || (how & O_APPEND))
+         return _sopen(file,how,_SH_DENYRW,mode);
+       else
+         return _sopen(file,how,_SH_DENYWR,mode);
+#else
+       return open(file,how,mode);
+#endif
+}
+
 // 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));
 }
@@ -735,7 +739,7 @@ extern void hsFD_ZERO(fd_set *fds);
 INLINE HsInt sizeofTimeVal(void) { return sizeof(struct timeval); }
 
 INLINE HsInt getTicksOfDay(void)
-{  
+{
     struct timeval tv;
     gettimeofday(&tv, (struct timezone *) NULL);
     return (tv.tv_sec * TICK_FREQ +