summaryrefslogtreecommitdiffstats
path: root/win/tclWin32Dll.c
diff options
context:
space:
mode:
authormdejong <mdejong>2004-06-21 22:05:44 (GMT)
committermdejong <mdejong>2004-06-21 22:05:44 (GMT)
commita7d93e405d7c52890ac2b6451680ed32574c2f18 (patch)
treea4a87ef27020e7670b6fb436fad9cffa4f64cf81 /win/tclWin32Dll.c
parentdd75f95a7e0f760d88b9059d13eca9ffd8e235cc (diff)
downloadtcl-a7d93e405d7c52890ac2b6451680ed32574c2f18.zip
tcl-a7d93e405d7c52890ac2b6451680ed32574c2f18.tar.gz
tcl-a7d93e405d7c52890ac2b6451680ed32574c2f18.tar.bz2
* win/tclWin32Dll.c (DllMain, _except_dllmain_detach_handler,
TclpCheckStackSpace, _except_checkstackspace_handler, TclWinCPUID, _except_TclWinCPUID_detach_handler): * win/tclWinChan.c (Tcl_MakeFileChannel, _except_makefilechannel_handler): * win/tclWinFCmd.c (DoRenameFile, _except_dorenamefile_handler, DoCopyFile, _except_docopyfile_handler): Rework pushing of exception handler function pointer so that compiling with gcc -O3 works. Remove empty function call to avoid compiler warning. Mark the DllMain function as noinline to avoid compiler error from duplicated asm labels in generated code.
Diffstat (limited to 'win/tclWin32Dll.c')
-rw-r--r--win/tclWin32Dll.c143
1 files changed, 120 insertions, 23 deletions
diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c
index def7996..42a9ace 100644
--- a/win/tclWin32Dll.c
+++ b/win/tclWin32Dll.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWin32Dll.c,v 1.36 2004/06/05 17:31:08 kennykb Exp $
+ * RCS: @(#) $Id: tclWin32Dll.c,v 1.37 2004/06/21 22:05:55 mdejong Exp $
*/
#include "tclWinInt.h"
@@ -46,6 +46,38 @@ static void *INITIAL_ESP,
*RESTORED_HANDLER;
#endif /* HAVE_NO_SEH && TCL_MEM_DEBUG */
+#ifdef HAVE_NO_SEH
+
+static
+__attribute__ ((cdecl))
+EXCEPTION_DISPOSITION
+_except_dllmain_detach_handler(
+ struct _EXCEPTION_RECORD *ExceptionRecord,
+ void *EstablisherFrame,
+ struct _CONTEXT *ContextRecord,
+ void *DispatcherContext);
+
+static
+__attribute__ ((cdecl))
+EXCEPTION_DISPOSITION
+_except_checkstackspace_handler(
+ struct _EXCEPTION_RECORD *ExceptionRecord,
+ void *EstablisherFrame,
+ struct _CONTEXT *ContextRecord,
+ void *DispatcherContext);
+
+static
+__attribute__((cdecl))
+EXCEPTION_DISPOSITION
+_except_TclWinCPUID_detach_handler(
+ struct _EXCEPTION_RECORD *ExceptionRecord,
+ void *EstablisherFrame,
+ struct _CONTEXT *ContextRecord,
+ void *DispatcherContext);
+
+#endif /* HAVE_NO_SEH */
+
+
/*
* The following function tables are used to dispatch to either the
* wide-character or multi-byte versions of the operating system calls,
@@ -157,12 +189,28 @@ static TclWinProcs unicodeProcs = {
TclWinProcs *tclWinProcs;
static Tcl_Encoding tclWinTCharEncoding;
+
+#ifdef HAVE_NO_SEH
+
+/* Need to add noinline flag to DllMain declaration so that gcc -O3
+ * does not inline asm code into DllEntryPoint and cause a
+ * compile time error because of redefined local labels.
+ */
+
+BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason,
+ LPVOID reserved)
+ __attribute__ ((noinline));
+
+#else
+
/*
* The following declaration is for the VC++ DLL entry point.
*/
BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason,
LPVOID reserved);
+#endif /* HAVE_NO_SEH */
+
/*
* The following structure and linked list is to allow us to map between
@@ -268,10 +316,12 @@ DllMain(hInst, reason, reserved)
# endif /* TCL_MEM_DEBUG */
__asm__ __volatile__ (
- "pushl %ebp" "\n\t"
- "pushl $__except_dllmain_detach_handler" "\n\t"
- "pushl %fs:0" "\n\t"
- "movl %esp, %fs:0");
+ "pushl %%ebp" "\n\t"
+ "pushl %0" "\n\t"
+ "pushl %%fs:0" "\n\t"
+ "movl %%esp, %%fs:0"
+ :
+ : "r" (_except_dllmain_detach_handler) );
#else
__try {
#endif /* HAVE_NO_SEH */
@@ -317,7 +367,22 @@ DllMain(hInst, reason, reserved)
return TRUE;
}
-
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * _except_dllmain_detach_handler --
+ *
+ * SEH exception handler for DllMain.
+ *
+ * Results:
+ * See DllMain.
+ *
+ * Side effects:
+ * See DllMain.
+ *
+ *----------------------------------------------------------------------
+ */
#ifdef HAVE_NO_SEH
static
__attribute__ ((cdecl))
@@ -330,12 +395,11 @@ _except_dllmain_detach_handler(
{
__asm__ __volatile__ (
"jmp dllmain_detach_reentry");
- /* Nuke compiler warning about unused static function */
- _except_dllmain_detach_handler(NULL, NULL, NULL, NULL);
return 0; /* Function does not return */
}
#endif /* HAVE_NO_SEH */
+
#endif /* !STATIC_BUILD */
#endif /* __WIN32__ */
@@ -498,10 +562,12 @@ TclpCheckStackSpace()
# endif /* TCL_MEM_DEBUG */
__asm__ __volatile__ (
- "pushl %ebp" "\n\t"
- "pushl $__except_checkstackspace_handler" "\n\t"
- "pushl %fs:0" "\n\t"
- "movl %esp, %fs:0");
+ "pushl %%ebp" "\n\t"
+ "pushl %0" "\n\t"
+ "pushl %%fs:0" "\n\t"
+ "movl %%esp, %%fs:0"
+ :
+ : "r" (_except_checkstackspace_handler) );
#else
__try {
#endif /* HAVE_NO_SEH */
@@ -557,6 +623,22 @@ TclpCheckStackSpace()
*/
return retval;
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * _except_checkstackspace_handler --
+ *
+ * SEH exception handler for TclpCheckStackSpace.
+ *
+ * Results:
+ * See TclpCheckStackSpace.
+ *
+ * Side effects:
+ * See TclpCheckStackSpace.
+ *
+ *----------------------------------------------------------------------
+ */
#ifdef HAVE_NO_SEH
static
__attribute__ ((cdecl))
@@ -569,8 +651,6 @@ _except_checkstackspace_handler(
{
__asm__ __volatile__ (
"jmp checkstackspace_reentry");
- /* Nuke compiler warning about unused static function */
- _except_checkstackspace_handler(NULL, NULL, NULL, NULL);
return 0; /* Function does not return */
}
#endif /* HAVE_NO_SEH */
@@ -1027,10 +1107,12 @@ TclWinCPUID( unsigned int index, /* Which CPUID value to retrieve */
# ifdef HAVE_NO_SEH
__asm__ __volatile__ (
- "pushl %ebp" "\n\t"
- "pushl $__except_TclWinCPUID_detach_handler" "\n\t"
- "pushl %fs:0" "\n\t"
- "movl %esp, %fs:0" );
+ "pushl %%ebp" "\n\t"
+ "pushl %0" "\n\t"
+ "pushl %%fs:0" "\n\t"
+ "movl %%esp, %%fs:0"
+ :
+ : "r" (_except_TclWinCPUID_detach_handler) );
# else
__try {
# endif
@@ -1126,9 +1208,27 @@ TclWinCPUID( unsigned int index, /* Which CPUID value to retrieve */
#endif
return status;
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * _except_TclWinCPUID_detach_handler --
+ *
+ * SEH exception handler for TclWinCPUID.
+ *
+ * Results:
+ * See TclWinCPUID.
+ *
+ * Side effects:
+ * See TclWinCPUID.
+ *
+ *----------------------------------------------------------------------
+ */
-#if defined( __GNUC__ ) && defined( HAVE_NO_SEH )
-static __attribute__((cdecl)) EXCEPTION_DISPOSITION
+#if defined( HAVE_NO_SEH )
+static
+__attribute__((cdecl))
+EXCEPTION_DISPOSITION
_except_TclWinCPUID_detach_handler(
struct _EXCEPTION_RECORD *ExceptionRecord,
void *EstablisherFrame,
@@ -1137,10 +1237,7 @@ _except_TclWinCPUID_detach_handler(
{
__asm__ __volatile__ (
"jmp TclWinCPUID_detach_reentry" );
- /* Nuke compiler warning about unused static function */
- _except_TclWinCPUID_detach_handler(NULL, NULL, NULL, NULL);
return 0; /* Function does not return */
}
#endif
-