From 4f965cff3c2ccd69b0ed0ab33635add02f16077f Mon Sep 17 00:00:00 2001 From: H_Konishi Date: Fri, 14 Jun 2002 12:21:50 +0000 Subject: *bcc32 fix for win9x. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@2570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- win32/win32.c | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) (limited to 'win32') diff --git a/win32/win32.c b/win32/win32.c index 81ce8b6ba..24699be9c 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 */ } -- cgit