summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormdejong <mdejong>2004-10-28 19:51:26 (GMT)
committermdejong <mdejong>2004-10-28 19:51:26 (GMT)
commitcfe5fa244324a7fa72c30f81c48dab14cff295a5 (patch)
tree1a42df5d7007d9e8a6b2fc8ad961aa93a70e2422
parentc87342572e59fbdad7f99c32447e402ffcd5a270 (diff)
downloadtk-cfe5fa244324a7fa72c30f81c48dab14cff295a5.zip
tk-cfe5fa244324a7fa72c30f81c48dab14cff295a5.tar.gz
tk-cfe5fa244324a7fa72c30f81c48dab14cff295a5.tar.bz2
* win/tkWin32Dll.c (DllMain, _except_dllmain_detach_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.
-rw-r--r--ChangeLog9
-rw-r--r--win/tkWin32Dll.c56
2 files changed, 57 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index cd21f7f..feb2619 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2004-10-28 Mo DeJong <mdejong@users.sourceforge.net>
+
+ * win/tkWin32Dll.c (DllMain, _except_dllmain_detach_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.
+
2004-10-28 Pat Thoyts <patthoyts@users.sourceforge.net>
* unix/tkUnixScale.c (DisplayHorizontalValue): Fix for #220927 by
diff --git a/win/tkWin32Dll.c b/win/tkWin32Dll.c
index cec133a..3b6d7f5 100644
--- a/win/tkWin32Dll.c
+++ b/win/tkWin32Dll.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWin32Dll.c,v 1.9 2004/03/05 07:32:54 mdejong Exp $
+ * RCS: @(#) $Id: tkWin32Dll.c,v 1.10 2004/10/28 19:51:37 mdejong Exp $
*/
#include "tkWinInt.h"
@@ -23,12 +23,37 @@ 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);
+#endif /* HAVE_NO_SEH */
+
+#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 _ANSI_ARGS_((HINSTANCE hInst,
DWORD reason, LPVOID reserved));
+#endif /* HAVE_NO_SEH */
/*
*----------------------------------------------------------------------
@@ -112,12 +137,14 @@ DllMain(hInstance, reason, reserved)
"=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");
+ "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 */
@@ -170,6 +197,21 @@ DllMain(hInstance, 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))
@@ -182,8 +224,6 @@ _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 */