[project @ 2005-01-01 23:59:58 by krasimir]
[ghc-base.git] / include / HsBase.h
index 289f9b5..b5d5fdb 100644 (file)
 #include <fcntl.h>
 #include "timeUtils.h"
 #include <shlobj.h>
+#include <share.h>
 #endif
 
 #if HAVE_SYS_SELECT_H
@@ -693,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));
 }
@@ -731,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 +