Debian Codegraph @

win/tclWinInt.h

raw
1 /*
2 * tclWinInt.h --
3 *
4 * Declarations of Windows-specific shared variables and procedures.
5 *
6 * Copyright (c) 1994-1996 Sun Microsystems, Inc.
7 *
8 * See the file "license.terms" for information on usage and redistribution
9 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10 */
11
12 #ifndef _TCLWININT
13 #define _TCLWININT
14
15 #include "tclInt.h"
16
17 #ifdef HAVE_NO_SEH
18 /*
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.
22 */
23
24 typedef struct TCLEXCEPTION_REGISTRATION {
25 struct TCLEXCEPTION_REGISTRATION *link;
26 EXCEPTION_DISPOSITION (*handler)(
27 struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*);
28 void *ebp;
29 void *esp;
30 int status;
31 } TCLEXCEPTION_REGISTRATION;
32 #endif
33
34 /*
35 * Windows version dependend functions
36 */
37 typedef struct TclWinProcs {
38 BOOL (WINAPI *cancelSynchronousIo)(HANDLE);
39 BOOLEAN (WINAPI *createSymbolicLink)(LPCWSTR, LPCWSTR, DWORD);
40 } TclWinProcs;
41
42 MODULE_SCOPE TclWinProcs tclWinProcs;
43
44 /*
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.
48 */
49
50 #ifndef VER_PLATFORM_WIN32_WINDOWS
51 #define VER_PLATFORM_WIN32_WINDOWS 1
52 #endif
53 #ifndef VER_PLATFORM_WIN32_CE
54 #define VER_PLATFORM_WIN32_CE 3
55 #endif
56
57 #ifndef TCL_Z_MODIFIER
58 # ifdef _WIN64
59 # if defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO
60 # define TCL_Z_MODIFIER "ll"
61 # else
62 # define TCL_Z_MODIFIER "I"
63 # endif
64 # else
65 # define TCL_Z_MODIFIER ""
66 # endif
67 #endif
68 #define TCL_I_MODIFIER TCL_Z_MODIFIER
69
70 /*
71 * Declarations of functions that are not accessible by way of the
72 * stubs table.
73 */
74
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 TclWinOpenSerialChannel(HANDLE handle,
83 char *channelName, int permissions);
84 MODULE_SCOPE HANDLE TclWinSerialOpen(HANDLE handle, const WCHAR *name,
85 DWORD access);
86 MODULE_SCOPE int TclWinSymLinkCopyDirectory(const WCHAR *LinkOriginal,
87 const WCHAR *LinkCopy);
88 MODULE_SCOPE int TclWinSymLinkDelete(const WCHAR *LinkOriginal,
89 int linkOnly);
90 MODULE_SCOPE int TclWinFileOwned(Tcl_Obj *);
91 #if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC)
92 MODULE_SCOPE void TclWinFreeAllocCache(void);
93 MODULE_SCOPE void TclFreeAllocCache(void *);
94 MODULE_SCOPE Tcl_Mutex *TclpNewAllocMutex(void);
95 MODULE_SCOPE void * TclpGetAllocCache(void);
96 MODULE_SCOPE void TclpSetAllocCache(void *);
97 #endif /* TCL_THREADS */
98
99 MODULE_SCOPE const char*TclpGetUserName(Tcl_DString *bufferPtr);
100
101 /* Needed by tclWinFile.c and tclWinFCmd.c */
102 #ifndef FILE_ATTRIBUTE_REPARSE_POINT
103 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
104 #endif
105
106 /*
107 *----------------------------------------------------------------------
108 * Declarations of helper-workers threaded facilities for a pipe based channel.
109 *
110 * Corresponding functionality provided in "tclWinPipe.c".
111 *----------------------------------------------------------------------
112 */
113
114 typedef struct TclPipeThreadInfo {
115 HANDLE evControl; /* Auto-reset event used by the main thread to
116 * signal when the pipe thread should attempt
117 * to do read/write operation. Additionally
118 * used as signal to stop (state set to -1) */
119 volatile LONG state; /* Indicates current state of the thread */
120 ClientData clientData; /* Referenced data of the main thread */
121 HANDLE evWakeUp; /* Optional wake-up event worker set by shutdown */
122 } TclPipeThreadInfo;
123
124
125 /* If pipe-workers will use some tcl subsystem, we can use ckalloc without
126 * more overhead for finalize thread (should be executed anyway)
127 *
128 * #define _PTI_USE_CKALLOC 1
129 */
130
131 /*
132 * State of the pipe-worker.
133 *
134 * State PTI_STATE_STOP possible from idle state only, worker owns TI structure.
135 * Otherwise PTI_STATE_END used (main thread hold ownership of the TI).
136 */
137
138 #define PTI_STATE_IDLE 0 /* idle or not yet initialzed */
139 #define PTI_STATE_WORK 1 /* in work */
140 #define PTI_STATE_STOP 2 /* thread should stop work (owns TI structure) */
141 #define PTI_STATE_END 4 /* thread should stop work (worker is busy) */
142 #define PTI_STATE_DOWN 8 /* worker is down */
143
144
145 MODULE_SCOPE
146 TclPipeThreadInfo * TclPipeThreadCreateTI(TclPipeThreadInfo **pipeTIPtr,
147 ClientData clientData, HANDLE wakeEvent);
148 MODULE_SCOPE int TclPipeThreadWaitForSignal(TclPipeThreadInfo **pipeTIPtr);
149
150 static inline void
151 TclPipeThreadSignal(
152 TclPipeThreadInfo **pipeTIPtr)
153 {
154 TclPipeThreadInfo *pipeTI = *pipeTIPtr;
155 if (pipeTI) {
156 SetEvent(pipeTI->evControl);
157 }
158 };
159
160 static inline int
161 TclPipeThreadIsAlive(
162 TclPipeThreadInfo **pipeTIPtr)
163 {
164 TclPipeThreadInfo *pipeTI = *pipeTIPtr;
165 return (pipeTI && pipeTI->state != PTI_STATE_DOWN);
166 };
167
168 MODULE_SCOPE int TclPipeThreadStopSignal(TclPipeThreadInfo **pipeTIPtr, HANDLE wakeEvent);
169 MODULE_SCOPE void TclPipeThreadStop(TclPipeThreadInfo **pipeTIPtr, HANDLE hThread);
170 MODULE_SCOPE void TclPipeThreadExit(TclPipeThreadInfo **pipeTIPtr);
171
172 #endif /* _TCLWININT */