summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-06-06 13:02:04 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-06-06 13:02:04 (GMT)
commit37642292deb9342c75edf60536fb15b4aa3c13db (patch)
tree46a5d0a2c7c630b7a1bf5fbe8468b83a5f4985d5
parent12ef999bc6349fb7ea9cc20b1940422a4533424f (diff)
parenteaf04cc2de0d346f1b108812475f1c27fc33c74d (diff)
downloadtcl-37642292deb9342c75edf60536fb15b4aa3c13db.zip
tcl-37642292deb9342c75edf60536fb15b4aa3c13db.tar.gz
tcl-37642292deb9342c75edf60536fb15b4aa3c13db.tar.bz2
On Cygwin, use win32 API in stead of uname() to determine the tcl_platform variables
-rw-r--r--ChangeLog5
-rw-r--r--unix/tclUnixInit.c71
2 files changed, 74 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index c70acbb..1fee643 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-06-06 Jan Nijtmans <nijtmans@users.sf.net>
+
+ * unix/tclUnixInit.c: On Cygwin, use win32 API in stead of uname()
+ to determine the tcl_platform variables.
+
2012-05-31 Donal K. Fellows <dkf@users.sf.net>
* doc/safe.n: [Bug 1997845]: Corrected formatting so that generated
diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c
index 5111746..f9015b7 100644
--- a/unix/tclUnixInit.c
+++ b/unix/tclUnixInit.c
@@ -31,6 +31,51 @@
# include <dlfcn.h>
# endif
#endif
+
+#ifdef __CYGWIN__
+DLLIMPORT extern __stdcall unsigned char GetVersionExA(void *);
+DLLIMPORT extern __stdcall void GetSystemInfo(void *);
+
+#define NUMPLATFORMS 4
+static const char *const platforms[NUMPLATFORMS] = {
+ "Win32s", "Windows 95", "Windows NT", "Windows CE"
+};
+
+#define NUMPROCESSORS 11
+static const char *const processors[NUMPROCESSORS] = {
+ "intel", "mips", "alpha", "ppc", "shx", "arm", "ia64", "alpha64", "msil",
+ "amd64", "ia32_on_win64"
+};
+
+typedef struct _SYSTEM_INFO {
+ union {
+ DWORD dwOemId;
+ struct {
+ int wProcessorArchitecture;
+ int wReserved;
+ };
+ };
+ DWORD dwPageSize;
+ void *lpMinimumApplicationAddress;
+ void *lpMaximumApplicationAddress;
+ void *dwActiveProcessorMask;
+ DWORD dwNumberOfProcessors;
+ DWORD dwProcessorType;
+ DWORD dwAllocationGranularity;
+ int wProcessorLevel;
+ int wProcessorRevision;
+} SYSTEM_INFO;
+
+typedef struct _OSVERSIONINFOA {
+ DWORD dwOSVersionInfoSize;
+ DWORD dwMajorVersion;
+ DWORD dwMinorVersion;
+ DWORD dwBuildNumber;
+ DWORD dwPlatformId;
+ char szCSDVersion[128];
+} OSVERSIONINFOA;
+#endif
+
#ifdef HAVE_COREFOUNDATION
#include <CoreFoundation/CoreFoundation.h>
#endif
@@ -764,7 +809,11 @@ void
TclpSetVariables(
Tcl_Interp *interp)
{
-#ifndef NO_UNAME
+#ifdef __CYGWIN__
+ SYSTEM_INFO sysInfo;
+ OSVERSIONINFOA osInfo;
+ char buffer[TCL_INTEGER_SPACE * 2];
+#elif !defined(NO_UNAME)
struct utsname name;
#endif
int unameOK;
@@ -873,7 +922,25 @@ TclpSetVariables(
#endif
unameOK = 0;
-#ifndef NO_UNAME
+#ifdef __CYGWIN__
+ unameOK = 1;
+ osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
+ GetVersionExA(&osInfo);
+ GetSystemInfo(&sysInfo);
+
+ if (osInfo.dwPlatformId < NUMPLATFORMS) {
+ Tcl_SetVar2(interp, "tcl_platform", "os",
+ platforms[osInfo.dwPlatformId], TCL_GLOBAL_ONLY);
+ }
+ sprintf(buffer, "%d.%d", osInfo.dwMajorVersion, osInfo.dwMinorVersion);
+ Tcl_SetVar2(interp, "tcl_platform", "osVersion", buffer, TCL_GLOBAL_ONLY);
+ if (sysInfo.wProcessorArchitecture < NUMPROCESSORS) {
+ Tcl_SetVar2(interp, "tcl_platform", "machine",
+ processors[sysInfo.wProcessorArchitecture],
+ TCL_GLOBAL_ONLY);
+ }
+
+#elif !defined NO_UNAME
if (uname(&name) >= 0) {
CONST char *native;