summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authornijtmans <nijtmans>2010-01-31 23:51:36 (GMT)
committernijtmans <nijtmans>2010-01-31 23:51:36 (GMT)
commit000ce914c4d1f4b493568ce10baa2341bc73b510 (patch)
tree012d77fe11409a3025fcb54cc6c78d69b36f953a /win
parenta98a5188b672f397d17abf6e04182566e1d7a7bb (diff)
downloadtcl-000ce914c4d1f4b493568ce10baa2341bc73b510.zip
tcl-000ce914c4d1f4b493568ce10baa2341bc73b510.tar.gz
tcl-000ce914c4d1f4b493568ce10baa2341bc73b510.tar.bz2
Various CYGWIN-related fixes
backported from HEAD. Still configure script not modified, so CYGWIN build is still disabled. Reason: although the build succeeds with those changes, many tests still fail.
Diffstat (limited to 'win')
-rw-r--r--win/.cvsignore42
-rw-r--r--win/cat.c10
-rw-r--r--win/tclWinDde.c3
-rw-r--r--win/tclWinError.c6
-rw-r--r--win/tclWinFile.c32
-rw-r--r--win/tclWinPipe.c12
-rw-r--r--win/tclWinPort.h45
-rw-r--r--win/tclWinReg.c31
-rw-r--r--win/tclWinSerial.c18
-rw-r--r--win/tclWinSock.c6
-rw-r--r--win/tclWinTest.c4
-rw-r--r--win/tclWinThrd.c28
12 files changed, 128 insertions, 109 deletions
diff --git a/win/.cvsignore b/win/.cvsignore
index 72c5007..1ebb703 100644
--- a/win/.cvsignore
+++ b/win/.cvsignore
@@ -1,18 +1,24 @@
-Debug
-Release
-*.opt
-*.ncb
-*.plg
-*.00?
-*.o
-*.obj
-*.i
-*.asm
-*.dll
-*.exe
-Makefile
-tcl.hpj
-tclConfig.sh
-.#*
-tcl.sln
-tcl.suo
+Debug
+Release
+*.opt
+*.ncb
+*.plg
+*.00?
+*.o
+*.obj
+*.i
+*.asm
+*.dll
+*.exe
+Makefile
+tcl.hpj
+tclConfig.sh
+.#*
+tcl.sln
+tcl.suo
+autom4te.cache
+config.status
+*.a
+*.lib
+*.exp
+*.res
diff --git a/win/cat.c b/win/cat.c
index 91c38f4..4804466 100644
--- a/win/cat.c
+++ b/win/cat.c
@@ -8,11 +8,15 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: cat.c,v 1.3 2005/11/04 00:06:49 dkf Exp $
+ * RCS: @(#) $Id: cat.c,v 1.3.10.1 2010/01/31 23:51:37 nijtmans Exp $
*/
#include <stdio.h>
-#include <io.h>
+#ifdef __CYGWIN__
+# include <unistd.h>
+#else
+# include <io.h>
+#endif
#include <string.h>
int
@@ -20,7 +24,7 @@ main(void)
{
char buf[1024];
int n;
- char *err;
+ const char *err;
while (1) {
n = read(0, buf, sizeof(buf));
diff --git a/win/tclWinDde.c b/win/tclWinDde.c
index bcd086e..46e0e55 100644
--- a/win/tclWinDde.c
+++ b/win/tclWinDde.c
@@ -9,13 +9,12 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinDde.c,v 1.31 2006/09/26 00:05:03 patthoyts Exp $
+ * RCS: @(#) $Id: tclWinDde.c,v 1.31.8.1 2010/01/31 23:51:37 nijtmans Exp $
*/
#include "tclInt.h"
#include <dde.h>
#include <ddeml.h>
-#include <tchar.h>
/*
* TCL_STORAGE_CLASS is set unconditionally to DLLEXPORT because the Dde_Init
diff --git a/win/tclWinError.c b/win/tclWinError.c
index 05661a2..7cf0ca4 100644
--- a/win/tclWinError.c
+++ b/win/tclWinError.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinError.c,v 1.7 2005/11/04 00:06:50 dkf Exp $
+ * RCS: @(#) $Id: tclWinError.c,v 1.7.10.1 2010/01/31 23:51:37 nijtmans Exp $
*/
#include "tclInt.h"
@@ -354,7 +354,7 @@ static int wsaErrorTable[] = {
void
TclWinConvertError(
- DWORD errCode) /* Win32 error code. */
+ unsigned long errCode) /* Win32 error code. */
{
if (errCode >= tableLen) {
Tcl_SetErrno(EINVAL);
@@ -381,7 +381,7 @@ TclWinConvertError(
void
TclWinConvertWSAError(
- DWORD errCode) /* Win32 error code. */
+ unsigned long errCode) /* Win32 error code. */
{
if ((errCode >= WSAEWOULDBLOCK) && (errCode <= WSAEREMOTE)) {
Tcl_SetErrno(wsaErrorTable[errCode - WSAEWOULDBLOCK]);
diff --git a/win/tclWinFile.c b/win/tclWinFile.c
index 6e6b713..7399e22 100644
--- a/win/tclWinFile.c
+++ b/win/tclWinFile.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinFile.c,v 1.95.2.2 2009/03/18 17:13:45 dgp Exp $
+ * RCS: @(#) $Id: tclWinFile.c,v 1.95.2.3 2010/01/31 23:51:37 nijtmans Exp $
*/
/* #define _WIN32_WINNT 0x0500 */
@@ -226,7 +226,7 @@ WinLink(
{
WCHAR tempFileName[MAX_PATH];
TCHAR *tempFilePart;
- int attr;
+ DWORD attr;
/*
* Get the full path referenced by the target.
@@ -247,7 +247,7 @@ WinLink(
*/
attr = (*tclWinProcs->getFileAttributesProc)(linkSourcePath);
- if (attr != 0xffffffff) {
+ if (attr != INVALID_FILE_ATTRIBUTES) {
Tcl_SetErrno(EEXIST);
return -1;
}
@@ -271,7 +271,7 @@ WinLink(
*/
attr = (*tclWinProcs->getFileAttributesProc)(linkTargetPath);
- if (attr == 0xffffffff) {
+ if (attr == INVALID_FILE_ATTRIBUTES) {
/*
* The target doesn't exist.
*/
@@ -347,7 +347,7 @@ WinReadLink(
{
WCHAR tempFileName[MAX_PATH];
TCHAR *tempFilePart;
- int attr;
+ DWORD attr;
/*
* Get the full path referenced by the target.
@@ -368,7 +368,7 @@ WinReadLink(
*/
attr = (*tclWinProcs->getFileAttributesProc)(linkSourcePath);
- if (attr == 0xffffffff) {
+ if (attr == INVALID_FILE_ATTRIBUTES) {
/*
* The source doesn't exist.
*/
@@ -1262,8 +1262,8 @@ WinIsReserved(
}
}
- } else if (!stricmp(path, "prn") || !stricmp(path, "nul")
- || !stricmp(path, "aux")) {
+ } else if (!strcasecmp(path, "prn") || !strcasecmp(path, "nul")
+ || !strcasecmp(path, "aux")) {
/*
* Have match for 'prn', 'nul' or 'aux'.
*/
@@ -1627,7 +1627,7 @@ NativeAccess(
}
/*
- * Now size contains the size of buffer needed
+ * Now size contains the size of buffer needed.
*/
sdPtr = (SECURITY_DESCRIPTOR *) HeapAlloc(GetProcessHeap(), 0, size);
@@ -1637,7 +1637,7 @@ NativeAccess(
}
/*
- * Call GetFileSecurity() for real
+ * Call GetFileSecurity() for real.
*/
if (!(*tclWinProcs->getFileSecurityProc)(nativePath,
@@ -1776,9 +1776,9 @@ NativeIsExec(
* Use wide-char case-insensitive comparison
*/
- if ((_wcsicmp(path+len-3, L"exe") == 0)
- || (_wcsicmp(path+len-3, L"com") == 0)
- || (_wcsicmp(path+len-3, L"bat") == 0)) {
+ if ((wcscasecmp(path+len-3, L"exe") == 0)
+ || (wcscasecmp(path+len-3, L"com") == 0)
+ || (wcscasecmp(path+len-3, L"bat") == 0)) {
return 1;
}
} else {
@@ -1797,9 +1797,9 @@ NativeIsExec(
* executable, whereas access did not.
*/
- if ((stricmp(p, "exe") == 0)
- || (stricmp(p, "com") == 0)
- || (stricmp(p, "bat") == 0)) {
+ if ((strcasecmp(p, "exe") == 0)
+ || (strcasecmp(p, "com") == 0)
+ || (strcasecmp(p, "bat") == 0)) {
/*
* File that ends with .exe, .com, or .bat is executable.
*/
diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c
index b27a762..5cf3a86 100644
--- a/win/tclWinPipe.c
+++ b/win/tclWinPipe.c
@@ -9,13 +9,11 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinPipe.c,v 1.65 2007/02/20 23:24:07 nijtmans Exp $
+ * RCS: @(#) $Id: tclWinPipe.c,v 1.65.4.1 2010/01/31 23:51:37 nijtmans Exp $
*/
#include "tclWinInt.h"
-#include <fcntl.h>
-#include <io.h>
#include <sys/stat.h>
/*
@@ -1424,7 +1422,7 @@ ApplicationType(
Tcl_DStringFree(&ds);
ext = strrchr(fullName, '.');
- if ((ext != NULL) && (stricmp(ext, ".bat") == 0)) {
+ if ((ext != NULL) && (strcasecmp(ext, ".bat") == 0)) {
applType = APPL_DOS;
break;
}
@@ -1448,7 +1446,7 @@ ApplicationType(
*/
CloseHandle(hFile);
- if ((ext != NULL) && (stricmp(ext, ".com") == 0)) {
+ if ((ext != NULL) && (strcasecmp(ext, ".com") == 0)) {
applType = APPL_DOS;
break;
}
@@ -2647,8 +2645,8 @@ Tcl_WaitPid(
void
TclWinAddProcess(
- HANDLE hProcess, /* Handle to process */
- DWORD id) /* Global process identifier */
+ void *hProcess, /* Handle to process */
+ unsigned long id) /* Global process identifier */
{
ProcInfo *procPtr = (ProcInfo *) ckalloc(sizeof(ProcInfo));
diff --git a/win/tclWinPort.h b/win/tclWinPort.h
index bca0b7e..039ba33 100644
--- a/win/tclWinPort.h
+++ b/win/tclWinPort.h
@@ -10,12 +10,22 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinPort.h,v 1.50 2007/12/13 15:28:44 dgp Exp $
+ * RCS: @(#) $Id: tclWinPort.h,v 1.50.2.1 2010/01/31 23:51:37 nijtmans Exp $
*/
#ifndef _TCLWINPORT
#define _TCLWINPORT
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#undef WIN32_LEAN_AND_MEAN
+
+/*
+ * Ask for the winsock function typedefs, also.
+ */
+#define INCL_WINSOCK_API_TYPEDEFS 1
+#include <winsock2.h>
+
#ifdef CHECK_UNICODE_CALLS
# define _UNICODE
# define UNICODE
@@ -32,13 +42,17 @@
*---------------------------------------------------------------------------
*/
+#ifdef __CYGWIN__
+# include <unistd.h>
+# include <wchar.h>
+#else
+# include <io.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
-
#include <errno.h>
#include <fcntl.h>
#include <float.h>
-#include <io.h>
#include <malloc.h>
#include <process.h>
#include <signal.h>
@@ -48,8 +62,11 @@
* These string functions are not defined with the same names on Windows.
*/
+#ifndef __CYGWIN__
+#define wcscasecmp _wcsicmp
#define strcasecmp stricmp
#define strncasecmp strnicmp
+#endif
/*
* Need to block out these includes for building extensions with MetroWerks
@@ -68,16 +85,6 @@
#include <time.h>
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#undef WIN32_LEAN_AND_MEAN
-
-/*
- * Ask for the winsock function typedefs, also.
- */
-#define INCL_WINSOCK_API_TYPEDEFS 1
-#include <winsock2.h>
-
/*
* Define EINPROGRESS in terms of WSAEINPROGRESS.
*/
@@ -395,15 +402,13 @@
#ifdef __CYGWIN__
/* On Cygwin, the environment is imported from the Cygwin DLL. */
- DLLIMPORT extern char **__cygwin_environ;
-# define environ __cygwin_environ
# define putenv TclCygwinPutenv
# define timezone _timezone
#endif /* __CYGWIN__ */
#ifdef __WATCOMC__
- /*
+ /*
* OpenWatcom uses a wine derived winsock2.h that is missing the
* LPFN_* typedefs.
*/
@@ -432,8 +437,8 @@
/*
*---------------------------------------------------------------------------
- * The following macros and declarations represent the interface between
- * generic and windows-specific parts of Tcl. Some of the macros may
+ * The following macros and declarations represent the interface between
+ * generic and windows-specific parts of Tcl. Some of the macros may
* override functions declared in tclInt.h.
*---------------------------------------------------------------------------
*/
@@ -507,14 +512,14 @@
/*
- * The following macros have trivial definitions, allowing generic code to
+ * The following macros have trivial definitions, allowing generic code to
* address platform-specific issues.
*/
#define TclpReleaseFile(file) ckfree((char *) file)
/*
- * The following macros and declarations wrap the C runtime library
+ * The following macros and declarations wrap the C runtime library
* functions.
*/
diff --git a/win/tclWinReg.c b/win/tclWinReg.c
index 05dbd7d..b7dce1d 100644
--- a/win/tclWinReg.c
+++ b/win/tclWinReg.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinReg.c,v 1.40 2007/05/15 16:12:53 dgp Exp $
+ * RCS: @(#) $Id: tclWinReg.c,v 1.40.4.1 2010/01/31 23:51:37 nijtmans Exp $
*/
#include "tclInt.h"
@@ -615,17 +615,17 @@ GetKeyNames(
return TCL_ERROR;
}
- /*
+ /*
* Determine how big a buffer is needed for enumerating subkeys, and
* how many subkeys there are
*/
result = (*regWinProcs->regQueryInfoKeyProc)
- (key, NULL, NULL, NULL, &subKeyCount, &maxSubKeyLen, NULL, NULL,
+ (key, NULL, NULL, NULL, &subKeyCount, &maxSubKeyLen, NULL, NULL,
NULL, NULL, NULL, NULL);
if (result != ERROR_SUCCESS) {
Tcl_SetObjResult(interp, Tcl_NewObj());
- Tcl_AppendResult(interp, "unable to query key \"",
+ Tcl_AppendResult(interp, "unable to query key \"",
Tcl_GetString(keyNameObj), "\": ", NULL);
AppendSystemError(interp, result);
RegCloseKey(key);
@@ -744,7 +744,7 @@ GetType(
* know about the type, just use the numeric value.
*/
- if (type > lastType || type < 0) {
+ if (type > lastType) {
Tcl_SetObjResult(interp, Tcl_NewIntObj((int) type));
} else {
Tcl_SetObjResult(interp, Tcl_NewStringObj(typeNames[type], -1));
@@ -878,7 +878,7 @@ GetValue(
*/
Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(
- Tcl_DStringValue(&data), (int) length));
+ (BYTE *) Tcl_DStringValue(&data), (int) length));
}
Tcl_DStringFree(&data);
return result;
@@ -1375,9 +1375,9 @@ SetValue(
Tcl_DStringFree(&buf);
} else if (type == REG_SZ || type == REG_EXPAND_SZ) {
Tcl_DString buf;
- char *data = Tcl_GetStringFromObj(dataObj, &length);
+ CONST char *data = Tcl_GetStringFromObj(dataObj, &length);
- data = (char *) Tcl_WinUtfToTChar(data, length, &buf);
+ data = Tcl_WinUtfToTChar(data, length, &buf);
/*
* Include the null in the length, padding if needed for Unicode.
@@ -1392,15 +1392,15 @@ SetValue(
(DWORD) type, (BYTE *) data, (DWORD) length);
Tcl_DStringFree(&buf);
} else {
- char *data;
+ BYTE *data;
/*
* Store binary data in the registry.
*/
- data = Tcl_GetByteArrayFromObj(dataObj, &length);
+ data = (BYTE *) Tcl_GetByteArrayFromObj(dataObj, &length);
result = (*regWinProcs->regSetValueExProc)(key, valueName, 0,
- (DWORD) type, (BYTE *) data, (DWORD) length);
+ (DWORD) type, data, (DWORD) length);
}
Tcl_DStringFree(&nameBuf);
@@ -1438,10 +1438,11 @@ BroadcastValue(
int objc, /* Number of arguments. */
Tcl_Obj *CONST objv[]) /* Argument values. */
{
- LRESULT result, sendResult;
+ LRESULT result;
+ DWORD sendResult;
UINT timeout = 3000;
int len;
- char *str;
+ CONST char *str;
Tcl_Obj *objPtr;
if ((objc != 3) && (objc != 5)) {
@@ -1600,8 +1601,8 @@ ConvertDWORD(
* Check to see if the low bit is in the first byte.
*/
- localType = (*((char*)(&order)) == 1) ? REG_DWORD : REG_DWORD_BIG_ENDIAN;
- return (type != localType) ? SWAPLONG(value) : value;
+ localType = (*((char*) &order) == 1) ? REG_DWORD : REG_DWORD_BIG_ENDIAN;
+ return (type != localType) ? (DWORD) SWAPLONG(value) : value;
}
/*
diff --git a/win/tclWinSerial.c b/win/tclWinSerial.c
index 39c7e05..04ccf9b 100644
--- a/win/tclWinSerial.c
+++ b/win/tclWinSerial.c
@@ -11,13 +11,11 @@
*
* Serial functionality implemented by Rolf.Schroedter@dlr.de
*
- * RCS: @(#) $Id: tclWinSerial.c,v 1.36 2008/01/14 00:11:44 hobbs Exp $
+ * RCS: @(#) $Id: tclWinSerial.c,v 1.36.2.1 2010/01/31 23:51:37 nijtmans Exp $
*/
#include "tclWinInt.h"
-#include <fcntl.h>
-#include <io.h>
#include <sys/stat.h>
/*
@@ -1744,16 +1742,16 @@ SerialSetOptionProc(
dcb.XonLim = (WORD) (infoPtr->sysBufRead*1/2);
dcb.XoffLim = (WORD) (infoPtr->sysBufRead*1/4);
- if (strnicmp(value, "NONE", vlen) == 0) {
+ if (strncasecmp(value, "NONE", vlen) == 0) {
/*
* Leave all handshake options disabled.
*/
- } else if (strnicmp(value, "XONXOFF", vlen) == 0) {
+ } else if (strncasecmp(value, "XONXOFF", vlen) == 0) {
dcb.fOutX = dcb.fInX = TRUE;
- } else if (strnicmp(value, "RTSCTS", vlen) == 0) {
+ } else if (strncasecmp(value, "RTSCTS", vlen) == 0) {
dcb.fOutxCtsFlow = TRUE;
dcb.fRtsControl = RTS_CONTROL_HANDSHAKE;
- } else if (strnicmp(value, "DTRDSR", vlen) == 0) {
+ } else if (strncasecmp(value, "DTRDSR", vlen) == 0) {
dcb.fOutxDsrFlow = TRUE;
dcb.fDtrControl = DTR_CONTROL_HANDSHAKE;
} else {
@@ -1863,7 +1861,7 @@ SerialSetOptionProc(
result = TCL_ERROR;
break;
}
- if (strnicmp(argv[i], "DTR", strlen(argv[i])) == 0) {
+ if (strncasecmp(argv[i], "DTR", strlen(argv[i])) == 0) {
if (!EscapeCommFunction(infoPtr->handle,
(DWORD) (flag ? SETDTR : CLRDTR))) {
if (interp != NULL) {
@@ -1872,7 +1870,7 @@ SerialSetOptionProc(
result = TCL_ERROR;
break;
}
- } else if (strnicmp(argv[i], "RTS", strlen(argv[i])) == 0) {
+ } else if (strncasecmp(argv[i], "RTS", strlen(argv[i])) == 0) {
if (!EscapeCommFunction(infoPtr->handle,
(DWORD) (flag ? SETRTS : CLRRTS))) {
if (interp != NULL) {
@@ -1881,7 +1879,7 @@ SerialSetOptionProc(
result = TCL_ERROR;
break;
}
- } else if (strnicmp(argv[i], "BREAK", strlen(argv[i])) == 0) {
+ } else if (strncasecmp(argv[i], "BREAK", strlen(argv[i])) == 0) {
if (!EscapeCommFunction(infoPtr->handle,
(DWORD) (flag ? SETBREAK : CLRBREAK))) {
if (interp != NULL) {
diff --git a/win/tclWinSock.c b/win/tclWinSock.c
index b26d697..bd615a8 100644
--- a/win/tclWinSock.c
+++ b/win/tclWinSock.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinSock.c,v 1.62.2.2 2009/04/27 21:45:20 ferrieux Exp $
+ * RCS: @(#) $Id: tclWinSock.c,v 1.62.2.3 2010/01/31 23:51:37 nijtmans Exp $
*/
#include "tclWinInt.h"
@@ -1768,7 +1768,7 @@ TcpSetOptionProc(
sock = infoPtr->socket;
#ifdef TCL_FEATURE_KEEPALIVE_NAGLE
- if (!stricmp(optionName, "-keepalive")) {
+ if (!strcasecmp(optionName, "-keepalive")) {
BOOL val = FALSE;
int boolVar, rtn;
@@ -1789,7 +1789,7 @@ TcpSetOptionProc(
return TCL_ERROR;
}
return TCL_OK;
- } else if (!stricmp(optionName, "-nagle")) {
+ } else if (!strcasecmp(optionName, "-nagle")) {
BOOL val = FALSE;
int boolVar, rtn;
diff --git a/win/tclWinTest.c b/win/tclWinTest.c
index adea787..a3ea423 100644
--- a/win/tclWinTest.c
+++ b/win/tclWinTest.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinTest.c,v 1.22.2.1 2008/10/07 20:51:47 nijtmans Exp $
+ * RCS: @(#) $Id: tclWinTest.c,v 1.22.2.2 2010/01/31 23:51:37 nijtmans Exp $
*/
#include "tclInt.h"
@@ -754,7 +754,7 @@ TestplatformChmod(
done:
if (secDesc) {
- ckfree(secDesc);
+ ckfree((char *) secDesc);
}
if (newAcl) {
ckfree((char *) newAcl);
diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c
index 22ba966..442e292 100644
--- a/win/tclWinThrd.c
+++ b/win/tclWinThrd.c
@@ -9,13 +9,11 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinThrd.c,v 1.43.4.1 2008/12/21 20:13:49 dgp Exp $
+ * RCS: @(#) $Id: tclWinThrd.c,v 1.43.4.2 2010/01/31 23:51:37 nijtmans Exp $
*/
#include "tclWinInt.h"
-#include <fcntl.h>
-#include <io.h>
#include <sys/stat.h>
/*
@@ -43,8 +41,10 @@ static CRITICAL_SECTION initLock;
#ifdef TCL_THREADS
-static CRITICAL_SECTION allocLock;
-static Tcl_Mutex allocLockPtr = (Tcl_Mutex) &allocLock;
+static struct Tcl_Mutex_ {
+ CRITICAL_SECTION crit;
+} allocLock;
+static Tcl_Mutex allocLockPtr = &allocLock;
static int allocOnce = 0;
#endif /* TCL_THREADS */
@@ -155,7 +155,7 @@ TclpThreadCreate(
EnterCriticalSection(&joinLock);
*idPtr = 0; /* must initialize as Tcl_Thread is a pointer and
- * on WIN64 sizeof void* != sizeof unsigned
+ * on WIN64 sizeof void* != sizeof unsigned
*/
#if defined(_MSC_VER) || defined(__MSVCRT__) || defined(__BORLANDC__)
@@ -412,7 +412,7 @@ Tcl_GetAllocMutex(void)
{
#ifdef TCL_THREADS
if (!allocOnce) {
- InitializeCriticalSection(&allocLock);
+ InitializeCriticalSection(&allocLock.crit);
allocOnce = 1;
}
return &allocLockPtr;
@@ -454,7 +454,7 @@ TclFinalizeLock(void)
#ifdef TCL_THREADS
if (allocOnce) {
- DeleteCriticalSection(&allocLock);
+ DeleteCriticalSection(&allocLock.crit);
allocOnce = 0;
}
#endif
@@ -495,6 +495,7 @@ Tcl_MutexLock(
Tcl_Mutex *mutexPtr) /* The lock */
{
CRITICAL_SECTION *csPtr;
+
if (*mutexPtr == NULL) {
MASTER_LOCK;
@@ -535,6 +536,7 @@ Tcl_MutexUnlock(
Tcl_Mutex *mutexPtr) /* The lock */
{
CRITICAL_SECTION *csPtr = *((CRITICAL_SECTION **)mutexPtr);
+
LeaveCriticalSection(csPtr);
}
@@ -560,6 +562,7 @@ TclpFinalizeMutex(
Tcl_Mutex *mutexPtr)
{
CRITICAL_SECTION *csPtr = *(CRITICAL_SECTION **)mutexPtr;
+
if (csPtr != NULL) {
DeleteCriticalSection(csPtr);
ckfree((char *) csPtr);
@@ -645,11 +648,11 @@ Tcl_ConditionWait(
*/
if (*condPtr == NULL) {
- winCondPtr = (WinCondition *)ckalloc(sizeof(WinCondition));
+ winCondPtr = (WinCondition *) ckalloc(sizeof(WinCondition));
InitializeCriticalSection(&winCondPtr->condLock);
winCondPtr->firstPtr = NULL;
winCondPtr->lastPtr = NULL;
- *condPtr = (Tcl_Condition)winCondPtr;
+ *condPtr = (Tcl_Condition) winCondPtr;
TclRememberCondition(condPtr);
}
MASTER_UNLOCK;
@@ -759,6 +762,7 @@ Tcl_ConditionNotify(
{
WinCondition *winCondPtr;
ThreadSpecificData *tsdPtr;
+
if (*condPtr != NULL) {
winCondPtr = *((WinCondition **)condPtr);
@@ -815,6 +819,7 @@ FinalizeConditionEvent(
ClientData data)
{
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) data;
+
tsdPtr->flags = WIN_THREAD_UNINIT;
CloseHandle(tsdPtr->condEvent);
}
@@ -858,6 +863,9 @@ TclpFinalizeCondition(
}
}
+
+
+
/*
* Additions by AOL for specialized thread memory allocator.
*/