Index: ChangeLog ================================================================== --- ChangeLog +++ ChangeLog @@ -1,5 +1,13 @@ +2008-03-19 Pat Thoyts + + * win/Makefile.vc Updated the nmake build files with MSVC9 support + * win/rules.vc: and fixed to run the test-suite properly. + * win/nmakehlp.c: + * tls.tcl (tls::initlib): Corrected namespace handling. + * tls.c: Applied #1890223 to fix handshake on non-blocking sockets + 2007-09-06 Pat Thoyts * tls.c: Silence 64 bit integer conversion warnings * win/nmakehlp.c: Update build system to support AMD64 target * win/makefile.vc: with MSVC8 Index: tls.c ================================================================== --- tls.c +++ tls.c @@ -3,11 +3,11 @@ * some modifications: * Copyright (C) 2000 Ajuba Solutions * Copyright (C) 2002 ActiveState Corporation * Copyright (C) 2004 Starfish Systems * - * $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tls.c,v 1.26 2007/09/06 21:01:55 patthoyts Exp $ + * $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tls.c,v 1.27 2008/03/19 02:34:21 patthoyts Exp $ * * TLS (aka SSL) Channel - can be layered on any bi-directional * Tcl_Channel (Note: Requires Trf Core Patch) * * This was built (almost) from scratch based upon observation of @@ -606,10 +606,13 @@ statePtr = (State *)Tcl_GetChannelInstanceData(chan); if (!SSL_is_init_finished(statePtr->ssl)) { int err; ret = Tls_WaitForConnect(statePtr, &err); + if ((statePtr->flags & TLS_TCL_ASYNC) && err == EAGAIN) { + ret = 0; + } if (ret < 0) { CONST char *errStr = statePtr->err; Tcl_ResetResult(interp); Tcl_SetErrno(err); Index: tls.tcl ================================================================== --- tls.tcl +++ tls.tcl @@ -1,9 +1,9 @@ # # Copyright (C) 1997-2000 Matt Newman # -# $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tls.tcl,v 1.9 2008/03/18 00:40:37 hobbs2 Exp $ +# $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tls.tcl,v 1.10 2008/03/19 02:34:21 patthoyts Exp $ # namespace eval tls { variable logcmd tclLog variable debug 0 @@ -25,14 +25,14 @@ # Package index cd's into the package directory for loading. # Irrelevant to unixoids, but for Windows this enables the OS to find # the dependent DLL's in the CWD, where they may be. set cwd [pwd] catch {cd $dir} - set res [catch {load [file join $dir $dll]} err] + set res [catch {uplevel #0 [list load [file join [pwd] $dll]]} err] catch {cd $cwd} if {$res} { - namespace delete tls + namespace eval [namespace parent] {namespace delete tls} return -code $res $err } rename tls::initlib {} } Index: win/makefile.vc ================================================================== --- win/makefile.vc +++ win/makefile.vc @@ -16,11 +16,11 @@ # Copyright (c) 2001 ActiveState Corporation. # Copyright (c) 2001-2002 David Gravereaux. # Copyright (c) 2003-2006 Pat Thoyts # #------------------------------------------------------------------------- -# RCS: @(#)$Id: makefile.vc,v 1.4 2007/09/06 21:01:55 patthoyts Exp $ +# RCS: @(#)$Id: makefile.vc,v 1.5 2008/03/19 02:34:21 patthoyts Exp $ #------------------------------------------------------------------------- # Check to see we are configured to build with MSVC (MSDEVDIR or MSVCDIR) # or with the MS Platform SDK (MSSDK). Visual Studio .NET 2003 and 2005 define # VCINSTALLDIR instead. The MSVC Toolkit release defines yet another. @@ -171,11 +171,13 @@ DLLOBJS = \ $(TMP_DIR)\tls.obj \ $(TMP_DIR)\tlsBIO.obj \ $(TMP_DIR)\tlsIO.obj \ $(TMP_DIR)\tlsX509.obj \ +!if !$(STATIC_BUILD) $(TMP_DIR)\tls.res +!endif #------------------------------------------------------------------------- # Locate the OpenSSL library and headers #------------------------------------------------------------------------- @@ -248,20 +250,13 @@ !else cdebug = -Zi -WX $(DEBUGFLAGS) !endif ### Declarations common to all compiler options -cwarn = -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE +cwarn = $(WARNINGS) -D _CRT_SECURE_NO_DEPRECATE -D _CRT_NONSTDC_NO_DEPRECATE cflags = -nologo -c $(COMPILERFLAGS) $(cwarn) -Fp$(TMP_DIR)^\ -# Warning level -!if $(FULLWARNINGS) -cflags = $(cflags) -W4 -!else -cflags = $(cflags) -W3 -!endif - !if $(MSVCRT) !if $(DEBUG) && !$(UNCHECKED) crt = -MDd !else crt = -MD @@ -304,14 +299,10 @@ !endif ### Declarations common to all linker options lflags = -nologo -machine:$(MACHINE) $(LINKERFLAGS) $(ldebug) -!if $(FULLWARNINGS) -lflags = $(lflags) -warn:3 -!endif - !if $(PROFILE) lflags = $(lflags) -profile !endif !if $(ALIGN98_HACK) && !$(STATIC_BUILD) @@ -337,11 +328,13 @@ !endif # Avoid 'unresolved external symbol __security_cookie' errors. # c.f. http://support.microsoft.com/?id=894573 !if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64" +!if $(VCVERSION) >= 1400 && $(VCVERSION) < 1500 baselibs = $(baselibs) bufferoverflowU.lib +!endif !endif baselibs = $(baselibs) $(SSL_LIBS) ws2_32.lib user32.lib gdi32.lib advapi32.lib #--------------------------------------------------------------------- @@ -355,39 +348,38 @@ #--------------------------------------------------------------------- # Project specific targets (EDIT) #--------------------------------------------------------------------- all: setup $(PROJECT) -$(PROJECT): setup $(PRJLIB) +$(PROJECT): setup $(OUT_DIR)\pkgIndex.tcl $(OUT_DIR)\tls.tcl $(PRJLIB) install: install-binaries install-libraries install-docs -# Tests need to ensure we load the right dll file we -# have to handle the output differently on Win9x. -# -!if "$(OS)" == "Windows_NT" || "$(MSVCDIR)" == "IDE" test: setup $(PROJECT) - set TCL_LIBRARY=$(ROOT)/library - $(TCLSH) << -load $(PRJLIB:\=/) -source [file join $(LIBDIR) tls.tcl] -cd "$(ROOT)/tests" -set argv "$(TESTFLAGS)" -source all.tcl -<< + @set TCL_LIBRARY=$(TCL_LIBRARY:\=/) + @set TCLLIBPATH=$(OUT_DIR:\=/) +!if $(TCLINSTALL) + @set PATH=$(_TCLDIR)\bin;$(PATH) +!else + @set PATH=$(_TCLDIR)\win\$(BUILDDIRTOP);$(PATH) +!endif +!if "$(OS)" == "Windows_NT" || "$(MSVCDIR)" == "IDE" + $(DEBUGGER) $(TCLSH) "$(ROOT)/tests/all.tcl" $(TESTFLAGS) +!else + @echo Please wait while the tests are collected... + $(TCLSH) "$(ROOT)/tests/all.tcl" $(TESTFLAGS) > tests.log + type tests.log | more +!endif + +shell: setup $(PROJECT) + @set TCL_LIBRARY=$(TCL_LIBRARY:\=/) + @set TCLLIBPATH=$(OUT_DIR:\=/) +!if $(TCLINSTALL) + @set PATH=$(_TCLDIR)\bin;$(PATH) !else -test: setup $(PROJECT) - echo Please wait while the test results are collected - set TCL_LIBRARY=$(ROOT)/library - $(TCLSH) << >tests.log -load $(PRJLIB:\=/) -source [file normalize [file join $(LIBDIR) tls.tcl]] -cd "$(ROOT)/tests" -set argv "$(TESTFLAGS)" -source all.tcl -<< - type tests.log | more + @set PATH=$(_TCLDIR)\win\$(BUILDDIRTOP);$(PATH) !endif + $(DEBUGGER) $(TCLSH) setup: @if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR) @if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR) @@ -449,15 +441,19 @@ #------------------------------------------------------------------------- # Explicit dependency rules # #------------------------------------------------------------------------- -$(OUT_DIR)\pkgIndex.tcl: $(ROOT)\pkgIndex.tcl.in - nmakehlp -s << $** > $@ -@PACKAGE_VERSION@ $(DOTVERSION) -@PACKAGE_NAME@ $(PROJECT) -@PKG_LIB_FILE@ $(PRJLIBNAME) +.PHONY: $(OUT_DIR)\pkgIndex.tcl $(OUT_DIR)\tls.tcl + +$(OUT_DIR)\tls.tcl: $(GENERICDIR)\tls.tcl + @$(COPY) $** $@ + +$(OUT_DIR)\pkgIndex.tcl: + @type << > $@ +if {![package vsatisfies [package provide Tcl] 8.3]} {return} +package ifneeded $(PROJECT) $(DOTVERSION) "source \[file join [list $$dir] tls.tcl\] ; tls::initlib [list $$dir] $(PRJLIBNAME)" << #--------------------------------------------------------------------- # Installation. (EDIT) # @@ -473,15 +469,11 @@ install-libraries: @echo Installing libraries to '$(SCRIPT_INSTALL_DIR)' @if exist $(LIBDIR) $(CPY) $(LIBDIR)\tls.tcl "$(SCRIPT_INSTALL_DIR)" > NUL @echo Installing package index in '$(SCRIPT_INSTALL_DIR)' - @type << >"$(SCRIPT_INSTALL_DIR)\pkgIndex.tcl" -# pkgIndex.tcl - -if {![package vsatisfies [package provide Tcl] 8.3]} {return} -package ifneeded $(PROJECT) $(DOTVERSION) "[list load [file join $$dir $(PROJECT)$(VERSION).$(EXT)] Tls] ; [list source [file join $$dir tls.tcl]]" -<< + @$(CPY) $(OUT_DIR)\pkgIndex.tcl "$(SCRIPT_INSTALL_DIR)" install-docs: @echo Installing documentation files to '$(DOC_INSTALL_DIR)' @if exist $(DOCDIR) $(CPY) $(DOCDIR)\tls.htm "$(DOC_INSTALL_DIR)" >NUL Index: win/nmakehlp.c ================================================================== --- win/nmakehlp.c +++ win/nmakehlp.c @@ -9,22 +9,28 @@ * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * ---------------------------------------------------------------------------- - * RCS: @(#) $Id: nmakehlp.c,v 1.2 2007/09/06 21:01:55 patthoyts Exp $ + * RCS: @(#) $Id: nmakehlp.c,v 1.3 2008/03/19 02:34:21 patthoyts Exp $ * ---------------------------------------------------------------------------- */ #define _CRT_SECURE_NO_DEPRECATE #include #pragma comment (lib, "user32.lib") #pragma comment (lib, "kernel32.lib") #include #include + +/* + * This library is required for x64 builds with _some_ versions of MSVC + */ #if defined(_M_IA64) || defined(_M_AMD64) +#if _MSC_VER >= 1400 && _MSC_VER < 1500 #pragma comment(lib, "bufferoverflowU") +#endif #endif /* ISO hack for dumb VC++ */ #ifdef _MSC_VER #define snprintf _snprintf @@ -297,11 +303,13 @@ */ return !(strstr(Out.buffer, "D4002") != NULL || strstr(Err.buffer, "D4002") != NULL || strstr(Out.buffer, "D9002") != NULL - || strstr(Err.buffer, "D9002") != NULL); + || strstr(Err.buffer, "D9002") != NULL + || strstr(Out.buffer, "D2021") != NULL + || strstr(Err.buffer, "D2021") != NULL); } int CheckForLinkerFeature( const char *option) Index: win/rules.vc ================================================================== --- win/rules.vc +++ win/rules.vc @@ -9,14 +9,14 @@ # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # # Copyright (c) 2001-2002 David Gravereaux. -# Copyright (c) 2003-2005 Patrick Thoyts +# Copyright (c) 2003-2008 Patrick Thoyts # #------------------------------------------------------------------------------ -# RCS: @(#) $Id: rules.vc,v 1.2 2007/09/06 21:01:55 patthoyts Exp $ +# RCS: @(#) $Id: rules.vc,v 1.3 2008/03/19 02:34:21 patthoyts Exp $ #------------------------------------------------------------------------------ !ifndef _RULES_VC _RULES_VC = 1 @@ -89,11 +89,11 @@ ### test for optimizations !if [nmakehlp -c -Ot] !message *** Compiler has 'Optimizations' OPTIMIZING = 1 !else -!message *** Compiler doesn't have 'Optimizations' +!message *** Compiler does not have 'Optimizations' OPTIMIZING = 0 !endif OPTIMIZATIONS = @@ -146,11 +146,11 @@ ### test for pentium errata !if [nmakehlp -c -QI0f] !message *** Compiler has 'Pentium 0x0f fix' COMPILERFLAGS = $(COMPILERFLAGSS) -QI0f !else -!message *** Compiler doesn't have 'Pentium 0x0f fix' +!message *** Compiler does not have 'Pentium 0x0f fix' !endif !endif !if "$(MACHINE)" == "IA64" ### test for Itanium errata @@ -166,11 +166,11 @@ ### test for -align:4096, when align:512 will do. !if [nmakehlp -l -opt:nowin98] !message *** Linker has 'Win98 alignment problem' ALIGN98_HACK = 1 !else -!message *** Linker doesn't have 'Win98 alignment problem' +!message *** Linker does not have 'Win98 alignment problem' ALIGN98_HACK = 0 !endif !else ALIGN98_HACK = 0 !endif @@ -190,20 +190,26 @@ _VC_MANIFEST_EMBED_DLL= VCVER=0 !if ![echo VCVERSION=_MSC_VER > vercl.x] \ && ![cl -nologo -TC -P vercl.x $(ERRNULL)] !include vercl.i -!if $(VCVERSION) >= 1400 +!if $(VCVERSION) >= 1500 +VCVER=9 +!elseif $(VCVERSION) >= 1400 VCVER=8 -_VC_MANIFEST_EMBED_EXE=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;1 -_VC_MANIFEST_EMBED_DLL=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2 !elseif $(VCVERSION) >= 1300 VCVER=7 !elseif $(VCVERSION) >= 1200 VCVER=6 !endif !endif + +# Since MSVC8 we must deal with manifest resources. +!if $(VCVERSION) >= 1400 +_VC_MANIFEST_EMBED_EXE=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;1 +_VC_MANIFEST_EMBED_DLL=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2 +!endif #---------------------------------------------------------- # Decode the options requested. #---------------------------------------------------------- @@ -388,32 +394,38 @@ # Decode the checks requested. #---------------------------------------------------------- !if "$(CHECKS)" == "" || [nmakehlp -f "$(CHECKS)" "none"] TCL_NO_DEPRECATED = 0 -FULLWARNINGS = 0 +WARNINGS = -W3 !else !if [nmakehlp -f $(CHECKS) "nodep"] !message *** Doing nodep check TCL_NO_DEPRECATED = 1 !else TCL_NO_DEPRECATED = 0 !endif !if [nmakehlp -f $(CHECKS) "fullwarn"] !message *** Doing full warnings check -FULLWARNINGS = 1 +WARNINGS = -W4 +!if [nmakehlp -l -warn:3] +LINKERFLAGS = $(LINKERFLAGS) -warn:3 +!endif !else -FULLWARNINGS = 0 +WARNINGS = -W3 +!endif +!if [nmakehlp -f $(CHECKS) "64bit"] && [nmakehlp -c -Wp64] +!message *** Doing 64bit portability warnings +WARNINGS = $(WARNINGS) -Wp64 !endif !endif - #---------------------------------------------------------- # Set our defines now armed with our options. #---------------------------------------------------------- -OPTDEFINES = -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) +OPTDEFINES = -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) -DSTDC_HEADERS !if $(TCL_MEM_DEBUG) OPTDEFINES = $(OPTDEFINES) -DTCL_MEM_DEBUG !endif !if $(TCL_COMPILE_DEBUG) @@ -441,11 +453,11 @@ OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_OPTIMIZED !endif !if $(PROFILE) OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_PROFILED !endif -!if "$(MACHINE)" == "IA64" +!if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64" OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DO64BIT !endif #---------------------------------------------------------- @@ -561,18 +573,26 @@ !include version.vc TK_VERSION = $(TK_DOTVERSION:.=) !if $(TKINSTALL) WISH = "$(_TKDIR)\bin\wish$(TK_VERSION)$(SUFX).exe" +!if !exist($(WISH)) && $(TCL_THREADS) +WISH = "$(_TKDIR)\bin\wish$(TK_VERSION)t$(SUFX).exe" +!endif TKSTUBLIB = "$(_TKDIR)\lib\tkstub$(TK_VERSION).lib" TKIMPLIB = "$(_TKDIR)\lib\tk$(TK_VERSION)$(SUFX).lib" TK_INCLUDES = -I"$(_TKDIR)\include" +TK_LIBRARY = $(_TKDIR)\lib !else WISH = "$(_TKDIR)\win\$(BUILDDIRTOP)\wish$(TCL_VERSION)$(SUFX).exe" +!if !exist($(WISH)) && $(TCL_THREADS) +WISH = "$(_TKDIR)\win\$(BUILDDIRTOP)\wish$(TCL_VERSION)t$(SUFX).exe" +!endif TKSTUBLIB = "$(_TKDIR)\win\$(BUILDDIRTOP)\tkstub$(TCL_VERSION).lib" TKIMPLIB = "$(_TKDIR)\win\$(BUILDDIRTOP)\tk$(TCL_VERSION)$(SUFX).lib" TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib" +TK_LIBRARY = $(_TKDIR)\library !endif !endif !endif !endif @@ -584,9 +604,9 @@ !message *** Intermediate directory will be '$(TMP_DIR)' !message *** Output directory will be '$(OUT_DIR)' !message *** Suffix for binaries will be '$(SUFX)' !message *** Optional defines are '$(OPTDEFINES)' !message *** Compiler version $(VCVER). Target machine is $(MACHINE) -!message *** Compiler options '$(COMPILERFLAGS) $(OPTIMIZATIONS) $(DEBUGFLAGS)' +!message *** Compiler options '$(COMPILERFLAGS) $(OPTIMIZATIONS) $(DEBUGFLAGS) $(WARNINGS)' !message *** Link options '$(LINKERFLAGS)' !endif