diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2014-05-02 07:15:49 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2014-05-02 07:15:49 (GMT) |
| commit | e338d72a45468bad9139adc4d43a4167d4e244c6 (patch) | |
| tree | 870a6a99179fa39483426248efdf8be62fc04f2e /unix/tclUnixInit.c | |
| parent | b9c49065a55f1a7ddbda005962a9d0847045c274 (diff) | |
| parent | ccc37a91935f90ede0be48b9a71b93f54267e608 (diff) | |
| download | tcl-e338d72a45468bad9139adc4d43a4167d4e244c6.zip tcl-e338d72a45468bad9139adc4d43a4167d4e244c6.tar.gz tcl-e338d72a45468bad9139adc4d43a4167d4e244c6.tar.bz2 | |
merge novem
Diffstat (limited to 'unix/tclUnixInit.c')
| -rw-r--r-- | unix/tclUnixInit.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c index 1d81310..881ea23 100644 --- a/unix/tclUnixInit.c +++ b/unix/tclUnixInit.c @@ -33,7 +33,10 @@ #endif #ifdef __CYGWIN__ -DLLIMPORT extern __stdcall unsigned char GetVersionExA(void *); +DLLIMPORT extern __stdcall unsigned char GetVersionExW(void *); +DLLIMPORT extern __stdcall void *LoadLibraryW(const void *); +DLLIMPORT extern __stdcall void FreeLibrary(void *); +DLLIMPORT extern __stdcall void *GetProcAddress(void *, const char *); DLLIMPORT extern __stdcall void GetSystemInfo(void *); #define NUMPLATFORMS 4 @@ -72,8 +75,8 @@ typedef struct { DWORD dwMinorVersion; DWORD dwBuildNumber; DWORD dwPlatformId; - char szCSDVersion[128]; -} OSVERSIONINFOA; + wchar_t szCSDVersion[128]; +} OSVERSIONINFOW; #endif #ifdef HAVE_COREFOUNDATION @@ -748,7 +751,8 @@ TclpSetVariables( { #ifdef __CYGWIN__ SYSTEM_INFO sysInfo; - OSVERSIONINFOA osInfo; + static OSVERSIONINFOW osInfo; + static int osInfoInitialized = 0; char buffer[TCL_INTEGER_SPACE * 2]; #elif !defined(NO_UNAME) struct utsname name; @@ -861,8 +865,20 @@ TclpSetVariables( unameOK = 0; #ifdef __CYGWIN__ unameOK = 1; - osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA); - GetVersionExA(&osInfo); + if (!osInfoInitialized) { + HANDLE handle = LoadLibraryW(L"NTDLL"); + int(__stdcall *getversion)(void *) = + (int(__stdcall *)(void *))GetProcAddress(handle, "RtlGetVersion"); + osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW); + if (!getversion || getversion(&osInfo)) { + GetVersionExW(&osInfo); + } + if (handle) { + FreeLibrary(handle); + } + osInfoInitialized = 1; + } + GetSystemInfo(&sysInfo); if (osInfo.dwPlatformId < NUMPLATFORMS) { |
