From 2f64bc5e83126cf7aafe7ae267cf0b0f07386165 Mon Sep 17 00:00:00 2001 From: hobbs Date: Thu, 9 Dec 1999 14:44:09 +0000 Subject: * win/tclWin32Dll.c: * win/tclWinChan.c: * win/tclWinFCmd.c: * win/tclWinInit.c: * win/tclWinPipe.c: * win/tclWinSock.c: removed all code that supported Win32s. It was no longer officially supported, and likely didn't work anyway. * win/makefile.vc: removed 16 bit stuff, cleaned up. * win/tcl16.rc: * win/tclWin16.c: * win/winDumpExts.c: these files have been removed from the source tree (no longer necessary to build) * win/aclocal.m4: made it just include tcl.m4 --- win/aclocal.m4 | 446 +------------------------------------------- win/makefile.vc | 178 +++++------------- win/tcl16.rc | 37 ---- win/tclWin16.c | 347 ---------------------------------- win/tclWin32Dll.c | 29 +-- win/tclWinChan.c | 14 +- win/tclWinFCmd.c | 34 +--- win/tclWinInit.c | 12 +- win/tclWinPipe.c | 547 ++++++++---------------------------------------------- win/tclWinSock.c | 47 ++--- win/winDumpExts.c | 505 ------------------------------------------------- 11 files changed, 158 insertions(+), 2038 deletions(-) delete mode 100644 win/tcl16.rc delete mode 100644 win/tclWin16.c delete mode 100644 win/winDumpExts.c diff --git a/win/aclocal.m4 b/win/aclocal.m4 index 50a23cf..bc7540d 100644 --- a/win/aclocal.m4 +++ b/win/aclocal.m4 @@ -1,445 +1 @@ -#------------------------------------------------------------------------ -# SC_PATH_TCLCONFIG -- -# -# Locate the tclConfig.sh file and perform a sanity check on -# the Tcl compile flags -# Currently a no-op for Windows -# -# Arguments: -# PATCH_LEVEL The patch level for Tcl if any. -# -# Results: -# -# Adds the following arguments to configure: -# --with-tcl=... -# -# Sets the following vars: -# TCL_BIN_DIR Full path to the tclConfig.sh file -#------------------------------------------------------------------------ - -AC_DEFUN(SC_PATH_TCLCONFIG, [ - AC_MSG_CHECKING([the location of tclConfig.sh]) - - if test -d ../../tcl8.2$1/win; then - TCL_BIN_DIR_DEFAULT=../../tcl8.2$1/win - else - TCL_BIN_DIR_DEFAULT=../../tcl8.2/win - fi - - AC_ARG_WITH(tcl, [ --with-tcl=DIR use Tcl 8.2 binaries from DIR], - TCL_BIN_DIR=$withval, TCL_BIN_DIR=`cd $TCL_BIN_DIR_DEFAULT; pwd`) - if test ! -d $TCL_BIN_DIR; then - AC_MSG_ERROR(Tcl directory $TCL_BIN_DIR does not exist) - fi - if test ! -f $TCL_BIN_DIR/tclConfig.sh; then - AC_MSG_ERROR(There is no tclConfig.sh in $TCL_BIN_DIR: perhaps you did not specify the Tcl *build* directory (not the toplevel Tcl directory) or you forgot to configure Tcl?) - fi - AC_MSG_RESULT($TCL_BIN_DIR/tclConfig.sh) -]) - -#------------------------------------------------------------------------ -# SC_PATH_TKCONFIG -- -# -# Locate the tkConfig.sh file -# Currently a no-op for Windows -# -# Arguments: -# none -# -# Results: -# -# Adds the following arguments to configure: -# --with-tk=... -# -# Sets the following vars: -# TK_BIN_DIR Full path to the tkConfig.sh file -#------------------------------------------------------------------------ - -AC_DEFUN(SC_PATH_TKCONFIG, [ - AC_MSG_CHECKING([the location of tkConfig.sh]) - - if test -d ../../tk8.2$1/win; then - TK_BIN_DIR_DEFAULT=../../tk8.2$1/win - else - TK_BIN_DIR_DEFAULT=../../tk8.2/win - fi - - AC_ARG_WITH(tk, [ --with-tk=DIR use Tk 8.2 binaries from DIR], - TK_BIN_DIR=$withval, TK_BIN_DIR=`cd $TK_BIN_DIR_DEFAULT; pwd`) - if test ! -d $TK_BIN_DIR; then - AC_MSG_ERROR(Tk directory $TK_BIN_DIR does not exist) - fi - if test ! -f $TK_BIN_DIR/tkConfig.sh; then - AC_MSG_ERROR(There is no tkConfig.sh in $TK_BIN_DIR: perhaps you did not specify the Tk *build* directory (not the toplevel Tk directory) or you forgot to configure Tk?) - fi - - AC_MSG_RESULT($TK_BIN_DIR/tkConfig.sh) -]) - -#------------------------------------------------------------------------ -# SC_LOAD_TCLCONFIG -- -# -# Load the tclConfig.sh file -# Currently a no-op for Windows -# -# Arguments: -# -# Requires the following vars to be set: -# TCL_BIN_DIR -# -# Results: -# -# Subst the following vars: -# TCL_BIN_DIR -# TCL_SRC_DIR -# TCL_LIB_FILE -# -#------------------------------------------------------------------------ - -AC_DEFUN(SC_LOAD_TCLCONFIG, [ - AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh]) - - if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then - AC_MSG_RESULT([loading]) - . $TCL_BIN_DIR/tclConfig.sh - else - AC_MSG_RESULT([file not found]) - fi - - # The eval is required to do the TCL_DBGX substitution in the - # TCL_LIB_FILE variable. - - eval TCL_LIB_FILE=${TCL_LIB_FILE} - eval TCL_LIB_FLAG=${TCL_LIB_FLAG} - - AC_SUBST(TCL_BIN_DIR) - AC_SUBST(TCL_SRC_DIR) - AC_SUBST(TCL_LIB_FILE) -]) - -#------------------------------------------------------------------------ -# SC_LOAD_TKCONFIG -- -# -# Load the tkConfig.sh file -# Currently a no-op for Windows -# -# Arguments: -# -# Requires the following vars to be set: -# TK_BIN_DIR -# -# Results: -# -# Sets the following vars that should be in tkConfig.sh: -# TK_BIN_DIR -#------------------------------------------------------------------------ - -AC_DEFUN(SC_LOAD_TKCONFIG, [ - AC_MSG_CHECKING([for existence of $TCLCONFIG]) - - if test -f "$TK_BIN_DIR/tkConfig.sh" ; then - AC_MSG_CHECKING([loading $TK_BIN_DIR/tkConfig.sh]) - . $TK_BIN_DIR/tkConfig.sh - else - AC_MSG_RESULT([could not find $TK_BIN_DIR/tkConfig.sh]) - fi - - - AC_SUBST(TK_BIN_DIR) - AC_SUBST(TK_SRC_DIR) - AC_SUBST(TK_LIB_FILE) -]) - -#------------------------------------------------------------------------ -# SC_ENABLE_GCC -- -# -# Allows the use of GCC if available -# -# Arguments: -# none -# -# Results: -# -# Adds the following arguments to configure: -# --enable-gcc -# -# Sets the following vars: -# CC Command to use for the compiler -#------------------------------------------------------------------------ - -AC_DEFUN(SC_ENABLE_GCC, [ - AC_ARG_ENABLE(gcc, [ --enable-gcc allow use of gcc if available [--disable-gcc]], - [ok=$enableval], [ok=no]) - if test "$ok" = "yes"; then - CC=gcc - AC_PROG_CC - else - CC=cl - fi -]) - -#------------------------------------------------------------------------ -# SC_ENABLE_SHARED -- -# -# Allows the building of shared libraries -# -# Arguments: -# none -# -# Results: -# -# Adds the following arguments to configure: -# --enable-shared=yes|no -# -# Defines the following vars: -# STATIC_BUILD Used for building import/export libraries -# on Windows. -# -# Sets the following vars: -# SHARED_BUILD Value of 1 or 0 -#------------------------------------------------------------------------ - -AC_DEFUN(SC_ENABLE_SHARED, [ - AC_MSG_CHECKING([how to build libraries]) - AC_ARG_ENABLE(shared, - [ --enable-shared build and link with shared libraries [--enable-shared]], - [tcl_ok=$enableval], [tcl_ok=yes]) - - if test "${enable_shared+set}" = set; then - enableval="$enable_shared" - tcl_ok=$enableval - else - tcl_ok=yes - fi - - if test "$tcl_ok" = "yes" ; then - AC_MSG_RESULT([shared]) - SHARED_BUILD=1 - else - AC_MSG_RESULT([static]) - SHARED_BUILD=0 - AC_DEFINE(STATIC_BUILD) - fi -]) - -#------------------------------------------------------------------------ -# SC_ENABLE_THREADS -- -# -# Specify if thread support should be enabled -# -# Arguments: -# none -# -# Results: -# -# Adds the following arguments to configure: -# --enable-threads=yes|no -# -# Defines the following vars: -# TCL_THREADS -#------------------------------------------------------------------------ - -AC_DEFUN(SC_ENABLE_THREADS, [ - AC_MSG_CHECKING(for building with threads) - AC_ARG_ENABLE(threads, [ --enable-threads build with threads], - [tcl_ok=$enableval], [tcl_ok=no]) - - if test "$tcl_ok" = "yes"; then - AC_MSG_RESULT(yes) - TCL_THREADS=1 - AC_DEFINE(TCL_THREADS) - else - TCL_THREADS=0 - AC_MSG_RESULT(no (default)) - fi -]) - -#------------------------------------------------------------------------ -# SC_ENABLE_SYMBOLS -- -# -# Specify if debugging symbols should be used -# -# Arguments: -# none -# -# Requires the following vars to be set: -# CFLAGS_DEBUG -# CFLAGS_OPTIMIZE -# -# Results: -# -# Adds the following arguments to configure: -# --enable-symbols -# -# Defines the following vars: -# CFLAGS_DEFAULT Sets to CFLAGS_DEBUG if true -# Sets to CFLAGS_OPTIMIZE if false -# LDFLAGS_DEFAULT Sets to LDFLAGS_DEBUG if true -# Sets to LDFLAGS_OPTIMIZE if false -# DBGX Debug library extension -# -#------------------------------------------------------------------------ - -AC_DEFUN(SC_ENABLE_SYMBOLS, [ - AC_MSG_CHECKING([for build with symbols]) - AC_ARG_ENABLE(symbols, [ --enable-symbols build with debugging symbols [--disable-symbols]], [tcl_ok=$enableval], [tcl_ok=no]) - - if test "$tcl_ok" = "yes"; then - CFLAGS_DEFAULT="${CFLAGS_DEBUG}" - LDFLAGS_DEFAULT="${LDFLAGS_DEBUG}" - DBGX=d - AC_MSG_RESULT([yes]) - else - CFLAGS_DEFAULT="${CFLAGS_OPTIMIZE}" - LDFLAGS_DEFAULT="${LDFLAGS_OPTIMIZE}" - DBGX="" - AC_MSG_RESULT([no]) - fi -]) - - -#-------------------------------------------------------------------- -# SC_CONFIG_CFLAGS -# -# Try to determine the proper flags to pass to the compiler -# for building shared libraries and other such nonsense. -# -# NOTE: The backslashes in quotes below are substituted twice -# due to the fact that they are in a macro and then inlined -# in the final configure script. -# -# Arguments: -# none -# -# Results: -# -# Defines the following vars for all compilers: -# EXTRA_CFLAGS -# CFLAGS_DEBUG -# CFLAGS_OPTIMIZE -# CFLAGS_WARNING -# LDFLAGS_DEBUG -# LDFLAGS_OPTIMIZE -# PATHTYPE -# CC_OBJNAME -# CC_EXENAME -# -# Defines the following vars for non-gcc compilers -# SHLIB_LD -# SHLIB_LD_LIBS -# LIBS -# AR -# MAKE_LIB -# MAKE_EXE -# MAKE_DLL -# -# LIBSUFFIX -# LIBRARIES -# EXESUFFIX -# DLLSUFFIX -# -#-------------------------------------------------------------------- - -AC_DEFUN(SC_CONFIG_CFLAGS, [ - AC_MSG_CHECKING([compiler flags]) - EXTRA_CFLAGS="" - # set various compiler flags depending on whether we are using gcc or cl - - if test "${GCC}" = "yes" ; then - CFLAGS_DEBUG=-g - CFLAGS_OPTIMIZE=-O - CFLAGS_WARNING="-Wall -Wconversion" - LDFLAGS_DEBUG=-g - LDFLAGS_OPTIMIZE=-O - PATHTYPE=-u - - # Specify the CC output file names based on the target name - CC_OBJNAME="-o \[$]@" - CC_EXENAME="-o \[$]@" - else - SHLIB_LD="link -dll -nologo" - SHLIB_LD_LIBS="user32.lib advapi32.lib" - LIBS="user32.lib advapi32.lib" - AR="lib -nologo" - STLIB_LD="lib -nologo" - RC="rc" - MAKE_LIB="\${AR} -out:\[$]@" - MAKE_EXE="\${CC} -Fe\[$]@" - - if test "${SHARED_BUILD}" = "0" ; then - # static - AC_MSG_RESULT([using static flags]) - runtime=-MT - MAKE_DLL="echo " - LIBSUFFIX="s\${DBGX}.lib" - LIBRARIES="\${STATIC_LIBRARIES}" - EXESUFFIX="s\${DBGX}.exe" - DLLSUFFIX="" - else - # dynamic - AC_MSG_RESULT([using shared flags]) - runtime=-MD - MAKE_DLL="\${SHLIB_LD} \${SHLIB_LD_LIBS} \$(LDFLAGS) -out:\[$]@" - LIBSUFFIX="\${DBGX}.lib" - DLLSUFFIX="\${DBGX}.dll" - EXESUFFIX="\${DBGX}.exe" - LIBRARIES="\${SHARED_LIBRARIES}" - fi - - EXTRA_CFLAGS="-YX" - CFLAGS_DEBUG="-nologo -Z7 -Od -WX ${runtime}d" -# CFLAGS_OPTIMIZE="-nologo -O2 -Gs -GD ${runtime}" - CFLAGS_OPTIMIZE="-nologo -Oti -Gs -GD ${runtime}" - CFLAGS_WARNING="-W3" - LDFLAGS_DEBUG="-debug:full -debugtype:cv" - LDFLAGS_OPTIMIZE="-release" - PATHTYPE=-w - - # Specify the CC output file names based on the target name - CC_OBJNAME="-Fo\[$]@" - CC_EXENAME="-Fe\"\$(shell cygpath \$(PATHTYPE) '\[$]@')\"" - - # Specify linker flags depending on the type of app being - # built -- Console vs. Window. - LDFLAGS_CONSOLE="-subsystem:console" - LDFLAGS_WINDOW="-subsystem:windows" - fi -]) - -#------------------------------------------------------------------------ -# SC_WITH_TCL -- -# -# Location of the Tcl build directory. -# -# Arguments: -# none -# -# Results: -# -# Adds the following arguments to configure: -# --with-tcl=... -# -# Defines the following vars: -# TCL_BIN_DIR Full path to the tcl build dir. -#------------------------------------------------------------------------ - -AC_DEFUN(SC_WITH_TCL, [ - if test -d ../../tcl8.2$1/win; then - TCL_BIN_DEFAULT=../../tcl8.2$1/win - else - TCL_BIN_DEFAULT=../../tcl8.2/win - fi - - AC_ARG_WITH(tcl, [ --with-tcl=DIR use Tcl 8.2 binaries from DIR], - TCL_BIN_DIR=$withval, TCL_BIN_DIR=`cd $TCL_BIN_DEFAULT; pwd`) - if test ! -d $TCL_BIN_DIR; then - AC_MSG_ERROR(Tcl directory $TCL_BIN_DIR does not exist) - fi - if test ! -f $TCL_BIN_DIR/Makefile; then - AC_MSG_ERROR(There is no Makefile in $TCL_BIN_DIR: perhaps you did not specify the Tcl *build* directory (not the toplevel Tcl directory) or you forgot to configure Tcl?) - else - echo "building against Tcl binaries in: $TCL_BIN_DIR" - fi - AC_SUBST(TCL_BIN_DIR) -]) - +builtin(include,tcl.m4) diff --git a/win/makefile.vc b/win/makefile.vc index 00d7c8b..75caaf1 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -6,7 +6,7 @@ # Copyright (c) 1995-1996 Sun Microsystems, Inc. # Copyright (c) 1998-1999 by Scriptics Corporation. # -# RCS: @(#) $Id: makefile.vc,v 1.45 1999/10/29 03:05:12 hobbs Exp $ +# RCS: @(#) $Id: makefile.vc,v 1.46 1999/12/09 14:44:10 hobbs Exp $ # Does not depend on the presence of any environment variables in # order to compile tcl; all needed information is derived from @@ -22,27 +22,23 @@ # ones that come with the developer network CD's, or later # versions of VC++. # -# TOOLS16 = location of VC++ 1.5 16-bit tools, needed to build thunking -# library. This information is optional; if the 16-bit compiler -# is not available, then the 16-bit code will not be built. -# Tcl will still run without the 16-bit code, but... -# A. Under Windows 3.X any calls to the exec command -# will return an error. -# B. A 16-bit program to test the behavior of the exec -# command under NT and 95 will not be built. # INSTALLDIR = where the install- targets should copy the binaries and # support files # -ROOT = .. -TOOLS32 = c:\Progra~1\devstudio\vc -TOOLS32_rc = c:\Progra~1\devstudio\sharedide -TOOLS16 = c:\msvc +# Set this to the appropriate value of /MACHINE: for your platform +MACHINE = IX86 +ROOT = .. INSTALLDIR = c:\Progra~1\Tcl -# Set this to the appropriate value of /MACHINE: for your platform -MACHINE = IX86 +!IF "$(MACHINE)" == "IA64" +TOOLS32 = c:\ia64sdk17 +TOOLS32_rc = c:\ia64sdk17 +!ELSE +TOOLS32 = c:\Progra~1\devstudio\vc +TOOLS32_rc = c:\Progra~1\devstudio\sharedide +!ENDIF # Uncomment the following line to compile with thread support #THREADDEFINES = -DTCL_THREADS=1 @@ -94,7 +90,6 @@ TCLSTUBLIB = $(OUTDIR)\$(TCLSTUBLIBNAME) TCLPLUGINLIB = $(OUTDIR)\$(NAMEPREFIX)$(VERSION)p$(DBGX).lib TCLPLUGINDLLNAME= $(NAMEPREFIX)$(VERSION)p$(DBGX).dll TCLPLUGINDLL = $(OUTDIR)\$(TCLPLUGINDLLNAME) -TCL16DLL = $(OUTDIR)\$(NAMEPREFIX)16$(VERSION)$(DBGX).dll TCLSH = $(OUTDIR)\$(NAMEPREFIX)sh$(VERSION)$(DBGX).exe TCLSHP = $(OUTDIR)\$(NAMEPREFIX)shp$(VERSION)$(DBGX).exe TCLPIPEDLLNAME = $(NAMEPREFIX)pip$(VERSION)$(DBGX).dll @@ -104,8 +99,6 @@ TCLREGDLL = $(OUTDIR)\$(TCLREGDLLNAME) TCLDDEDLLNAME = $(NAMEPREFIX)dde$(VERSION)$(DBGX).dll TCLDDEDLL = $(OUTDIR)\$(TCLDDEDLLNAME) TCLTEST = $(OUTDIR)\$(NAMEPREFIX)test.exe -DUMPEXTS = $(TMPDIR)\dumpexts.exe -CAT16 = $(TMPDIR)\cat16.exe CAT32 = $(TMPDIR)\cat32.exe RMDIR = .\rmd.bat MKDIR = .\mkd.bat @@ -213,47 +206,64 @@ rc32 = "$(TOOLS32_rc)\bin\rc.exe" include32 = -I"$(TOOLS32)\include" lib32 = "$(TOOLS32)\bin\lib.exe" -cc16 = "$(TOOLS16)\bin\cl.exe" -link16 = "$(TOOLS16)\bin\link.exe" -rc16 = "$(TOOLS16)\bin\rc.exe" -include16 = -I"$(TOOLS16)\include" - WINDIR = $(ROOT)\win GENERICDIR = $(ROOT)\generic TCL_INCLUDES = -I$(WINDIR) -I$(GENERICDIR) -TCL_DEFINES = -D__WIN32__ $(DEBUGDEFINES) $(THREADDEFINES) +TCL_DEFINES = $(DEBUGDEFINES) $(THREADDEFINES) + +###################################################################### +# Compile flags +###################################################################### + +!IF "$(NODEBUG)" == "1" +# This cranks the optimization level to maximize speed +cdebug = -O2 -Gs -GD +!ELSE +!IF "$(MACHINE)" == "IA64" +cdebug = -Od -Zi +!ELSE +cdebug = -Z7 -Od -WX +!ENDIF +!ENDIF + +# declarations common to all compiler options +cflags = -c -W3 -nologo -Fp$(TMPDIR)\ -YX +cvarsdll = -MD$(DBGX) TCL_CFLAGS = $(cdebug) $(cflags) $(cvarsdll) $(include32) \ $(TCL_INCLUDES) $(TCL_DEFINES) -CON_CFLAGS = $(cdebug) $(cflags) $(cvars) $(include32) -DCONSOLE -DOS_CFLAGS = $(cdebug) $(cflags) $(include16) -AL -DLL16_CFLAGS = $(cdebug) $(cflags) $(include16) -ALw +CON_CFLAGS = $(cdebug) $(cflags) $(include32) -DCONSOLE ###################################################################### # Link flags ###################################################################### !IF "$(NODEBUG)" == "1" -ldebug = /RELEASE +ldebug = /RELEASE !ELSE -ldebug = -debug:full -debugtype:cv +ldebug = -debug:full -debugtype:cv !ENDIF # declarations common to all linker options -lcommon = /NODEFAULTLIB /RELEASE /NOLOGO +lcommon = /NODEFAULTLIB /RELEASE /NOLOGO +lflags = $(lcommon) /MACHINE:$(MACHINE) # declarations for use on Intel i386, i486, and Pentium systems !IF "$(MACHINE)" == "IX86" DLLENTRY = @12 -lflags = $(lcommon) /MACHINE:$(MACHINE) +dlllflags = $(lflags) -entry:_DllMainCRTStartup$(DLLENTRY) -dll +!ELSE +!IF "$(MACHINE)" == "IA64" +DLLENTRY = @12 +dlllflags = $(lflags) -dll !ELSE -lflags = $(lcommon) /MACHINE:$(MACHINE) +dlllflags = $(lflags) -entry:_DllMainCRTStartup$(DLLENTRY) -dll +!ENDIF !ENDIF conlflags = $(lflags) -subsystem:console -entry:mainCRTStartup guilflags = $(lflags) -subsystem:windows -entry:WinMainCRTStartup -dlllflags = $(lflags) -entry:_DllMainCRTStartup$(DLLENTRY) -dll !IF "$(MACHINE)" == "PPC" libc = libc$(DBGX).lib @@ -272,56 +282,16 @@ guilibsdll = $(libcdll) $(winlibs) conlibsdll = $(libcdll) $(baselibs) ###################################################################### -# Compile flags -###################################################################### - -!IF "$(NODEBUG)" == "1" -# This cranks the optimization level to maximize speed -cdebug = -O2 -Gs -GD -!ELSE -cdebug = -Z7 -Od -WX -!ENDIF - -# declarations common to all compiler options -ccommon = -c -W3 -nologo -YX -Fp$(TMPDIR)\ -Dtry=__try -Dexcept=__except - -!IF "$(MACHINE)" == "IX86" -cflags = $(ccommon) -D_X86_=1 -!ELSE -!IF "$(MACHINE)" == "MIPS" -cflags = $(ccommon) -D_MIPS_=1 -!ELSE -!IF "$(MACHINE)" == "PPC" -cflags = $(ccommon) -D_PPC_=1 -!ELSE -!IF "$(MACHINE)" == "ALPHA" -cflags = $(ccommon) -D_ALPHA_=1 -!ENDIF -!ENDIF -!ENDIF -!ENDIF - -cvars = -DWIN32 -D_WIN32 -cvarsmt = $(cvars) -D_MT -cvarsdll = $(cvarsmt) -D_DLL - -!IF "$(NODEBUG)" == "1" -cvarsdll = $(cvars) -MD -!ELSE -cvarsdll = $(cvars) -MDd -!ENDIF - -###################################################################### # Project specific targets ###################################################################### release: setup $(TCLSH) dlls -dlls: setup $(TCL16DLL) $(TCLPIPEDLL) $(TCLREGDLL) $(TCLDDEDLL) -all: setup $(TCLSH) dlls $(CAT16) $(CAT32) -tcltest: setup $(TCLTEST) dlls $(CAT16) $(CAT32) +dlls: setup $(TCLPIPEDLL) $(TCLREGDLL) $(TCLDDEDLL) +all: setup $(TCLSH) dlls $(CAT32) +tcltest: setup $(TCLTEST) dlls $(CAT32) plugin: setup $(TCLPLUGINDLL) $(TCLSHP) install: install-binaries install-libraries -test: setup $(TCLTEST) dlls $(CAT16) $(CAT32) +test: setup $(TCLTEST) dlls $(CAT32) set TCL_LIBRARY=$(ROOT)/library $(TCLTEST) $(ROOT)/tests/all.tcl @@ -329,17 +299,11 @@ setup: @$(MKDIR) $(TMPDIR) @$(MKDIR) $(OUTDIR) -$(DUMPEXTS): $(WINDIR)\winDumpExts.c - $(cc32) $(CON_CFLAGS) -Fo$(TMPDIR)\ $? - set LIB="$(TOOLS32)\lib" - $(link32) $(ldebug) $(conlflags) $(guilibs) -out:$@ \ - $(TMPDIR)\winDumpExts.obj - $(TCLLIB): $(TCLDLL) -$(TCLDLL): $(TCLOBJS) $(TMPDIR)\tcl.def $(TMPDIR)\tcl.res +$(TCLDLL): $(TCLOBJS) $(TMPDIR)\tcl.res set LIB="$(TOOLS32)\lib" - $(link32) $(ldebug) $(dlllflags) -def:$(TMPDIR)\tcl.def \ + $(link32) $(ldebug) $(dlllflags) \ -out:$@ $(TMPDIR)\tcl.res $(guilibsdll) @<< $(TCLOBJS) << @@ -349,9 +313,9 @@ $(TCLSTUBLIB): $(TCLSTUBOBJS) $(TCLPLUGINLIB): $(TCLPLUGINDLL) -$(TCLPLUGINDLL): $(TCLOBJS) $(TMPDIR)\plugin.def $(TMPDIR)\tcl.res +$(TCLPLUGINDLL): $(TCLOBJS) $(TMPDIR)\tcl.res set LIB="$(TOOLS32)\lib" - $(link32) $(ldebug) $(dlllflags) -def:$(TMPDIR)\plugin.def \ + $(link32) $(ldebug) $(dlllflags) \ -out:$@ $(TMPDIR)\tcl.res $(guilibsdll) @<< $(TCLOBJS) << @@ -371,29 +335,6 @@ $(TCLTEST): $(TCLTESTOBJS) $(TCLLIB) $(TMPDIR)\tclsh.res $(link32) $(ldebug) $(conlflags) $(TMPDIR)\tclsh.res -stack:2300000 \ -out:$@ $(conlibsdll) $(TCLLIB) $(TCLTESTOBJS) -$(TCL16DLL): $(WINDIR)\tcl16.rc $(WINDIR)\tclWin16.c - if exist $(cc16) $(cc16) @<< -$(DLL16_CFLAGS) -Fo$(TMPDIR)\ $(WINDIR)\tclWin16.c -<< - @copy << $(TMPDIR)\tclWin16.def > nul -LIBRARY $(@B);dll -EXETYPE WINDOWS -CODE PRELOAD MOVEABLE DISCARDABLE -DATA PRELOAD MOVEABLE SINGLE -HEAPSIZE 1024 -EXPORTS - WEP @1 RESIDENTNAME - UTPROC @2 -<< - if exist $(cc16) $(link16) /NOLOGO /ONERROR:NOEXE /NOE @<< -$(TMPDIR)\tclWin16.obj -$@ -nul -$(TOOLS16)\lib\ ldllcew oldnames libw toolhelp -$(TMPDIR)\tclWin16.def -<< - if exist $(cc16) $(rc16) -i $(GENERICDIR) $(TCL_DEFINES) $(WINDIR)\tcl16.rc $@ - $(TCLPIPEDLL): $(WINDIR)\stub16.c $(cc32) $(CON_CFLAGS) -Fo$(TMPDIR)\ $(WINDIR)\stub16.c set LIB="$(TOOLS32)\lib" @@ -414,22 +355,6 @@ $(CAT32): $(WINDIR)\cat.c set LIB="$(TOOLS32)\lib" $(link32) $(conlflags) -out:$@ -stack:16384 $(TMPDIR)\cat.obj $(conlibs) -$(CAT16): $(WINDIR)\cat.c - if exist $(cc16) $(cc16) $(DOS_CFLAGS) -Fo$(TMPDIR)\ $? - set LIB=$(TOOLS16)\lib - if exist $(cc16) $(link16) /NOLOGO /ONERROR:NOEXE /NOI /STACK:16384 \ - $(TMPDIR)\cat.obj,$@,nul,llibce.lib,nul - -$(TMPDIR)\tcl.def: $(DUMPEXTS) $(TCLOBJS) - $(DUMPEXTS) -o $@ $(TCLDLLNAME) @<< -$(TCLOBJS) -<< - -$(TMPDIR)\plugin.def: $(DUMPEXTS) $(TCLOBJS) - $(DUMPEXTS) -o $@ $(TCLPLUGINDLLNAME) @<< -$(TCLOBJS) -<< - install-binaries: $(TCLSH) $(MKDIR) "$(BIN_INSTALL_DIR)" $(MKDIR) "$(LIB_INSTALL_DIR)" @@ -579,7 +504,6 @@ clean: -@$(RM) $(TMPDIR)\*.pch -@$(RM) $(TMPDIR)\*.obj -@$(RM) $(TMPDIR)\*.res - -@$(RM) $(TMPDIR)\*.def -@$(RM) $(TMPDIR)\*.exe -@$(RMDIR) $(OUTDIR) -@$(RMDIR) $(TMPDIR) diff --git a/win/tcl16.rc b/win/tcl16.rc deleted file mode 100644 index 02c9b24..0000000 --- a/win/tcl16.rc +++ /dev/null @@ -1,37 +0,0 @@ -// RCS: @(#) $Id: tcl16.rc,v 1.3 1999/04/30 22:45:05 stanton Exp $ -// -// Version -// - -#define RESOURCE_INCLUDED -#include - -VS_VERSION_INFO VERSIONINFO - FILEVERSION TCL_MAJOR_VERSION,TCL_MINOR_VERSION,TCL_RELEASE_LEVEL,TCL_RELEASE_SERIAL - PRODUCTVERSION TCL_MAJOR_VERSION,TCL_MINOR_VERSION,TCL_RELEASE_LEVEL,TCL_RELEASE_SERIAL - FILEFLAGSMASK 0x3fL - FILEFLAGS 0x0L - FILEOS 0x1L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "FileDescription", "Tcl16 DLL, 16-bit thunking module\0" - VALUE "OriginalFilename", "tcl16" STRINGIFY(TCL_MAJOR_VERSION) STRINGIFY(TCL_MINOR_VERSION) ".dll\0" - VALUE "CompanyName", "Scriptics Corporation\0" - VALUE "FileVersion", TCL_PATCH_LEVEL - VALUE "LegalCopyright", "Copyright \251 1999 by Scriptics Corporation\0" - VALUE "ProductName", "Tcl " TCL_VERSION " for Windows\0" - VALUE "ProductVersion", TCL_PATCH_LEVEL - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - diff --git a/win/tclWin16.c b/win/tclWin16.c deleted file mode 100644 index dd82a34..0000000 --- a/win/tclWin16.c +++ /dev/null @@ -1,347 +0,0 @@ -/* - * tclWin16.c -- - * - * This file contains code for a 16-bit DLL to handle 32-to-16 bit - * thunking. This is necessary for the Win32s SynchSpawn() call. - * - * Copyright (c) 1994-1997 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * RCS: @(#) $Id: tclWin16.c,v 1.2 1998/09/14 18:40:19 stanton Exp $ - */ - -#define STRICT - -#include -#include - -#include -#include - -static int WinSpawn(char *command); -static int DosSpawn(char *command, char *fromFileName, - char *toFileName); -static int WaitForExit(int inst); - -/* - * The following data is used to construct a .pif file that wraps the - * .bat file that runs the 16-bit application (that Jack built). - * The .pif file causes the .bat file to run in an iconified window. - * Otherwise, when we try to exec something, a DOS box pops up, - * obscuring everything, and then almost immediately flickers out of - * existence, which is rather disconcerting. - */ - -static char pifData[545] = { -'\000', '\013', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\200', '\000', '\200', '\000', '\103', '\117', '\115', '\115', -'\101', '\116', '\104', '\056', '\103', '\117', '\115', '\000', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\020', '\000', '\000', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\177', '\001', '\000', -'\377', '\031', '\120', '\000', '\000', '\007', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\340', -'\040', '\115', '\111', '\103', '\122', '\117', '\123', '\117', -'\106', '\124', '\040', '\120', '\111', '\106', '\105', '\130', -'\000', '\207', '\001', '\000', '\000', '\161', '\001', '\127', -'\111', '\116', '\104', '\117', '\127', '\123', '\040', '\063', -'\070', '\066', '\040', '\063', '\056', '\060', '\000', '\005', -'\002', '\235', '\001', '\150', '\000', '\200', '\002', '\200', -'\000', '\144', '\000', '\062', '\000', '\000', '\004', '\000', -'\000', '\000', '\004', '\000', '\000', '\002', '\020', '\002', -'\000', '\037', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', -'\000', '\000', '\000', '\000', '\000', '\057', '\143', '\040', -'\146', '\157', '\157', '\056', '\142', '\141', '\164', '\000', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\040', '\040', '\040', -'\040', '\040', '\040', '\040', '\040', '\127', '\111', '\116', -'\104', '\117', '\127', '\123', '\040', '\062', '\070', '\066', -'\040', '\063', '\056', '\060', '\000', '\377', '\377', '\033', -'\002', '\006', '\000', '\000', '\000', '\000', '\000', '\000', -'\000' -}; - -static HINSTANCE hInstance; - - -/* - *---------------------------------------------------------------------- - * - * LibMain -- - * - * 16-bit DLL entry point. - * - * Results: - * Returns 1. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int CALLBACK -LibMain( - HINSTANCE hinst, - WORD wDS, - WORD cbHeap, - LPSTR unused) -{ - hInstance = hinst; - wDS = wDS; /* lint. */ - cbHeap = cbHeap; /* lint. */ - unused = unused; /* lint. */ - - return TRUE; -} - -/* - *---------------------------------------------------------------------- - * - * UTProc -- - * - * Universal Thunk dispatch routine. Executes a 16-bit DOS - * application or a 16-bit or 32-bit Windows application and - * waits for it to complete. - * - * Results: - * 1 if the application could be run, 0 or -1 on failure. - * - * Side effects: - * Executes 16-bit code. - * - *---------------------------------------------------------------------- - */ - -int WINAPI -UTProc(buf, func) - void *buf; - DWORD func; -{ - char **args; - - args = (char **) buf; - if (func == 0) { - return DosSpawn(args[0], args[1], args[2]); - } else { - return WinSpawn(args[0]); - } -} - -/* - *------------------------------------------------------------------------- - * - * WinSpawn -- - * - * Start a 16-bit or 32-bit Windows application with optional - * command line arguments and wait for it to finish. Windows - * applications do not handle input/output redirection. - * - * Results: - * The return value is 1 if the application could be run, 0 otherwise. - * - * Side effects: - * Whatever the application does. - * - *------------------------------------------------------------------------- - */ - -static int -WinSpawn(command) - char *command; /* The command line, consisting of the name - * of the executable to run followed by any - * number of arguments to the executable. */ -{ - return WaitForExit(WinExec(command, SW_SHOW)); -} - -/* - *--------------------------------------------------------------------------- - * - * DosSpawn -- - * - * Start a 16-bit DOS program with optional command line arguments - * and wait for it to finish. Input and output can be redirected - * from the specified files, but there is no such thing as stderr - * under Win32s. - * - * This procedure to constructs a temporary .pif file that wraps a - * temporary .bat file that runs the 16-bit application. The .bat - * file is necessary to get the redirection symbols '<' and '>' to - * work, because WinExec() doesn't accept them. The .pif file is - * necessary to cause the .bat file to run in an iconified window, - * to avoid having a large DOS box pop up, obscuring everything, and - * then almost immediately flicker out of existence, which is rather - * disconcerting. - * - * Results: - * The return value is 1 if the application could be run, 0 otherwise. - * - * Side effects: - * Whatever the application does. - * - *--------------------------------------------------------------------------- - */ - -static int -DosSpawn(command, fromFileName, toFileName) - char *command; /* The name of the program, plus any - * arguments, to be run. */ - char *fromFileName; /* Standard input for the program is to be - * redirected from this file, or NULL for no - * standard input. */ - char *toFileName; /* Standard output for the program is to be - * redirected to this file, or NULL to - * discard standard output. */ -{ - int result; - HFILE batFile, pifFile; - char batFileName[144], pifFileName[144]; - - GetTempFileName(0, "tcl", 0, batFileName); - unlink(batFileName); - strcpy(strrchr(batFileName, '.'), ".bat"); - batFile = _lcreat(batFileName, 0); - - GetTempFileName(0, "tcl", 0, pifFileName); - unlink(pifFileName); - strcpy(strrchr(pifFileName, '.'), ".pif"); - pifFile = _lcreat(pifFileName, 0); - - _lwrite(batFile, command, strlen(command)); - if (fromFileName == NULL) { - _lwrite(batFile, " < nul", 6); - } else { - _lwrite(batFile, " < ", 3); - _lwrite(batFile, fromFileName, strlen(fromFileName)); - } - if (toFileName == NULL) { - _lwrite(batFile, " > nul", 6); - } else { - _lwrite(batFile, " > ", 3); - _lwrite(batFile, toFileName, strlen(toFileName)); - } - _lwrite(batFile, "\r\n\032", 3); - _lclose(batFile); - - strcpy(pifData + 0x1c8, batFileName); - _lwrite(pifFile, pifData, sizeof(pifData)); - _lclose(pifFile); - - result = WaitForExit(WinExec(pifFileName, SW_MINIMIZE)); - - unlink(pifFileName); - unlink(batFileName); - - return result; -} - -/* - *------------------------------------------------------------------------- - * - * WaitForExit -- - * - * Wait until the application with the given instance handle has - * finished. PeekMessage() is used to yield the processor; - * otherwise, nothing else could execute on the system. - * - * Results: - * The return value is 1 if the process exited successfully, - * or 0 otherwise. - * - * Side effects: - * None. - * - *--------------------------------------------------------------------------- - */ - -static int -WaitForExit(inst) - int inst; /* Identifies the instance handle of the - * process to wait for. */ -{ - TASKENTRY te; - MSG msg; - UINT timer; - - if (inst < 32) { - return 0; - } - - te.dwSize = sizeof(te); - te.hInst = 0; - TaskFirst(&te); - do { - if (te.hInst == (HINSTANCE) inst) { - break; - } - } while (TaskNext(&te) != FALSE); - - if (te.hInst != (HINSTANCE) inst) { - return 0; - } - - timer = SetTimer(NULL, 0, 0, NULL); - while (1) { - if (GetMessage(&msg, NULL, 0, 0) != 0) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - TaskFirst(&te); - do { - if (te.hInst == (HINSTANCE) inst) { - break; - } - } while (TaskNext(&te) != FALSE); - - if (te.hInst != (HINSTANCE) inst) { - KillTimer(NULL, timer); - return 1; - } - } -} diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c index 349e770..eb43771 100644 --- a/win/tclWin32Dll.c +++ b/win/tclWin32Dll.c @@ -1,5 +1,4 @@ /* - * tclWin32Dll.c -- * * This file contains the DLL entry point which sets up the 32-to-16-bit @@ -10,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: tclWin32Dll.c,v 1.7 1999/04/23 01:57:23 stanton Exp $ + * RCS: @(#) $Id: tclWin32Dll.c,v 1.8 1999/12/09 14:44:10 hobbs Exp $ */ #include "tclWinInt.h" @@ -185,18 +184,6 @@ DllMain(hInst, reason, reserved) { switch (reason) { case DLL_PROCESS_ATTACH: - if (hInstance != NULL) { - /* - * Prevents DLL from being loaded multiple times under Win32s, - * since all copies of the DLL share the same data segment and - * Tcl isn't set up to handle that. Under NT or 95, each time - * the DLL is loaded, it gets its own private copy of the data - * segment. - */ - - return FALSE; - } - TclWinInit(hInst); return TRUE; @@ -344,18 +331,12 @@ TclWinInit(hInst) platformId = os.dwPlatformId; /* - * The following code stops Windows 3.x from automatically putting - * up Sharing Violation dialogs, e.g, when someone tries to - * access a file that is locked or a drive with no disk in it. - * Tcl already returns the appropriate error to the caller, and they - * can decide to put up their own dialog in response to that failure. - * - * Under 95 and NT, the system doesn't automatically put up dialogs - * when the above operations fail. + * We no longer support Win32s, so just in case someone manages to + * get a runtime there, make sure they know that. */ if (platformId == VER_PLATFORM_WIN32s) { - SetErrorMode(SetErrorMode(0) | SEM_FAILCRITICALERRORS); + panic("Win32s is not a supported platform"); } tclWinProcs = &asciiProcs; @@ -371,7 +352,7 @@ TclWinInit(hInst) * * Results: * The return value is one of: - * VER_PLATFORM_WIN32s Win32s on Windows 3.1. + * VER_PLATFORM_WIN32s Win32s on Windows 3.1. (not supported) * VER_PLATFORM_WIN32_WINDOWS Win32 on Windows 95. * VER_PLATFORM_WIN32_NT Win32 on Windows NT * diff --git a/win/tclWinChan.c b/win/tclWinChan.c index 1bca83d..28d7b51 100644 --- a/win/tclWinChan.c +++ b/win/tclWinChan.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: tclWinChan.c,v 1.8 1999/07/30 02:02:35 redman Exp $ + * RCS: @(#) $Id: tclWinChan.c,v 1.9 1999/12/09 14:44:10 hobbs Exp $ */ #include "tclWinInt.h" @@ -791,8 +791,7 @@ TclpOpenFileChannel(interp, fileName, modeString, permissions) channel = NULL; - switch (type) - { + switch (type) { case FILE_TYPE_SERIAL: channel = TclWinOpenSerialChannel(handle, channelName, channelPermissions); @@ -802,12 +801,10 @@ TclpOpenFileChannel(interp, fileName, modeString, permissions) channelPermissions); break; case FILE_TYPE_PIPE: - if (channelPermissions & TCL_READABLE) - { + if (channelPermissions & TCL_READABLE) { readFile = TclWinMakeFile(handle); } - if (channelPermissions & TCL_WRITABLE) - { + if (channelPermissions & TCL_WRITABLE) { writeFile = TclWinMakeFile(handle); } channel = TclpCreateCommandChannel(readFile, writeFile, NULL, 0, NULL); @@ -835,8 +832,7 @@ TclpOpenFileChannel(interp, fileName, modeString, permissions) Tcl_DStringFree(&buffer); Tcl_DStringFree(&ds); - if (channel != NULL) - { + if (channel != NULL) { if (seekFlag) { if (Tcl_Seek(channel, 0, SEEK_END) < 0) { if (interp != (Tcl_Interp *) NULL) { diff --git a/win/tclWinFCmd.c b/win/tclWinFCmd.c index aa9858b..1597583 100644 --- a/win/tclWinFCmd.c +++ b/win/tclWinFCmd.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: tclWinFCmd.c,v 1.6 1999/04/23 01:57:23 stanton Exp $ + * RCS: @(#) $Id: tclWinFCmd.c,v 1.7 1999/12/09 14:44:11 hobbs Exp $ */ #include "tclWinInt.h" @@ -159,20 +159,7 @@ TclpRenameFile( nativeSrc = Tcl_WinUtfToTChar(src, -1, &srcString); Tcl_WinUtfToTChar(dst, -1, &dstString); - if ((TclWinGetPlatformId() == VER_PLATFORM_WIN32s) - && ((Tcl_DStringLength(&srcString) >= MAX_PATH - 1) || - (Tcl_DStringLength(&dstString) >= MAX_PATH - 1))) { - /* - * On Win32s, really long file names cause the MoveFile() call - * to lock up, endlessly throwing an access violation and - * retrying the operation. - */ - - errno = ENAMETOOLONG; - result = TCL_ERROR; - } else { - result = DoRenameFile(nativeSrc, &dstString); - } + result = DoRenameFile(nativeSrc, &dstString); Tcl_DStringFree(&srcString); Tcl_DStringFree(&dstString); return result; @@ -224,16 +211,6 @@ DoRenameFile( errno = EACCES; return TCL_ERROR; } - if ((TclWinGetPlatformId() == VER_PLATFORM_WIN32s) && (errno == EACCES)) { - if ((srcAttr != 0) && (dstAttr != 0)) { - /* - * Win32s reports trying to overwrite an existing file or directory - * as EACCES. - */ - - errno = EEXIST; - } - } if (errno == EACCES) { decode: if (srcAttr & FILE_ATTRIBUTE_DIRECTORY) { @@ -687,13 +664,6 @@ DoCreateDirectory( nativePath = (TCHAR *) Tcl_DStringValue(pathPtr); if ((*tclWinProcs->createDirectoryProc)(nativePath, NULL) == 0) { error = GetLastError(); - if (TclWinGetPlatformId() == VER_PLATFORM_WIN32s) { - if ((error == ERROR_ACCESS_DENIED) - && ((*tclWinProcs->getFileAttributesProc)(nativePath) - != 0xffffffff)) { - error = ERROR_FILE_EXISTS; - } - } TclWinConvertError(error); return TCL_ERROR; } diff --git a/win/tclWinInit.c b/win/tclWinInit.c index 70895ca..c56958a 100644 --- a/win/tclWinInit.c +++ b/win/tclWinInit.c @@ -7,7 +7,7 @@ * Copyright (c) 1998-1999 by Scriptics Corporation. * All rights reserved. * - * RCS: @(#) $Id: tclWinInit.c,v 1.20 1999/07/22 21:50:57 redman Exp $ + * RCS: @(#) $Id: tclWinInit.c,v 1.21 1999/12/09 14:44:11 hobbs Exp $ */ #include "tclWinInt.h" @@ -553,15 +553,7 @@ TclpSetVariables(interp) GetVersionExA(&osInfo); oemId = (OemId *) &sysInfo; - if (osInfo.dwPlatformId == VER_PLATFORM_WIN32s) { - /* - * Since Win32s doesn't support GetSystemInfo, we use a default value. - */ - - oemId->wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL; - } else { - GetSystemInfo(&sysInfo); - } + GetSystemInfo(&sysInfo); /* * Initialize the tclDefaultLibrary variable from the registry. diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index 9f650ff..5c4b137 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.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: tclWinPipe.c,v 1.8 1999/07/31 01:24:25 redman Exp $ + * RCS: @(#) $Id: tclWinPipe.c,v 1.9 1999/12/09 14:44:11 hobbs Exp $ */ #include "tclWinInt.h" @@ -47,10 +47,9 @@ TCL_DECLARE_MUTEX(pipeMutex) /* * The following constants and structures are used to encapsulate the state * of various types of files used in a pipeline. + * This used to have a 1 && 2 that supported Win32s. */ -#define WIN32S_PIPE 1 /* Win32s emulated pipe. */ -#define WIN32S_TMPFILE 2 /* Win32s emulated temporary file. */ #define WIN_FILE 3 /* Basic Win32 file. */ /* @@ -64,36 +63,6 @@ typedef struct WinFile { } WinFile; /* - * The following structure is used to keep track of temporary files under - * Win32s and delete the disk file when the open handle is closed. - * The type field will be WIN32S_TMPFILE. - */ - -typedef struct TmpFile { - WinFile file; /* Common part. */ - char name[MAX_PATH]; /* Name of temp file. */ -} TmpFile; - -/* - * The following structure represents a synchronous pipe under Win32s. - * The type field will be WIN32S_PIPE. The handle field will refer to - * an open file when Tcl is reading from the "pipe", otherwise it is - * INVALID_HANDLE_VALUE. - */ - -typedef struct WinPipe { - WinFile file; /* Common part. */ - struct WinPipe *otherPtr; /* Pointer to the WinPipe structure that - * corresponds to the other end of this - * pipe. */ - char *fileName; /* The name of the staging file that gets - * the data written to this pipe. Malloc'd. - * and shared by both ends of the pipe. Only - * when both ends are freed will fileName be - * freed and the file it refers to deleted. */ -} WinPipe; - -/* * This list is used to map from pids to process handles. */ @@ -117,7 +86,7 @@ static ProcInfo *procList; */ #define PIPE_EOF (1<<2) /* Pipe has reached EOF. */ -#define PIPE_EXTRABYTE (1<<3) /* The reader thread has consumed one byte. */ +#define PIPE_EXTRABYTE (1<<3) /* The reader thread has consumed one byte. */ /* * This structure describes per-instance data for a pipe based channel. @@ -211,9 +180,7 @@ static int ApplicationType(Tcl_Interp *interp, const char *fileName, char *fullName); static void BuildCommandLine(const char *executable, int argc, char **argv, Tcl_DString *linePtr); -static void CopyChannel(HANDLE dst, HANDLE src); static BOOL HasConsole(void); -static char * MakeTempFile(Tcl_DString *namePtr); static int PipeBlockModeProc(ClientData instanceData, int mode); static void PipeCheckProc(ClientData clientData, int flags); static int PipeClose2Proc(ClientData instanceData, @@ -389,16 +356,13 @@ PipeSetupProc( infoPtr = infoPtr->nextPtr) { if (infoPtr->watchMask & TCL_WRITABLE) { filePtr = (WinFile*) infoPtr->writeFile; - if ((filePtr->type == WIN32S_PIPE) - || (WaitForSingleObject(infoPtr->writable, 0) - != WAIT_TIMEOUT)) { + if (WaitForSingleObject(infoPtr->writable, 0) != WAIT_TIMEOUT) { block = 0; } } if (infoPtr->watchMask & TCL_READABLE) { filePtr = (WinFile*) infoPtr->readFile; - if ((filePtr->type == WIN32S_PIPE) - || (WaitForRead(infoPtr, 0) >= 0)) { + if (WaitForRead(infoPtr, 0) >= 0) { block = 0; } } @@ -457,20 +421,15 @@ PipeCheckProc( needEvent = 0; filePtr = (WinFile*) infoPtr->writeFile; - if (infoPtr->watchMask & TCL_WRITABLE) { - if ((filePtr->type == WIN32S_PIPE) - || (WaitForSingleObject(infoPtr->writable, 0) - != WAIT_TIMEOUT)) { - needEvent = 1; - } + if ((infoPtr->watchMask & TCL_WRITABLE) && + (WaitForSingleObject(infoPtr->writable, 0) != WAIT_TIMEOUT)) { + needEvent = 1; } filePtr = (WinFile*) infoPtr->readFile; - if (infoPtr->watchMask & TCL_READABLE) { - if ((filePtr->type == WIN32S_PIPE) - || (WaitForRead(infoPtr, 0) >= 0)) { - needEvent = 1; - } + if ((infoPtr->watchMask & TCL_READABLE) && + (WaitForRead(infoPtr, 0) >= 0)) { + needEvent = 1; } if (needEvent) { @@ -779,20 +738,7 @@ TclpCreateTempFile(contents) } } - /* - * Under Win32s a file created with FILE_FLAG_DELETE_ON_CLOSE won't - * actually be deleted when it is closed, so we have to do it ourselves. - */ - - if (TclWinGetPlatformId() == VER_PLATFORM_WIN32s) { - TmpFile *tmpFilePtr = (TmpFile *) ckalloc(sizeof(TmpFile)); - tmpFilePtr->file.type = WIN32S_TMPFILE; - tmpFilePtr->file.handle = handle; - lstrcpyA(tmpFilePtr->name, (char *) name); - return (TclFile) tmpFilePtr; - } else { - return TclWinMakeFile(handle); - } + return TclWinMakeFile(handle); error: TclWinConvertError(GetLastError()); @@ -806,8 +752,7 @@ TclpCreateTempFile(contents) * * TclpCreatePipe -- * - * Creates an anonymous pipe. Under Win32s, creates a temp file - * that is used to simulate a pipe. + * Creates an anonymous pipe. * * Results: * Returns 1 on success, 0 on failure. @@ -833,33 +778,6 @@ TclpCreatePipe( return 1; } - if (TclWinGetPlatformId() == VER_PLATFORM_WIN32s) { - WinPipe *readPipePtr, *writePipePtr; - char buf[MAX_PATH]; - int bytes; - - if (TempFileName((WCHAR *) buf) != 0) { - bytes = strlen((char *) buf) + 1; - readPipePtr = (WinPipe *) ckalloc(sizeof(WinPipe)); - writePipePtr = (WinPipe *) ckalloc(sizeof(WinPipe)); - - readPipePtr->file.type = WIN32S_PIPE; - readPipePtr->otherPtr = writePipePtr; - readPipePtr->fileName = (char *) ckalloc(bytes); - lstrcpyA(readPipePtr->fileName, buf); - readPipePtr->file.handle = INVALID_HANDLE_VALUE; - writePipePtr->file.type = WIN32S_PIPE; - writePipePtr->otherPtr = readPipePtr; - writePipePtr->fileName = readPipePtr->fileName; - writePipePtr->file.handle = INVALID_HANDLE_VALUE; - - *readPipe = (TclFile) readPipePtr; - *writePipe = (TclFile) writePipePtr; - - return 1; - } - } - TclWinConvertError(GetLastError()); return 0; } @@ -886,15 +804,13 @@ TclpCloseFile( TclFile file) /* The file to close. */ { WinFile *filePtr = (WinFile *) file; - WinPipe *pipePtr; switch (filePtr->type) { case WIN_FILE: - case WIN32S_TMPFILE: /* * Don't close the Win32 handle if the handle is a standard channel - * during the exit process. Otherwise, one thread may kill the stdio - * of another. + * during the exit process. Otherwise, one thread may kill the + * stdio of another. */ if (!TclInExit() @@ -907,27 +823,6 @@ TclpCloseFile( return -1; } } - /* - * Simulate deleting the file on close for Win32s. - */ - - if (filePtr->type == WIN32S_TMPFILE) { - DeleteFileA(((TmpFile *) filePtr)->name); - } - break; - - case WIN32S_PIPE: - pipePtr = (WinPipe *) file; - - if (pipePtr->otherPtr != NULL) { - pipePtr->otherPtr->otherPtr = NULL; - } else { - if (pipePtr->file.handle != INVALID_HANDLE_VALUE) { - CloseHandle(pipePtr->file.handle); - } - DeleteFileA(pipePtr->fileName); - ckfree((char *) pipePtr->fileName); - } break; default: @@ -981,9 +876,8 @@ TclpGetPid( * * Create a child process that has the specified files as its * standard input, output, and error. The child process runs - * synchronously under Win32s and asynchronously under Windows NT - * and Windows 95, and runs with the same environment variables - * as the creating process. + * asynchronously under Windows NT and Windows 9x, and runs + * with the same environment variables as the creating process. * * The complete Windows search path is searched to find the specified * executable. If an executable by the given name is not found, @@ -1050,158 +944,6 @@ TclpCreateProcess( result = TCL_ERROR; Tcl_DStringInit(&cmdLine); - - if (TclWinGetPlatformId() == VER_PLATFORM_WIN32s) { - /* - * Under Win32s, there are no pipes. In order to simulate pipe - * behavior, the child processes are run synchronously and their - * I/O is redirected from/to temporary files before the next - * stage of the pipeline is started. - */ - - MSG msg; - DWORD status; - DWORD args[4]; - void *trans[5]; - char *inputFileName, *outputFileName; - Tcl_DString inputTempFile, outputTempFile; - - BuildCommandLine(execPath, argc, argv, &cmdLine); - - ZeroMemory(&startInfo, sizeof(startInfo)); - startInfo.cb = sizeof(startInfo); - - Tcl_DStringInit(&inputTempFile); - Tcl_DStringInit(&outputTempFile); - outputHandle = INVALID_HANDLE_VALUE; - - inputFileName = NULL; - outputFileName = NULL; - if (inputFile != NULL) { - filePtr = (WinFile *) inputFile; - switch (filePtr->type) { - case WIN_FILE: - case WIN32S_TMPFILE: { - h = INVALID_HANDLE_VALUE; - inputFileName = MakeTempFile(&inputTempFile); - if (inputFileName != NULL) { - h = CreateFileA((char *) inputFileName, - GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, - NULL); - } - if (h == INVALID_HANDLE_VALUE) { - Tcl_AppendResult(interp, "couldn't duplicate input handle: ", - Tcl_PosixError(interp), (char *) NULL); - goto end32s; - } - CopyChannel(h, filePtr->handle); - CloseHandle(h); - break; - } - case WIN32S_PIPE: { - inputFileName = (char *) ((WinPipe *) inputFile)->fileName; - break; - } - } - } - if (inputFileName == NULL) { - inputFileName = "nul"; - } - if (outputFile != NULL) { - filePtr = (WinFile *) outputFile; - if (filePtr->type == WIN_FILE) { - outputFileName = MakeTempFile(&outputTempFile); - if (outputFileName == NULL) { - Tcl_AppendResult(interp, "couldn't duplicate output handle: ", - Tcl_PosixError(interp), (char *) NULL); - goto end32s; - } - outputHandle = filePtr->handle; - } else if (filePtr->type == WIN32S_PIPE) { - outputFileName = (char *) ((WinPipe *) outputFile)->fileName; - } - } - if (outputFileName == NULL) { - outputFileName = "nul"; - } - - if (applType == APPL_DOS) { - args[0] = (DWORD) Tcl_DStringValue(&cmdLine); - args[1] = (DWORD) inputFileName; - args[2] = (DWORD) outputFileName; - trans[0] = &args[0]; - trans[1] = &args[1]; - trans[2] = &args[2]; - trans[3] = NULL; - if (TclWinSynchSpawn(args, 0, trans, pidPtr) != 0) { - result = TCL_OK; - } - } else if (applType == APPL_WIN3X) { - args[0] = (DWORD) Tcl_DStringValue(&cmdLine); - trans[0] = &args[0]; - trans[1] = NULL; - if (TclWinSynchSpawn(args, 1, trans, pidPtr) != 0) { - result = TCL_OK; - } - } else { - if (CreateProcessA(NULL, Tcl_DStringValue(&cmdLine), - NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, - &startInfo, &procInfo) != 0) { - CloseHandle(procInfo.hThread); - while (1) { - if (GetExitCodeProcess(procInfo.hProcess, &status) == FALSE) { - break; - } - if (status != STILL_ACTIVE) { - break; - } - if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) == TRUE) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - *pidPtr = (Tcl_Pid) procInfo.hProcess; - if (*pidPtr != 0) { - TclWinAddProcess(procInfo.hProcess, procInfo.dwProcessId); - } - result = TCL_OK; - } - } - if (result != TCL_OK) { - TclWinConvertError(GetLastError()); - Tcl_AppendResult(interp, "couldn't execute \"", argv[0], - "\": ", Tcl_PosixError(interp), (char *) NULL); - } - - end32s: - if (outputHandle != INVALID_HANDLE_VALUE) { - /* - * Now copy stuff from temp file to actual output handle. Don't - * close outputHandle because it is associated with the output - * file owned by the caller. - */ - - h = CreateFileA(outputFileName, GENERIC_READ, 0, NULL, OPEN_ALWAYS, - 0, NULL); - if (h != INVALID_HANDLE_VALUE) { - CopyChannel(outputHandle, h); - } - CloseHandle(h); - } - - if (inputFileName == Tcl_DStringValue(&inputTempFile)) { - DeleteFileA(inputFileName); - } - - if (outputFileName == Tcl_DStringValue(&outputTempFile)) { - DeleteFileA(outputFileName); - } - - Tcl_DStringFree(&inputTempFile); - Tcl_DStringFree(&outputTempFile); - Tcl_DStringFree(&cmdLine); - return result; - } hProcess = GetCurrentProcess(); /* @@ -1821,80 +1563,6 @@ BuildCommandLine( /* *---------------------------------------------------------------------- * - * MakeTempFile -- - * - * Helper function for TclpCreateProcess under Win32s. Makes a - * temporary file that _won't_ go away automatically when it's file - * handle is closed. Used for simulated pipes, which are written - * in one pass and reopened and read in the next pass. - * - * Results: - * namePtr is filled with the name of the temporary file. - * - * Side effects: - * A temporary file with the name specified by namePtr is created. - * The caller is responsible for deleting this temporary file. - * - *---------------------------------------------------------------------- - */ - -static char * -MakeTempFile(namePtr) - Tcl_DString *namePtr; /* Initialized Tcl_DString that is filled - * with the name of the temporary file that - * was created. */ -{ - char name[MAX_PATH]; - - if (TempFileName((WCHAR *) name) == 0) { - return NULL; - } - - Tcl_DStringAppend(namePtr, name, -1); - return Tcl_DStringValue(namePtr); -} - -/* - *---------------------------------------------------------------------- - * - * CopyChannel -- - * - * Helper function used by TclpCreateProcess under Win32s. Copies - * what remains of source file to destination file; source file - * pointer need not be positioned at the beginning of the file if - * all of source file is not desired, but data is copied up to end - * of source file. - * - * Results: - * None. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -static void -CopyChannel( - HANDLE dst, /* Destination file. */ - HANDLE src) /* Source file. */ -{ - char buf[8192]; - DWORD dwRead, dwWrite; - - while (ReadFile(src, buf, sizeof(buf), &dwRead, NULL) != FALSE) { - if (dwRead == 0) { - break; - } - if (WriteFile(dst, buf, dwRead, &dwWrite, NULL) == FALSE) { - break; - } - } -} - -/* - *---------------------------------------------------------------------- - * * TclpCreateCommandChannel -- * * This function is called by Tcl_OpenCommandChannel to perform @@ -1923,16 +1591,6 @@ TclpCreateCommandChannel( int channelId; DWORD id; PipeInfo *infoPtr = (PipeInfo *) ckalloc((unsigned) sizeof(PipeInfo)); - OSVERSIONINFO os; - int useThreads; - - /* - * Fetch the OS version info. - */ - - os.dwOSVersionInfoSize = sizeof(os); - GetVersionEx(&os); - useThreads = (os.dwPlatformId != VER_PLATFORM_WIN32s); PipeInit(); @@ -1954,13 +1612,7 @@ TclpCreateCommandChannel( */ if (readFile) { - WinPipe *pipePtr = (WinPipe *) readFile; - if (pipePtr->file.type == WIN32S_PIPE - && pipePtr->file.handle == INVALID_HANDLE_VALUE) { - pipePtr->file.handle = CreateFileA(pipePtr->fileName, GENERIC_READ, - 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - } - channelId = (int) pipePtr->file.handle; + channelId = (int) ((WinFile*)readFile)->handle; } else if (writeFile) { channelId = (int) ((WinFile*)writeFile)->handle; } else if (errorFile) { @@ -1974,37 +1626,29 @@ TclpCreateCommandChannel( infoPtr->threadId = Tcl_GetCurrentThread(); if (readFile != NULL) { - if (useThreads) { - /* - * Start the background reader thread. - */ + /* + * Start the background reader thread. + */ - infoPtr->readable = CreateEvent(NULL, TRUE, TRUE, NULL); - infoPtr->startReader = CreateEvent(NULL, FALSE, FALSE, NULL); - infoPtr->readThread = CreateThread(NULL, 8000, PipeReaderThread, - infoPtr, 0, &id); - SetThreadPriority(infoPtr->readThread, THREAD_PRIORITY_HIGHEST); - } else { - infoPtr->readThread = 0; - } + infoPtr->readable = CreateEvent(NULL, TRUE, TRUE, NULL); + infoPtr->startReader = CreateEvent(NULL, FALSE, FALSE, NULL); + infoPtr->readThread = CreateThread(NULL, 8000, PipeReaderThread, + infoPtr, 0, &id); + SetThreadPriority(infoPtr->readThread, THREAD_PRIORITY_HIGHEST); infoPtr->validMask |= TCL_READABLE; } else { infoPtr->readThread = 0; } if (writeFile != NULL) { - if (useThreads) { - /* - * Start the background writeer thwrite. - */ + /* + * Start the background writeer thwrite. + */ - infoPtr->writable = CreateEvent(NULL, TRUE, TRUE, NULL); - infoPtr->startWriter = CreateEvent(NULL, FALSE, FALSE, NULL); - infoPtr->writeThread = CreateThread(NULL, 8000, PipeWriterThread, - infoPtr, 0, &id); - SetThreadPriority(infoPtr->readThread, THREAD_PRIORITY_HIGHEST); - } else { - infoPtr->writeThread = 0; - } + infoPtr->writable = CreateEvent(NULL, TRUE, TRUE, NULL); + infoPtr->startWriter = CreateEvent(NULL, FALSE, FALSE, NULL); + infoPtr->writeThread = CreateThread(NULL, 8000, PipeWriterThread, + infoPtr, 0, &id); + SetThreadPriority(infoPtr->readThread, THREAD_PRIORITY_HIGHEST); infoPtr->validMask |= TCL_WRITABLE; } @@ -2262,25 +1906,16 @@ PipeClose2Proc( /* * Wrap the error file into a channel and give it to the cleanup - * routine. If we are running in Win32s, just delete the error file - * immediately, because it was never used. + * routine. */ if (pipePtr->errorFile) { WinFile *filePtr; - OSVERSIONINFO os; - os.dwOSVersionInfoSize = sizeof(os); - GetVersionEx(&os); - if (os.dwPlatformId == VER_PLATFORM_WIN32s) { - TclpCloseFile(pipePtr->errorFile); - errChan = NULL; - } else { - filePtr = (WinFile*)pipePtr->errorFile; - errChan = Tcl_MakeFileChannel((ClientData) filePtr->handle, - TCL_READABLE); - ckfree((char *) filePtr); - } + filePtr = (WinFile*)pipePtr->errorFile; + errChan = Tcl_MakeFileChannel((ClientData) filePtr->handle, + TCL_READABLE); + ckfree((char *) filePtr); } else { errChan = NULL; } @@ -2336,53 +1971,39 @@ PipeInputProc( int result; *errorCode = 0; - if (filePtr->type == WIN32S_PIPE) { - if (((WinPipe *)filePtr)->otherPtr != NULL) { - panic("PipeInputProc: child process isn't finished writing"); - } - if (filePtr->handle == INVALID_HANDLE_VALUE) { - filePtr->handle = CreateFileA(((WinPipe *)filePtr)->fileName, - GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, - NULL); - } - if (filePtr->handle == INVALID_HANDLE_VALUE) { - goto error; - } - } else { - /* - * Synchronize with the reader thread. - */ + /* + * Synchronize with the reader thread. + */ - result = WaitForRead(infoPtr, (infoPtr->flags & PIPE_ASYNC) ? 0 : 1); + result = WaitForRead(infoPtr, (infoPtr->flags & PIPE_ASYNC) ? 0 : 1); - /* - * If an error occurred, return immediately. - */ + /* + * If an error occurred, return immediately. + */ - if (result == -1) { - *errorCode = errno; - return -1; - } + if (result == -1) { + *errorCode = errno; + return -1; + } - if (infoPtr->readFlags & PIPE_EXTRABYTE) { - /* - * The reader thread consumed 1 byte as a side effect of - * waiting so we need to move it into the buffer. - */ + if (infoPtr->readFlags & PIPE_EXTRABYTE) { + /* + * The reader thread consumed 1 byte as a side effect of + * waiting so we need to move it into the buffer. + */ - *buf = infoPtr->extraByte; - infoPtr->readFlags &= ~PIPE_EXTRABYTE; - buf++; - bufSize--; - bytesRead = 1; + *buf = infoPtr->extraByte; + infoPtr->readFlags &= ~PIPE_EXTRABYTE; + buf++; + bufSize--; + bytesRead = 1; - /* - * If further read attempts would block, return what we have. - */ + /* + * If further read attempts would block, return what we have. + */ - if (result == 0) { - return bytesRead; - } + if (result == 0) { + return bytesRead; } } @@ -2403,7 +2024,6 @@ PipeInputProc( return bytesRead; } - error: TclWinConvertError(GetLastError()); if (errno == EPIPE) { infoPtr->readFlags |= PIPE_EOF; @@ -2567,31 +2187,26 @@ PipeEventProc( } /* - * If we aren't on Win32s, check to see if the pipe is readable. Note + * Check to see if the pipe is readable. Note * that we can't tell if a pipe is writable, so we always report it * as being writable unless we have detected EOF. */ filePtr = (WinFile*) ((PipeInfo*)infoPtr)->writeFile; mask = 0; - if (infoPtr->watchMask & TCL_WRITABLE) { - if ((filePtr->type == WIN32S_PIPE) - || (WaitForSingleObject(infoPtr->writable, 0) - != WAIT_TIMEOUT)) { - mask = TCL_WRITABLE; - } + if ((infoPtr->watchMask & TCL_WRITABLE) && + (WaitForSingleObject(infoPtr->writable, 0) != WAIT_TIMEOUT)) { + mask = TCL_WRITABLE; } filePtr = (WinFile*) ((PipeInfo*)infoPtr)->readFile; - if (infoPtr->watchMask & TCL_READABLE) { - if ((filePtr->type == WIN32S_PIPE) - || (WaitForRead(infoPtr, 0) >= 0)) { - if (infoPtr->readFlags & PIPE_EOF) { - mask = TCL_READABLE; - } else { - mask |= TCL_READABLE; - } - } + if ((infoPtr->watchMask & TCL_READABLE) && + (WaitForRead(infoPtr, 0) >= 0)) { + if (infoPtr->readFlags & PIPE_EOF) { + mask = TCL_READABLE; + } else { + mask |= TCL_READABLE; + } } /* @@ -2692,16 +2307,6 @@ PipeGetHandleProc( if (direction == TCL_READABLE && infoPtr->readFile) { filePtr = (WinFile*) infoPtr->readFile; - if (filePtr->type == WIN32S_PIPE) { - if (filePtr->handle == INVALID_HANDLE_VALUE) { - filePtr->handle = CreateFileA(((WinPipe *)filePtr)->fileName, - GENERIC_READ, 0, NULL, OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, NULL); - } - if (filePtr->handle == INVALID_HANDLE_VALUE) { - return TCL_ERROR; - } - } *handlePtr = (ClientData) filePtr->handle; return TCL_OK; } diff --git a/win/tclWinSock.c b/win/tclWinSock.c index c39d8ba..957f72c 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.17 1999/08/01 22:09:29 redman Exp $ + * RCS: @(#) $Id: tclWinSock.c,v 1.18 1999/12/09 14:44:11 hobbs Exp $ */ #include "tclWinInt.h" @@ -260,40 +260,19 @@ InitSockets() { DWORD id; WSADATA wsaData; - OSVERSIONINFO info; ThreadSpecificData *tsdPtr = (ThreadSpecificData *)TclThreadDataKeyGet(&dataKey); if (! initialized) { initialized = 1; Tcl_CreateExitHandler(SocketExitHandler, (ClientData) NULL); - - /* - * Find out if we're running on Win32s. - */ - - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&info); - - /* - * Check to see if Sockets are supported on this system. Since - * win32s panics if we call WSAStartup on a system that doesn't - * have winsock.dll, we need to look for it on the system first. - * If we find winsock, then load the library and initialize the - * stub table. - */ - - if ((info.dwPlatformId != VER_PLATFORM_WIN32s) - || (SearchPathA(NULL, "WINSOCK", ".DLL", 0, NULL, NULL) != 0)) { - winSock.hInstance = LoadLibraryA("wsock32.dll"); - } else { - winSock.hInstance = NULL; - } - + + winSock.hInstance = LoadLibraryA("wsock32.dll"); + /* * Initialize the function table. */ - + if (!SocketsEnabled()) { return; } @@ -1801,7 +1780,7 @@ TcpOutputProc(instanceData, buf, toWrite, errorCodePtr) * use sockets. */ - if (! SocketsEnabled()) { + if (!SocketsEnabled()) { *errorCodePtr = EFAULT; return -1; } @@ -2161,8 +2140,12 @@ SocketThread(LPVOID arg) * store the tsdPtr, it's from a different thread, so it's * not directly accessible, but needed. */ - + +#ifdef _WIN64 + SetWindowLongPtr(tsdPtr->hwnd, GWLP_USERDATA, (LONG) tsdPtr); +#else SetWindowLong(tsdPtr->hwnd, GWL_USERDATA, (LONG) tsdPtr); +#endif } while (1) { @@ -2208,8 +2191,11 @@ SocketProc(hwnd, message, wParam, lParam) SOCKET socket; SocketInfo *infoPtr; ThreadSpecificData *tsdPtr = +#ifdef _WIN64 + (ThreadSpecificData *) GetWindowLongPtr(hwnd, GWLP_USERDATA); +#else (ThreadSpecificData *) GetWindowLong(hwnd, GWL_USERDATA); - +#endif switch (message) { @@ -2299,8 +2285,7 @@ SocketProc(hwnd, message, wParam, lParam) * Clear the selection mask */ - (void) (*winSock.WSAAsyncSelect)(infoPtr->socket, hwnd, - 0, 0); + (void) (*winSock.WSAAsyncSelect)(infoPtr->socket, hwnd, 0, 0); } break; case SOCKET_TERMINATE: diff --git a/win/winDumpExts.c b/win/winDumpExts.c deleted file mode 100644 index 295bdd9..0000000 --- a/win/winDumpExts.c +++ /dev/null @@ -1,505 +0,0 @@ -/* - * winDumpExts.c -- - * Author: Gordon Chaffee, Scott Stanton - * - * History: The real functionality of this file was written by - * Matt Pietrek in 1993 in his pedump utility. I've - * modified it to dump the externals in a bunch of object - * files to create a .def file. - * - * 10/12/95 Modified by Scott Stanton to support Relocatable Object Module - * Format files for Borland C++ 4.5. - * - * Notes: Visual C++ puts an underscore before each exported symbol. - * This file removes them. I don't know if this is a problem - * this other compilers. If _MSC_VER is defined, - * the underscore is removed. If not, it isn't. To get a - * full dump of an object file, use the -f option. This can - * help determine the something that may be different with a - * compiler other than Visual C++. - *---------------------------------------------------------------------- - * - * RCS: @(#) $Id: winDumpExts.c,v 1.5 1999/05/07 23:40:38 stanton Exp $ - */ - -#include -#include -#include -#include - -#ifdef _ALPHA_ -#define e_magic_number IMAGE_FILE_MACHINE_ALPHA -#else -#define e_magic_number IMAGE_FILE_MACHINE_I386 -#endif - -/* - *---------------------------------------------------------------------- - * GetArgcArgv -- - * - * Break up a line into argc argv - *---------------------------------------------------------------------- - */ -int -GetArgcArgv(char *s, char **argv) -{ - int quote = 0; - int argc = 0; - char *bp; - - bp = s; - while (1) { - while (isspace(*bp)) { - bp++; - } - if (*bp == '\n' || *bp == '\0') { - *bp = '\0'; - return argc; - } - if (*bp == '\"') { - quote = 1; - bp++; - } - argv[argc++] = bp; - - while (*bp != '\0') { - if (quote) { - if (*bp == '\"') { - quote = 0; - *bp = '\0'; - bp++; - break; - } - bp++; - continue; - } - if (isspace(*bp)) { - *bp = '\0'; - bp++; - break; - } - bp++; - } - } -} - -/* - * The names of the first group of possible symbol table storage classes - */ -char * SzStorageClass1[] = { - "NULL","AUTOMATIC","EXTERNAL","STATIC","REGISTER","EXTERNAL_DEF","LABEL", - "UNDEFINED_LABEL","MEMBER_OF_STRUCT","ARGUMENT","STRUCT_TAG", - "MEMBER_OF_UNION","UNION_TAG","TYPE_DEFINITION","UNDEFINED_STATIC", - "ENUM_TAG","MEMBER_OF_ENUM","REGISTER_PARAM","BIT_FIELD" -}; - -/* - * The names of the second group of possible symbol table storage classes - */ -char * SzStorageClass2[] = { - "BLOCK","FUNCTION","END_OF_STRUCT","FILE","SECTION","WEAK_EXTERNAL" -}; - -/* - *---------------------------------------------------------------------- - * GetSZStorageClass -- - * - * Given a symbol storage class value, return a descriptive - * ASCII string - *---------------------------------------------------------------------- - */ -PSTR -GetSZStorageClass(BYTE storageClass) -{ - if ( storageClass <= IMAGE_SYM_CLASS_BIT_FIELD ) - return SzStorageClass1[storageClass]; - else if ( (storageClass >= IMAGE_SYM_CLASS_BLOCK) - && (storageClass <= IMAGE_SYM_CLASS_WEAK_EXTERNAL) ) - return SzStorageClass2[storageClass-IMAGE_SYM_CLASS_BLOCK]; - else - return "???"; -} - -/* - *---------------------------------------------------------------------- - * GetSectionName -- - * - * Used by DumpSymbolTable, it gives meaningful names to - * the non-normal section number. - * - * Results: - * A name is returned in buffer - *---------------------------------------------------------------------- - */ -void -GetSectionName(WORD section, PSTR buffer, unsigned cbBuffer) -{ - char tempbuffer[10]; - - switch ( (SHORT)section ) - { - case IMAGE_SYM_UNDEFINED: strcpy(tempbuffer, "UNDEF"); break; - case IMAGE_SYM_ABSOLUTE: strcpy(tempbuffer, "ABS "); break; - case IMAGE_SYM_DEBUG: strcpy(tempbuffer, "DEBUG"); break; - default: wsprintf(tempbuffer, "%-5X", section); - } - - strncpy(buffer, tempbuffer, cbBuffer-1); -} - -/* - *---------------------------------------------------------------------- - * DumpSymbolTable -- - * - * Dumps a COFF symbol table from an EXE or OBJ. We only use - * it to dump tables from OBJs. - *---------------------------------------------------------------------- - */ -void -DumpSymbolTable(PIMAGE_SYMBOL pSymbolTable, FILE *fout, unsigned cSymbols) -{ - unsigned i; - PSTR stringTable; - char sectionName[10]; - - fprintf(fout, "Symbol Table - %X entries (* = auxillary symbol)\n", - cSymbols); - - fprintf(fout, - "Indx Name Value Section cAux Type Storage\n" - "---- -------------------- -------- ---------- ----- ------- --------\n"); - - /* - * The string table apparently starts right after the symbol table - */ - stringTable = (PSTR)&pSymbolTable[cSymbols]; - - for ( i=0; i < cSymbols; i++ ) { - fprintf(fout, "%04X ", i); - if ( pSymbolTable->N.Name.Short != 0 ) - fprintf(fout, "%-20.8s", pSymbolTable->N.ShortName); - else - fprintf(fout, "%-20s", stringTable + pSymbolTable->N.Name.Long); - - fprintf(fout, " %08X", pSymbolTable->Value); - - GetSectionName(pSymbolTable->SectionNumber, sectionName, - sizeof(sectionName)); - fprintf(fout, " sect:%s aux:%X type:%02X st:%s\n", - sectionName, - pSymbolTable->NumberOfAuxSymbols, - pSymbolTable->Type, - GetSZStorageClass(pSymbolTable->StorageClass) ); -#if 0 - if ( pSymbolTable->NumberOfAuxSymbols ) - DumpAuxSymbols(pSymbolTable); -#endif - - /* - * Take into account any aux symbols - */ - i += pSymbolTable->NumberOfAuxSymbols; - pSymbolTable += pSymbolTable->NumberOfAuxSymbols; - pSymbolTable++; - } -} - -/* - *---------------------------------------------------------------------- - * DumpExternals -- - * - * Dumps a COFF symbol table from an EXE or OBJ. We only use - * it to dump tables from OBJs. - *---------------------------------------------------------------------- - */ -void -DumpExternals(PIMAGE_SYMBOL pSymbolTable, FILE *fout, unsigned cSymbols) -{ - unsigned i; - PSTR stringTable; - char *s, *f; - char symbol[1024]; - - /* - * The string table apparently starts right after the symbol table - */ - stringTable = (PSTR)&pSymbolTable[cSymbols]; - - for ( i=0; i < cSymbols; i++ ) { - if (pSymbolTable->SectionNumber > 0 && pSymbolTable->Type == 0x20) { - if (pSymbolTable->StorageClass == IMAGE_SYM_CLASS_EXTERNAL) { - if (pSymbolTable->N.Name.Short != 0) { - strncpy(symbol, pSymbolTable->N.ShortName, 8); - symbol[8] = 0; - } else { - s = stringTable + pSymbolTable->N.Name.Long; - strcpy(symbol, s); - } - s = symbol; - - /* - * Skip to the last @ and ensure it is followed by digits, - * otherwise it is probably part of a C++ mangled name. - */ - - f = strrchr(s, '@'); - if (f && f[1] >= '0' && f[1] <= '9') { - *f = 0; - } -#if defined(_MSC_VER) && defined(_X86_) - if (symbol[0] == '_') { - s = &symbol[1]; - } -#endif - if ((stricmp(s, "DllEntryPoint") != 0) - && (stricmp(s, "DllMain") != 0)) { - fprintf(fout, "\t%s\n", s); - } - } - } - - /* - * Take into account any aux symbols - */ - i += pSymbolTable->NumberOfAuxSymbols; - pSymbolTable += pSymbolTable->NumberOfAuxSymbols; - pSymbolTable++; - } -} - -/* - *---------------------------------------------------------------------- - * DumpObjFile -- - * - * Dump an object file--either a full listing or just the exported - * symbols. - *---------------------------------------------------------------------- - */ -void -DumpObjFile(PIMAGE_FILE_HEADER pImageFileHeader, FILE *fout, int full) -{ - PIMAGE_SYMBOL PCOFFSymbolTable; - DWORD COFFSymbolCount; - - PCOFFSymbolTable = (PIMAGE_SYMBOL) - ((DWORD)pImageFileHeader + pImageFileHeader->PointerToSymbolTable); - COFFSymbolCount = pImageFileHeader->NumberOfSymbols; - - if (full) { - DumpSymbolTable(PCOFFSymbolTable, fout, COFFSymbolCount); - } else { - DumpExternals(PCOFFSymbolTable, fout, COFFSymbolCount); - } -} - -/* - *---------------------------------------------------------------------- - * SkipToNextRecord -- - * - * Skip over the current ROMF record and return the type of the - * next record. - *---------------------------------------------------------------------- - */ - -BYTE -SkipToNextRecord(BYTE **ppBuffer) -{ - int length; - (*ppBuffer)++; /* Skip over the type.*/ - length = *((WORD*)(*ppBuffer))++; /* Retrieve the length. */ - *ppBuffer += length; /* Skip over the rest. */ - return **ppBuffer; /* Return the type. */ -} - -/* - *---------------------------------------------------------------------- - * DumpROMFObjFile -- - * - * Dump a Relocatable Object Module Format file, displaying only - * the exported symbols. - *---------------------------------------------------------------------- - */ -void -DumpROMFObjFile(LPVOID pBuffer, FILE *fout) -{ - BYTE type, length; - char symbol[1024], *s; - - while (1) { - type = SkipToNextRecord(&(BYTE*)pBuffer); - if (type == 0x90) { /* PUBDEF */ - if (((BYTE*)pBuffer)[4] != 0) { - length = ((BYTE*)pBuffer)[5]; - strncpy(symbol, ((char*)pBuffer) + 6, length); - symbol[length] = '\0'; - s = symbol; - if ((stricmp(s, "DllEntryPoint") != 0) - && (stricmp(s, "DllMain") != 0)) { - if (s[0] == '_') { - s++; - fprintf(fout, "\t_%s\n\t%s=_%s\n", s, s, s); - } else { - fprintf(fout, "\t%s\n", s); - } - } - } - } else if (type == 0x8B || type == 0x8A) { /* MODEND */ - break; - } - } -} - -/* - *---------------------------------------------------------------------- - * DumpFile -- - * - * Open up a file, memory map it, and call the appropriate - * dumping routine - *---------------------------------------------------------------------- - */ -void -DumpFile(LPSTR filename, FILE *fout, int full) -{ - HANDLE hFile; - HANDLE hFileMapping; - LPVOID lpFileBase; - PIMAGE_DOS_HEADER dosHeader; - - hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); - - if (hFile == INVALID_HANDLE_VALUE) { - fprintf(stderr, "Couldn't open file with CreateFile()\n"); - return; - } - - hFileMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); - if (hFileMapping == 0) { - CloseHandle(hFile); - fprintf(stderr, "Couldn't open file mapping with CreateFileMapping()\n"); - return; - } - - lpFileBase = MapViewOfFile(hFileMapping, FILE_MAP_READ, 0, 0, 0); - if (lpFileBase == 0) { - CloseHandle(hFileMapping); - CloseHandle(hFile); - fprintf(stderr, "Couldn't map view of file with MapViewOfFile()\n"); - return; - } - - dosHeader = (PIMAGE_DOS_HEADER)lpFileBase; - if (dosHeader->e_magic == IMAGE_DOS_SIGNATURE) { -#if 0 - DumpExeFile( dosHeader ); -#else - fprintf(stderr, "File is an executable. I don't dump those.\n"); - return; -#endif - } - /* Does it look like a i386 COFF OBJ file??? */ - else if ((dosHeader->e_magic == e_magic_number) - && (dosHeader->e_sp == 0)) { - /* - * The two tests above aren't what they look like. They're - * really checking for IMAGE_FILE_HEADER.Machine == i386 (0x14C) - * and IMAGE_FILE_HEADER.SizeOfOptionalHeader == 0; - */ - DumpObjFile((PIMAGE_FILE_HEADER) lpFileBase, fout, full); - } else if (*((BYTE *)lpFileBase) == 0x80) { - /* - * This file looks like it might be a ROMF file. - */ - DumpROMFObjFile(lpFileBase, fout); - } else { - printf("unrecognized file format\n"); - } - UnmapViewOfFile(lpFileBase); - CloseHandle(hFileMapping); - CloseHandle(hFile); -} - -void -main(int argc, char **argv) -{ - char *fargv[1000]; - char cmdline[10000]; - int i, arg; - FILE *fout; - int pos; - int full = 0; - char *outfile = NULL; - - if (argc < 3) { - Usage: - fprintf(stderr, "Usage: %s ?-o outfile? ?-f(ull)? ..\n", argv[0]); - exit(1); - } - - arg = 1; - while (argv[arg][0] == '-') { - if (strcmp(argv[arg], "--") == 0) { - arg++; - break; - } else if (strcmp(argv[arg], "-f") == 0) { - full = 1; - } else if (strcmp(argv[arg], "-o") == 0) { - arg++; - if (arg == argc) { - goto Usage; - } - outfile = argv[arg]; - } - arg++; - } - if (arg == argc) { - goto Usage; - } - - if (outfile) { - fout = fopen(outfile, "w+"); - if (fout == NULL) { - fprintf(stderr, "Unable to open \'%s\' for writing:\n", - argv[arg]); - perror(""); - exit(1); - } - } else { - fout = stdout; - } - - if (! full) { - char *dllname = argv[arg]; - arg++; - if (arg == argc) { - goto Usage; - } - fprintf(fout, "EXPORTS\n"); - } - - for (; arg < argc; arg++) { - if (argv[arg][0] == '@') { - FILE *fargs = fopen(&argv[arg][1], "r"); - if (fargs == NULL) { - fprintf(stderr, "Unable to open \'%s\' for reading:\n", - argv[arg]); - perror(""); - exit(1); - } - pos = 0; - for (i = 0; i < arg; i++) { - strcpy(&cmdline[pos], argv[i]); - pos += strlen(&cmdline[pos]) + 1; - fargv[i] = argv[i]; - } - fgets(&cmdline[pos], sizeof(cmdline), fargs); - fprintf(stderr, "%s\n", &cmdline[pos]); - fclose(fargs); - i += GetArgcArgv(&cmdline[pos], &fargv[i]); - argc = i; - argv = fargv; - } - DumpFile(argv[arg], fout, full); - } - exit(0); -} -- cgit v0.12