OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/base.git] / util / src / TclTk / tcl8.6.12 / win / tclWinInt.h
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 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,
87                             DWORD access);
88 MODULE_SCOPE int        TclWinSymLinkCopyDirectory(const WCHAR *LinkOriginal,
89                             const WCHAR *LinkCopy);
90 MODULE_SCOPE int        TclWinSymLinkDelete(const WCHAR *LinkOriginal,
91                             int linkOnly);
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 */
100
101 MODULE_SCOPE const char*TclpGetUserName(Tcl_DString *bufferPtr);
102
103 /* Needed by tclWinFile.c and tclWinFCmd.c */
104 #ifndef FILE_ATTRIBUTE_REPARSE_POINT
105 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
106 #endif
107
108 /*
109  *----------------------------------------------------------------------
110  * Declarations of helper-workers threaded facilities for a pipe based channel.
111  *
112  * Corresponding functionality provided in "tclWinPipe.c".
113  *----------------------------------------------------------------------
114  */
115
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 */
124 } TclPipeThreadInfo;
125
126
127 /* If pipe-workers will use some tcl subsystem, we can use ckalloc without
128  * more overhead for finalize thread (should be executed anyway)
129  *
130  * #define _PTI_USE_CKALLOC 1
131  */
132
133 /*
134  * State of the pipe-worker.
135  *
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).
138  */
139
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 */
145
146
147 MODULE_SCOPE
148 TclPipeThreadInfo *     TclPipeThreadCreateTI(TclPipeThreadInfo **pipeTIPtr,
149                             ClientData clientData, HANDLE wakeEvent);
150 MODULE_SCOPE int        TclPipeThreadWaitForSignal(TclPipeThreadInfo **pipeTIPtr);
151
152 static inline void
153 TclPipeThreadSignal(
154     TclPipeThreadInfo **pipeTIPtr)
155 {
156     TclPipeThreadInfo *pipeTI = *pipeTIPtr;
157     if (pipeTI) {
158         SetEvent(pipeTI->evControl);
159     }
160 };
161
162 static inline int
163 TclPipeThreadIsAlive(
164     TclPipeThreadInfo **pipeTIPtr)
165 {
166     TclPipeThreadInfo *pipeTI = *pipeTIPtr;
167     return (pipeTI && pipeTI->state != PTI_STATE_DOWN);
168 };
169
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);
173
174 #endif  /* _TCLWININT */