From 6f438769bc6be9f629476c948b96d7d00c7586e0 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 25 Mar 2020 14:48:44 +0000 Subject: Follow-up to [a9f61c48906b66f8]: Fill UNIX TclIntPlatDecls stub entry 5 with same entry from win32. Can be simplified further in 8.7/9.0. --- generic/tclInt.decls | 7 +++---- generic/tclIntPlatDecls.h | 19 ++++++++++++------- generic/tclStubInit.c | 33 ++++++++++++++------------------- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/generic/tclInt.decls b/generic/tclInt.decls index 85ce69f..96fa01c 100644 --- a/generic/tclInt.decls +++ b/generic/tclInt.decls @@ -1206,10 +1206,9 @@ declare 4 unix { const char **argv, TclFile inputFile, TclFile outputFile, TclFile errorFile, Tcl_Pid *pidPtr) } -# Signature changed in 8.1: -# declare 5 unix { -# TclFile TclpCreateTempFile(char *contents, Tcl_DString *namePtr) -# } +declare 5 unix { + int TclUnixWaitForFile_(int fd, int mask, int timeout) +} declare 6 unix { TclFile TclpMakeFile(Tcl_Channel channel, int direction) } diff --git a/generic/tclIntPlatDecls.h b/generic/tclIntPlatDecls.h index 6ea6f95..7034fc3 100644 --- a/generic/tclIntPlatDecls.h +++ b/generic/tclIntPlatDecls.h @@ -57,7 +57,8 @@ EXTERN int TclpCreateProcess(Tcl_Interp *interp, int argc, const char **argv, TclFile inputFile, TclFile outputFile, TclFile errorFile, Tcl_Pid *pidPtr); -/* Slot 5 is reserved */ +/* 5 */ +EXTERN int TclUnixWaitForFile_(int fd, int mask, int timeout); /* 6 */ EXTERN TclFile TclpMakeFile(Tcl_Channel channel, int direction); /* 7 */ @@ -207,7 +208,8 @@ EXTERN int TclpCreateProcess(Tcl_Interp *interp, int argc, const char **argv, TclFile inputFile, TclFile outputFile, TclFile errorFile, Tcl_Pid *pidPtr); -/* Slot 5 is reserved */ +/* 5 */ +EXTERN int TclUnixWaitForFile_(int fd, int mask, int timeout); /* 6 */ EXTERN TclFile TclpMakeFile(Tcl_Channel channel, int direction); /* 7 */ @@ -276,7 +278,7 @@ typedef struct TclIntPlatStubs { Tcl_Channel (*tclpCreateCommandChannel) (TclFile readFile, TclFile writeFile, TclFile errorFile, int numPids, Tcl_Pid *pidPtr); /* 2 */ int (*tclpCreatePipe) (TclFile *readPipe, TclFile *writePipe); /* 3 */ int (*tclpCreateProcess) (Tcl_Interp *interp, int argc, const char **argv, TclFile inputFile, TclFile outputFile, TclFile errorFile, Tcl_Pid *pidPtr); /* 4 */ - void (*reserved5)(void); + int (*tclUnixWaitForFile_) (int fd, int mask, int timeout); /* 5 */ TclFile (*tclpMakeFile) (Tcl_Channel channel, int direction); /* 6 */ TclFile (*tclpOpenFile) (const char *fname, int mode); /* 7 */ int (*tclUnixWaitForFile) (int fd, int mask, int timeout); /* 8 */ @@ -342,7 +344,7 @@ typedef struct TclIntPlatStubs { Tcl_Channel (*tclpCreateCommandChannel) (TclFile readFile, TclFile writeFile, TclFile errorFile, int numPids, Tcl_Pid *pidPtr); /* 2 */ int (*tclpCreatePipe) (TclFile *readPipe, TclFile *writePipe); /* 3 */ int (*tclpCreateProcess) (Tcl_Interp *interp, int argc, const char **argv, TclFile inputFile, TclFile outputFile, TclFile errorFile, Tcl_Pid *pidPtr); /* 4 */ - void (*reserved5)(void); + int (*tclUnixWaitForFile_) (int fd, int mask, int timeout); /* 5 */ TclFile (*tclpMakeFile) (Tcl_Channel channel, int direction); /* 6 */ TclFile (*tclpOpenFile) (const char *fname, int mode); /* 7 */ int (*tclUnixWaitForFile) (int fd, int mask, int timeout); /* 8 */ @@ -394,7 +396,8 @@ extern const TclIntPlatStubs *tclIntPlatStubsPtr; (tclIntPlatStubsPtr->tclpCreatePipe) /* 3 */ #define TclpCreateProcess \ (tclIntPlatStubsPtr->tclpCreateProcess) /* 4 */ -/* Slot 5 is reserved */ +#define TclUnixWaitForFile_ \ + (tclIntPlatStubsPtr->tclUnixWaitForFile_) /* 5 */ #define TclpMakeFile \ (tclIntPlatStubsPtr->tclpMakeFile) /* 6 */ #define TclpOpenFile \ @@ -511,7 +514,8 @@ extern const TclIntPlatStubs *tclIntPlatStubsPtr; (tclIntPlatStubsPtr->tclpCreatePipe) /* 3 */ #define TclpCreateProcess \ (tclIntPlatStubsPtr->tclpCreateProcess) /* 4 */ -/* Slot 5 is reserved */ +#define TclUnixWaitForFile_ \ + (tclIntPlatStubsPtr->tclUnixWaitForFile_) /* 5 */ #define TclpMakeFile \ (tclIntPlatStubsPtr->tclpMakeFile) /* 6 */ #define TclpOpenFile \ @@ -570,7 +574,8 @@ extern const TclIntPlatStubs *tclIntPlatStubsPtr; #define TclpInetNtoa inet_ntoa #undef TclpCreateTempFile_ -#ifndef MAC_OSX_TCL /* Not accessable on UNIX */ +#undef TclUnixWaitForFile_ +#ifndef MAC_OSX_TCL /* not accessable on Win32/UNIX */ #undef TclMacOSXGetFileAttribute /* 15 */ #undef TclMacOSXSetFileAttribute /* 16 */ #undef TclMacOSXCopyFileAttributes /* 17 */ diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 2967065..aae51dd 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -145,6 +145,7 @@ static unsigned short TclWinNToHS(unsigned short ns) { #endif #define TclpCreateTempFile_ TclpCreateTempFile +#define TclUnixWaitForFile_ TclUnixWaitForFile #ifndef MAC_OSX_TCL /* On UNIX, fill with other stub entries */ #define TclMacOSXGetFileAttribute (int (*)(Tcl_Interp *, int, Tcl_Obj *, Tcl_Obj **))(void *)TclpCreateProcess #define TclMacOSXSetFileAttribute (int (*)(Tcl_Interp *, int, Tcl_Obj *, Tcl_Obj *))(void *)isatty @@ -160,18 +161,12 @@ static unsigned short TclWinNToHS(unsigned short ns) { # define TclpReaddir 0 # define TclpIsAtty 0 #elif defined(__CYGWIN__) -# define TclpIsAtty TclPlatIsAtty -# define TclWinSetInterfaces (void (*) (int)) doNothing -# define TclWinAddProcess (void (*) (void *, unsigned int)) doNothing +# define TclpIsAtty isatty +# define TclWinSetInterfaces (void (*) (int))(void *)doNothing +# define TclWinAddProcess (void (*) (void *, unsigned int))(void *)doNothing # define TclWinFlushDirtyChannels doNothing # define TclWinResetInterfaces doNothing -static int -TclpIsAtty(int fd) -{ - return isatty(fd); -} - #define TclWinGetPlatformId winGetPlatformId static int TclWinGetPlatformId() @@ -181,14 +176,6 @@ TclWinGetPlatformId() return 2; /* VER_PLATFORM_WIN32_NT */; } -void *TclWinGetTclInstance() -{ - void *hInstance = NULL; - GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, - (const char *)&TclpIsAtty, &hInstance); - return hInstance; -} - #define TclWinSetSockOpt winSetSockOpt static int TclWinSetSockOpt(SOCKET s, int level, int optname, @@ -226,6 +213,14 @@ TclWinNoBackslash(char *path) return path; } +void *TclWinGetTclInstance() +{ + void *hInstance = NULL; + GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, + (const char *)&TclWinNoBackslash, &hInstance); + return hInstance; +} + int TclpGetPid(Tcl_Pid pid) { @@ -764,7 +759,7 @@ static const TclIntPlatStubs tclIntPlatStubs = { TclpCreateCommandChannel, /* 2 */ TclpCreatePipe, /* 3 */ TclpCreateProcess, /* 4 */ - 0, /* 5 */ + TclUnixWaitForFile_, /* 5 */ TclpMakeFile, /* 6 */ TclpOpenFile, /* 7 */ TclUnixWaitForFile, /* 8 */ @@ -830,7 +825,7 @@ static const TclIntPlatStubs tclIntPlatStubs = { TclpCreateCommandChannel, /* 2 */ TclpCreatePipe, /* 3 */ TclpCreateProcess, /* 4 */ - 0, /* 5 */ + TclUnixWaitForFile_, /* 5 */ TclpMakeFile, /* 6 */ TclpOpenFile, /* 7 */ TclUnixWaitForFile, /* 8 */ -- cgit v0.12