4 * Declarations of Windows-specific shared variables and procedures.
6 * Copyright (c) 1994-1996 Sun Microsystems, Inc.
8 * See the file "license.terms" for information on usage and redistribution
9 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
19 * Unlike Borland and Microsoft, we don't register exception handlers by
20 * pushing registration records onto the runtime stack. Instead, we register
21 * them by creating an TCLEXCEPTION_REGISTRATION within the activation record.
24 typedef struct TCLEXCEPTION_REGISTRATION {
25 struct TCLEXCEPTION_REGISTRATION *link;
26 EXCEPTION_DISPOSITION (*handler)(
27 struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*);
31 } TCLEXCEPTION_REGISTRATION;
35 * Windows version dependend functions
37 typedef struct TclWinProcs {
38 BOOL (WINAPI *cancelSynchronousIo)(HANDLE);
39 BOOLEAN (WINAPI *createSymbolicLink)(LPCWSTR, LPCWSTR, DWORD);
42 MODULE_SCOPE TclWinProcs tclWinProcs;
45 * Some versions of Borland C have a define for the OSVERSIONINFO for
46 * Win32s and for NT, but not for Windows 95.
47 * Define VER_PLATFORM_WIN32_CE for those without newer headers.
50 #ifndef VER_PLATFORM_WIN32_WINDOWS
51 #define VER_PLATFORM_WIN32_WINDOWS 1
53 #ifndef VER_PLATFORM_WIN32_CE
54 #define VER_PLATFORM_WIN32_CE 3
57 #ifndef TCL_Z_MODIFIER
59 # if defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO
60 # define TCL_Z_MODIFIER "ll"
62 # define TCL_Z_MODIFIER "I"
65 # define TCL_Z_MODIFIER ""
68 #define TCL_I_MODIFIER TCL_Z_MODIFIER
71 * Declarations of functions that are not accessible by way of the
75 MODULE_SCOPE char TclWinDriveLetterForVolMountPoint(
76 const WCHAR *mountPoint);
77 MODULE_SCOPE void TclWinEncodingsCleanup(void);
78 MODULE_SCOPE void TclWinInit(HINSTANCE hInst);
79 MODULE_SCOPE TclFile TclWinMakeFile(HANDLE handle);
80 MODULE_SCOPE Tcl_Channel TclWinOpenConsoleChannel(HANDLE handle,
81 char *channelName, int permissions);
82 MODULE_SCOPE Tcl_Channel TclWinOpenFileChannel(HANDLE handle, char *channelName,
83 int permissions, int appendMode);
84 MODULE_SCOPE Tcl_Channel TclWinOpenSerialChannel(HANDLE handle,
85 char *channelName, int permissions);
86 MODULE_SCOPE HANDLE TclWinSerialOpen(HANDLE handle, const WCHAR *name,
88 MODULE_SCOPE int TclWinSymLinkCopyDirectory(const WCHAR *LinkOriginal,
89 const WCHAR *LinkCopy);
90 MODULE_SCOPE int TclWinSymLinkDelete(const WCHAR *LinkOriginal,
92 MODULE_SCOPE int TclWinFileOwned(Tcl_Obj *);
93 #if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC)
94 MODULE_SCOPE void TclWinFreeAllocCache(void);
95 MODULE_SCOPE void TclFreeAllocCache(void *);
96 MODULE_SCOPE Tcl_Mutex *TclpNewAllocMutex(void);
97 MODULE_SCOPE void * TclpGetAllocCache(void);
98 MODULE_SCOPE void TclpSetAllocCache(void *);
99 #endif /* TCL_THREADS */
101 MODULE_SCOPE const char*TclpGetUserName(Tcl_DString *bufferPtr);
103 /* Needed by tclWinFile.c and tclWinFCmd.c */
104 #ifndef FILE_ATTRIBUTE_REPARSE_POINT
105 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
109 *----------------------------------------------------------------------
110 * Declarations of helper-workers threaded facilities for a pipe based channel.
112 * Corresponding functionality provided in "tclWinPipe.c".
113 *----------------------------------------------------------------------
116 typedef struct TclPipeThreadInfo {
117 HANDLE evControl; /* Auto-reset event used by the main thread to
118 * signal when the pipe thread should attempt
119 * to do read/write operation. Additionally
120 * used as signal to stop (state set to -1) */
121 volatile LONG state; /* Indicates current state of the thread */
122 ClientData clientData; /* Referenced data of the main thread */
123 HANDLE evWakeUp; /* Optional wake-up event worker set by shutdown */
127 /* If pipe-workers will use some tcl subsystem, we can use ckalloc without
128 * more overhead for finalize thread (should be executed anyway)
130 * #define _PTI_USE_CKALLOC 1
134 * State of the pipe-worker.
136 * State PTI_STATE_STOP possible from idle state only, worker owns TI structure.
137 * Otherwise PTI_STATE_END used (main thread hold ownership of the TI).
140 #define PTI_STATE_IDLE 0 /* idle or not yet initialzed */
141 #define PTI_STATE_WORK 1 /* in work */
142 #define PTI_STATE_STOP 2 /* thread should stop work (owns TI structure) */
143 #define PTI_STATE_END 4 /* thread should stop work (worker is busy) */
144 #define PTI_STATE_DOWN 8 /* worker is down */
148 TclPipeThreadInfo * TclPipeThreadCreateTI(TclPipeThreadInfo **pipeTIPtr,
149 ClientData clientData, HANDLE wakeEvent);
150 MODULE_SCOPE int TclPipeThreadWaitForSignal(TclPipeThreadInfo **pipeTIPtr);
154 TclPipeThreadInfo **pipeTIPtr)
156 TclPipeThreadInfo *pipeTI = *pipeTIPtr;
158 SetEvent(pipeTI->evControl);
163 TclPipeThreadIsAlive(
164 TclPipeThreadInfo **pipeTIPtr)
166 TclPipeThreadInfo *pipeTI = *pipeTIPtr;
167 return (pipeTI && pipeTI->state != PTI_STATE_DOWN);
170 MODULE_SCOPE int TclPipeThreadStopSignal(TclPipeThreadInfo **pipeTIPtr, HANDLE wakeEvent);
171 MODULE_SCOPE void TclPipeThreadStop(TclPipeThreadInfo **pipeTIPtr, HANDLE hThread);
172 MODULE_SCOPE void TclPipeThreadExit(TclPipeThreadInfo **pipeTIPtr);
174 #endif /* _TCLWININT */