summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authormdejong <mdejong>2003-12-26 04:12:16 (GMT)
committermdejong <mdejong>2003-12-26 04:12:16 (GMT)
commitb6cbad4ae34d28d3a1c2047ec41ddbedeb705023 (patch)
treeef4e6b5d7eca34aa85a9ff16a5df83749107034c /win
parent14a76c909180e749b12ffbcb9e23a4b48978d4ab (diff)
downloadtcl-b6cbad4ae34d28d3a1c2047ec41ddbedeb705023.zip
tcl-b6cbad4ae34d28d3a1c2047ec41ddbedeb705023.tar.gz
tcl-b6cbad4ae34d28d3a1c2047ec41ddbedeb705023.tar.bz2
* win/tclWin32Dll.c (DllMain): Add HAVE_NO_SEH
blocks in place of __try and __except statements to support gcc builds. This is needed after David's changes on 2003-12-21. [Tcl patch 858493]
Diffstat (limited to 'win')
-rw-r--r--win/tclWin32Dll.c70
1 files changed, 69 insertions, 1 deletions
diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c
index 579cf55..2bccd07 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.30 2003/12/24 04:18:22 davygrvy Exp $
+ * RCS: @(#) $Id: tclWin32Dll.c,v 1.31 2003/12/26 04:12:16 mdejong Exp $
*/
#include "tclWinInt.h"
@@ -255,18 +255,86 @@ DllMain(hInst, reason, reserved)
* us from an exception handler and the state of the stack might
* be unstable.
*/
+#ifdef HAVE_NO_SEH
+# ifdef TCL_MEM_DEBUG
+ __asm__ __volatile__ (
+ "movl %%esp, %0" "\n\t"
+ "movl %%ebp, %1" "\n\t"
+ "movl %%fs:0, %2" "\n\t"
+ : "=m"(INITIAL_ESP),
+ "=m"(INITIAL_EBP),
+ "=r"(INITIAL_HANDLER) );
+# 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");
+#else
__try {
+#endif /* HAVE_NO_SEH */
Tcl_Finalize();
+#ifdef HAVE_NO_SEH
+ __asm__ __volatile__ (
+ "jmp dllmain_detach_pop" "\n"
+ "dllmain_detach_reentry:" "\n\t"
+ "movl %%fs:0, %%eax" "\n\t"
+ "movl 0x8(%%eax), %%esp" "\n\t"
+ "movl 0x8(%%esp), %%ebp" "\n"
+ "dllmain_detach_pop:" "\n\t"
+ "movl (%%esp), %%eax" "\n\t"
+ "movl %%eax, %%fs:0" "\n\t"
+ "add $12, %%esp" "\n\t"
+ :
+ :
+ : "%eax");
+
+# ifdef TCL_MEM_DEBUG
+ __asm__ __volatile__ (
+ "movl %%esp, %0" "\n\t"
+ "movl %%ebp, %1" "\n\t"
+ "movl %%fs:0, %2" "\n\t"
+ : "=m"(RESTORED_ESP),
+ "=m"(RESTORED_EBP),
+ "=r"(RESTORED_HANDLER) );
+
+ if (INITIAL_ESP != RESTORED_ESP)
+ Tcl_Panic("ESP restored incorrectly");
+ if (INITIAL_EBP != RESTORED_EBP)
+ Tcl_Panic("EBP restored incorrectly");
+ if (INITIAL_HANDLER != RESTORED_HANDLER)
+ Tcl_Panic("HANDLER restored incorrectly");
+# endif /* TCL_MEM_DEBUG */
+#else
} __except (EXCEPTION_EXECUTE_HANDLER) {
/* empty handler body. */
}
+#endif /* HAVE_NO_SEH */
break;
}
return TRUE;
}
+#ifdef HAVE_NO_SEH
+static
+__attribute__ ((cdecl))
+EXCEPTION_DISPOSITION
+_except_dllmain_detach_handler(
+ struct _EXCEPTION_RECORD *ExceptionRecord,
+ void *EstablisherFrame,
+ struct _CONTEXT *ContextRecord,
+ void *DispatcherContext)
+{
+ __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__ */