summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorH_Konishi <H_Konishi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-06-14 12:21:50 +0000
committerH_Konishi <H_Konishi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-06-14 12:21:50 +0000
commit42c59aa31785793dd365c70bac10d807c0329a34 (patch)
tree7649110a6384fd9530b75d93c2c9e323c10c5841 /win32
parent9e1473541d906808d31671bf0dc614f361c843df (diff)
*bcc32 fix for win9x.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c39
1 files changed, 11 insertions, 28 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 81ce8b6..24699be 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -1323,7 +1323,7 @@ EXTERN_C void __cdecl _lock_fhandle(int);
EXTERN_C void __cdecl _unlock_fhandle(int);
EXTERN_C void __cdecl _unlock(int);
-#if defined _MT || defined __MSVCRT__
+#if (defined _MT || defined __MSVCRT__) && !defined __BORLANDC__
#define MSVCRT_THREADS
#endif
#ifdef MSVCRT_THREADS
@@ -1360,6 +1360,15 @@ EXTERN_C _CRTIMP ioinfo * __pioinfo[];
#define _osfhnd(i) (_pioinfo(i)->osfhnd)
#define _osfile(i) (_pioinfo(i)->osfile)
#define _pipech(i) (_pioinfo(i)->pipech)
+
+#define _set_osfhnd(fh, osfh) (void)(_osfhnd(fh) = osfh)
+#define _set_osflags(fh, flags) (_osfile(fh) = (flags))
+
+#else
+
+#define _set_osfhnd(fh, osfh) (void)((fh), (osfh))
+#define _set_osflags(fh, flags) (void)((fh), (flags))
+
#endif
#define FOPEN 0x01 /* file handle open */
@@ -1368,8 +1377,6 @@ EXTERN_C _CRTIMP ioinfo * __pioinfo[];
#define FDEV 0x40 /* file handle refers to device */
#define FTEXT 0x80 /* file handle is in text mode */
-#define _set_osfhnd(fh, osfh) (void)(_osfhnd(fh) = osfh)
-
static int
rb_w32_open_osfhandle(long osfhandle, int flags)
{
@@ -1388,29 +1395,6 @@ rb_w32_open_osfhandle(long osfhandle, int flags)
if (flags & O_NOINHERIT)
fileflags |= FNOINHERIT;
-#ifdef __BORLANDC__
- {
- /* attempt to allocate a C Runtime file handle */
- HANDLE hF = CreateFile("NUL", 0, 0, NULL, OPEN_ALWAYS, 0, NULL);
- fh = _open_osfhandle((long)hF, 0);
- CloseHandle(hF);
- if (fh == -1) {
- errno = EMFILE; /* too many open files */
- _doserrno = 0L; /* not an OS error */
- }
- else {
-
- MTHREAD_ONLY(EnterCriticalSection(&(_pioinfo(fh)->lock)));
- /* the file is open. now, set the info in _osfhnd array */
- //_set_osfhnd(fh, osfhandle);
-
- fileflags |= FOPEN; /* mark as open */
-
- //_osfile(fh) = fileflags; /* set osfile entry */
- MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fh)->lock));
- }
- }
-#else
RUBY_CRITICAL({
/* attempt to allocate a C Runtime file handle */
HANDLE hF = CreateFile("NUL", 0, 0, NULL, OPEN_ALWAYS, 0, NULL);
@@ -1428,11 +1412,10 @@ rb_w32_open_osfhandle(long osfhandle, int flags)
fileflags |= FOPEN; /* mark as open */
- _osfile(fh) = fileflags; /* set osfile entry */
+ _set_osflags(fh, fileflags); /* set osfile entry */
MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fh)->lock));
}
});
-#endif
return fh; /* return handle */
}