diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | win32/win32.c | 56 |
2 files changed, 22 insertions, 40 deletions
@@ -1,3 +1,7 @@ +Fri Feb 23 15:05:57 2007 NAKAMURA Usaku <usa@ruby-lang.org> + + * win32/win32.c (set_pioinfo_extra): simplified. + Fri Feb 23 14:23:20 2007 Minero Aoki <aamine@loveruby.net> * test/ruby/test_literal.rb: new test. @@ -146,7 +150,7 @@ Fri Feb 16 11:18:21 2007 Eric Hodel <drbrain@segment7.net> Thu Feb 15 20:48:36 2007 NAKAMURA Usaku <usa@ruby-lang.org> - * win32/win32.c (get_pioinfo_extra): new function for VC++8 SP1 + * win32/win32.c (set_pioinfo_extra): new function for VC++8 SP1 workaround. [ruby-core:10259] * win32/win32.c (NtInitialize): call above function. diff --git a/win32/win32.c b/win32/win32.c index 0554c4206d..f9816c30e5 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1672,60 +1672,38 @@ typedef struct { #if !defined(__BORLANDC__) && !defined(_WIN32_WCE) EXTERN_C _CRTIMP ioinfo * __pioinfo[]; +#define IOINFO_L2E 5 +#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E) +#define _pioinfo(i) ((ioinfo*)((char*)(__pioinfo[i >> IOINFO_L2E]) + (i & (IOINFO_ARRAY_ELTS - 1)) * (sizeof(ioinfo) + pioinfo_extra))) +#define _osfhnd(i) (_pioinfo(i)->osfhnd) +#define _osfile(i) (_pioinfo(i)->osfile) +#define _pipech(i) (_pioinfo(i)->pipech) + #if _MSC_VER >= 1400 static size_t pioinfo_extra = 0; /* workaround for VC++8 SP1 */ static void set_pioinfo_extra(void) { - char libpath[MAXPATHLEN+1]; - HMODULE msvcrt = NULL; - MEMORY_BASIC_INFORMATION m; - DWORD dummy; - DWORD size; - void *buf; - VS_FIXEDFILEINFO *pffi; - int major, minor, teeny, build; - - memset(&m, 0, sizeof(m)); - if (VirtualQuery(stdin, &m, sizeof(m)) && m.State == MEM_COMMIT) - msvcrt = (HMODULE)m.AllocationBase; - if (!msvcrt) - return; - if (!GetModuleFileName(msvcrt, libpath, sizeof(libpath))) - return; + int fd; - size = GetFileVersionInfoSize(libpath, &dummy); - if (size == 0) - return; - buf = malloc(size); - if (!GetFileVersionInfo(libpath, 0, size, buf) || - !VerQueryValue(buf, "\\", &pffi, &dummy)) { - free(buf); - return; + fd = open("NUL", O_RDONLY); + for (pioinfo_extra = 0; pioinfo_extra <= 64; pioinfo_extra += sizeof(void *)) { + if (_osfhnd(fd) == _get_osfhandle(fd)) { + break; + } } - major = HIWORD(pffi->dwFileVersionMS); - minor = LOWORD(pffi->dwFileVersionMS); - teeny = HIWORD(pffi->dwFileVersionLS); - build = LOWORD(pffi->dwFileVersionLS); - free(buf); + close(fd); - if (major == 8 && minor == 0 && - (teeny > 50727 || (teeny == 50727 && build >= 762))) { - pioinfo_extra = 16; + if (pioinfo_extra > 64) { + /* not found, maybe something wrong... */ + pioinfo_extra = 0; } } #else #define pioinfo_extra 0 #endif -#define IOINFO_L2E 5 -#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E) -#define _pioinfo(i) ((ioinfo*)((char*)(__pioinfo[i >> IOINFO_L2E]) + (i & (IOINFO_ARRAY_ELTS - 1)) * (sizeof(ioinfo) + pioinfo_extra))) -#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)) |