From 691b6fb869f4d8d64da25f768589eb0eebb65634 Mon Sep 17 00:00:00 2001 From: usa Date: Thu, 15 Feb 2007 11:50:28 +0000 Subject: [PATCH] * win32/win32.c (get_pioinfo_extra): new function for VC++8 SP1 workaround. [ruby-core:10259] * win32/win32.c (NtInitialize): call above function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ win32/Makefile.sub | 2 +- win32/win32.c | 52 +++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1d16fff85b..2c729eaed7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Thu Feb 15 20:48:36 2007 NAKAMURA Usaku + + * win32/win32.c (get_pioinfo_extra): new function for VC++8 SP1 + workaround. [ruby-core:10259] + + * win32/win32.c (NtInitialize): call above function. + Thu Feb 15 16:25:54 2007 Akinori MUSHA * lib/uri/generic.rb (URI::Generic::userinfo): Considering how diff --git a/win32/Makefile.sub b/win32/Makefile.sub index a7f13e3df4..4c90898788 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -143,7 +143,7 @@ RFLAGS = -r !if !defined(EXTLIBS) EXTLIBS = !endif -LIBS = oldnames.lib user32.lib advapi32.lib shell32.lib ws2_32.lib $(EXTLIBS) +LIBS = oldnames.lib user32.lib advapi32.lib shell32.lib version.lib ws2_32.lib $(EXTLIBS) MISSING = acosh.obj crypt.obj erf.obj win32.obj ARFLAGS = -machine:$(MACHINE) -out: diff --git a/win32/win32.c b/win32/win32.c index c4aabf62b7..827af77b59 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -451,7 +451,10 @@ NtInitialize(int *argc, char ***argv) int ret; #if _MSC_VER >= 1400 + static void set_pioinfo_extra(void); + _set_invalid_parameter_handler(invalid_parameter); + set_pioinfo_extra(); #endif // @@ -1669,9 +1672,56 @@ typedef struct { #if !defined(__BORLANDC__) && !defined(_WIN32_WCE) EXTERN_C _CRTIMP ioinfo * __pioinfo[]; +#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; + + size = GetFileVersionInfoSize(libpath, &dummy); + if (size == 0) + return; + buf = malloc(size); + if (!GetFileVersionInfo(libpath, 0, size, buf) || + !VerQueryValue(buf, "\\", &pffi, &dummy)) { + free(buf); + return; + } + major = HIWORD(pffi->dwFileVersionMS); + minor = LOWORD(pffi->dwFileVersionMS); + teeny = HIWORD(pffi->dwFileVersionLS); + build = LOWORD(pffi->dwFileVersionLS); + free(buf); + + if (major == 8 && minor == 0 && + (teeny > 50727 || (teeny == 50727 && build >= 762))) { + pioinfo_extra = 16; + } +} +#else +#define pioinfo_extra 0 +#endif + #define IOINFO_L2E 5 #define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E) -#define _pioinfo(i) (__pioinfo[i >> IOINFO_L2E] + (i & (IOINFO_ARRAY_ELTS - 1))) +#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)