summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--generic/tcl.decls6
-rw-r--r--generic/tclInt.decls4
-rw-r--r--unix/tclUnixInit.c71
4 files changed, 79 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index c91a822..0bb1715 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-25 Jan Nijtmans <nijtmans@users.sf.net>
* win/tclWinDde.c: [Bug 473946]: special characters not correctly sent,
diff --git a/generic/tcl.decls b/generic/tcl.decls
index db9950c..d4651c6 100644
--- a/generic/tcl.decls
+++ b/generic/tcl.decls
@@ -1822,12 +1822,12 @@ declare 1 win {
# Mac declarations
# This is needed by the shells to handle Macintosh events.
-
+
declare 0 mac {
void Tcl_MacSetEventProc(Tcl_MacConvertEventPtr procPtr)
}
-# These routines are useful for handling using scripts from resources
+# These routines are useful for handling using scripts from resources
# in the application shell
declare 1 mac {
@@ -1859,7 +1859,7 @@ declare 6 mac {
# These are not in MSL 2.1.2, so we need to export them from the
# Tcl shared library. They are found in the compat directory.
-
+
declare 7 mac {
int strncasecmp(const char *s1, const char *s2, size_t n)
}
diff --git a/generic/tclInt.decls b/generic/tclInt.decls
index d714e85..1366fc3 100644
--- a/generic/tclInt.decls
+++ b/generic/tclInt.decls
@@ -799,10 +799,10 @@ declare 19 mac {
declare 20 mac {
int TclMacRegisterResourceFork(short fileRef, Tcl_Obj *tokenPtr,
int insert)
-}
+}
declare 21 mac {
short TclMacUnRegisterResourceFork(char *tokenPtr, Tcl_Obj *resultPtr)
-}
+}
declare 22 mac {
int TclMacCreateEnv(void)
}
diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c
index 46ef042..5de9e48 100644
--- a/unix/tclUnixInit.c
+++ b/unix/tclUnixInit.c
@@ -34,6 +34,51 @@
# 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
+
+
/*
* The Init script (common to Windows and Unix platforms) is
* defined in tkInitScript.h
@@ -774,7 +819,11 @@ void
TclpSetVariables(interp)
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;
@@ -876,7 +925,25 @@ TclpSetVariables(interp)
Tcl_SetVar2(interp, "tcl_platform", "platform", "unix", TCL_GLOBAL_ONLY);
#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;