tclWinInt.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. #ifndef _TCLWININT
  12. #define _TCLWININT
  13. #include "tclInt.h"
  14. #ifdef HAVE_NO_SEH
  15. /*
  16. * Unlike Borland and Microsoft, we don't register exception handlers by
  17. * pushing registration records onto the runtime stack. Instead, we register
  18. * them by creating an TCLEXCEPTION_REGISTRATION within the activation record.
  19. */
  20. typedef struct TCLEXCEPTION_REGISTRATION {
  21. struct TCLEXCEPTION_REGISTRATION *link;
  22. EXCEPTION_DISPOSITION (*handler)(
  23. struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*);
  24. void *ebp;
  25. void *esp;
  26. int status;
  27. } TCLEXCEPTION_REGISTRATION;
  28. #endif
  29. /*
  30. * Windows version dependend functions
  31. */
  32. typedef struct TclWinProcs {
  33. BOOL (WINAPI *cancelSynchronousIo)(HANDLE);
  34. BOOLEAN (WINAPI *createSymbolicLink)(LPCWSTR, LPCWSTR, DWORD);
  35. } TclWinProcs;
  36. MODULE_SCOPE TclWinProcs tclWinProcs;
  37. /*
  38. * Some versions of Borland C have a define for the OSVERSIONINFO for
  39. * Win32s and for NT, but not for Windows 95.
  40. * Define VER_PLATFORM_WIN32_CE for those without newer headers.
  41. */
  42. #ifndef VER_PLATFORM_WIN32_WINDOWS
  43. #define VER_PLATFORM_WIN32_WINDOWS 1
  44. #endif
  45. #ifndef VER_PLATFORM_WIN32_CE
  46. #define VER_PLATFORM_WIN32_CE 3
  47. #endif
  48. #ifndef TCL_Z_MODIFIER
  49. # ifdef _WIN64
  50. # if defined(__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO
  51. # define TCL_Z_MODIFIER "ll"
  52. # else
  53. # define TCL_Z_MODIFIER "I"
  54. # endif
  55. # else
  56. # define TCL_Z_MODIFIER ""
  57. # endif
  58. #endif
  59. #define TCL_I_MODIFIER TCL_Z_MODIFIER
  60. /*
  61. * Declarations of functions that are not accessible by way of the
  62. * stubs table.
  63. */
  64. MODULE_SCOPE char TclWinDriveLetterForVolMountPoint(
  65. const WCHAR *mountPoint);
  66. MODULE_SCOPE void TclWinEncodingsCleanup(void);
  67. MODULE_SCOPE void TclWinInit(HINSTANCE hInst);
  68. MODULE_SCOPE TclFile TclWinMakeFile(HANDLE handle);
  69. MODULE_SCOPE Tcl_Channel TclWinOpenConsoleChannel(HANDLE handle,
  70. char *channelName, int permissions);
  71. MODULE_SCOPE Tcl_Channel TclWinOpenFileChannel(HANDLE handle, char *channelName,
  72. int permissions, int appendMode);
  73. MODULE_SCOPE Tcl_Channel TclWinOpenSerialChannel(HANDLE handle,
  74. char *channelName, int permissions);
  75. MODULE_SCOPE HANDLE TclWinSerialOpen(HANDLE handle, const WCHAR *name,
  76. DWORD access);
  77. MODULE_SCOPE int TclWinSymLinkCopyDirectory(const WCHAR *LinkOriginal,
  78. const WCHAR *LinkCopy);
  79. MODULE_SCOPE int TclWinSymLinkDelete(const WCHAR *LinkOriginal,
  80. int linkOnly);
  81. MODULE_SCOPE int TclWinFileOwned(Tcl_Obj *);
  82. #if defined(TCL_THREADS) && defined(USE_THREAD_ALLOC)
  83. MODULE_SCOPE void TclWinFreeAllocCache(void);
  84. MODULE_SCOPE void TclFreeAllocCache(void *);
  85. MODULE_SCOPE Tcl_Mutex *TclpNewAllocMutex(void);
  86. MODULE_SCOPE void * TclpGetAllocCache(void);
  87. MODULE_SCOPE void TclpSetAllocCache(void *);
  88. #endif /* TCL_THREADS */
  89. MODULE_SCOPE const char*TclpGetUserName(Tcl_DString *bufferPtr);
  90. /* Needed by tclWinFile.c and tclWinFCmd.c */
  91. #ifndef FILE_ATTRIBUTE_REPARSE_POINT
  92. #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
  93. #endif
  94. /*
  95. *----------------------------------------------------------------------
  96. * Declarations of helper-workers threaded facilities for a pipe based channel.
  97. *
  98. * Corresponding functionality provided in "tclWinPipe.c".
  99. *----------------------------------------------------------------------
  100. */
  101. typedef struct TclPipeThreadInfo {
  102. HANDLE evControl; /* Auto-reset event used by the main thread to
  103. * signal when the pipe thread should attempt
  104. * to do read/write operation. Additionally
  105. * used as signal to stop (state set to -1) */
  106. volatile LONG state; /* Indicates current state of the thread */
  107. ClientData clientData; /* Referenced data of the main thread */
  108. HANDLE evWakeUp; /* Optional wake-up event worker set by shutdown */
  109. } TclPipeThreadInfo;
  110. /* If pipe-workers will use some tcl subsystem, we can use ckalloc without
  111. * more overhead for finalize thread (should be executed anyway)
  112. *
  113. * #define _PTI_USE_CKALLOC 1
  114. */
  115. /*
  116. * State of the pipe-worker.
  117. *
  118. * State PTI_STATE_STOP possible from idle state only, worker owns TI structure.
  119. * Otherwise PTI_STATE_END used (main thread hold ownership of the TI).
  120. */
  121. #define PTI_STATE_IDLE 0 /* idle or not yet initialzed */
  122. #define PTI_STATE_WORK 1 /* in work */
  123. #define PTI_STATE_STOP 2 /* thread should stop work (owns TI structure) */
  124. #define PTI_STATE_END 4 /* thread should stop work (worker is busy) */
  125. #define PTI_STATE_DOWN 8 /* worker is down */
  126. MODULE_SCOPE
  127. TclPipeThreadInfo * TclPipeThreadCreateTI(TclPipeThreadInfo **pipeTIPtr,
  128. ClientData clientData, HANDLE wakeEvent);
  129. MODULE_SCOPE int TclPipeThreadWaitForSignal(TclPipeThreadInfo **pipeTIPtr);
  130. static inline void
  131. TclPipeThreadSignal(
  132. TclPipeThreadInfo **pipeTIPtr)
  133. {
  134. TclPipeThreadInfo *pipeTI = *pipeTIPtr;
  135. if (pipeTI) {
  136. SetEvent(pipeTI->evControl);
  137. }
  138. };
  139. static inline int
  140. TclPipeThreadIsAlive(
  141. TclPipeThreadInfo **pipeTIPtr)
  142. {
  143. TclPipeThreadInfo *pipeTI = *pipeTIPtr;
  144. return (pipeTI && pipeTI->state != PTI_STATE_DOWN);
  145. };
  146. MODULE_SCOPE int TclPipeThreadStopSignal(TclPipeThreadInfo **pipeTIPtr, HANDLE wakeEvent);
  147. MODULE_SCOPE void TclPipeThreadStop(TclPipeThreadInfo **pipeTIPtr, HANDLE hThread);
  148. MODULE_SCOPE void TclPipeThreadExit(TclPipeThreadInfo **pipeTIPtr);
  149. #endif /* _TCLWININT */