summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authormdejong <mdejong>2004-06-21 22:07:30 (GMT)
committermdejong <mdejong>2004-06-21 22:07:30 (GMT)
commit1dc7dd38fb40ca56d2e36b80e22ff1c1e68e0b0c (patch)
tree0d504bc39e9ca874037cde6be8a9aa0666e194d5 /win
parent44d95ca8cecdf4670b8e3b23bb90a7b7d291e096 (diff)
downloadtcl-1dc7dd38fb40ca56d2e36b80e22ff1c1e68e0b0c.zip
tcl-1dc7dd38fb40ca56d2e36b80e22ff1c1e68e0b0c.tar.gz
tcl-1dc7dd38fb40ca56d2e36b80e22ff1c1e68e0b0c.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')
-rw-r--r--win/tclWin32Dll.c143
-rw-r--r--win/tclWinChan.c42
-rw-r--r--win/tclWinFCmd.c80
3 files changed, 223 insertions, 42 deletions
diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c
index 4cfd944..78d8bc5 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.24.2.3 2004/06/05 17:25:40 kennykb Exp $
+ * RCS: @(#) $Id: tclWin32Dll.c,v 1.24.2.4 2004/06/21 22:07:32 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,
@@ -153,12 +185,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
@@ -261,10 +309,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 */
@@ -312,7 +362,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))
@@ -325,12 +390,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__ */
@@ -493,10 +557,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 */
@@ -552,6 +618,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))
@@ -564,8 +646,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 */
@@ -978,10 +1058,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
@@ -1077,9 +1159,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,
@@ -1088,10 +1188,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
-
diff --git a/win/tclWinChan.c b/win/tclWinChan.c
index c6640f1..60f9aef 100644
--- a/win/tclWinChan.c
+++ b/win/tclWinChan.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: tclWinChan.c,v 1.30 2003/01/26 05:59:38 mdejong Exp $
+ * RCS: @(#) $Id: tclWinChan.c,v 1.30.2.1 2004/06/21 22:07:32 mdejong Exp $
*/
#include "tclWinInt.h"
@@ -131,6 +131,17 @@ static void *INITIAL_ESP,
*RESTORED_HANDLER;
#endif /* HAVE_NO_SEH && TCL_MEM_DEBUG */
+#ifdef HAVE_NO_SEH
+static
+__attribute__ ((cdecl))
+EXCEPTION_DISPOSITION
+_except_makefilechannel_handler(
+ struct _EXCEPTION_RECORD *ExceptionRecord,
+ void *EstablisherFrame,
+ struct _CONTEXT *ContextRecord,
+ void *DispatcherContext);
+#endif
+
/*
*----------------------------------------------------------------------
@@ -1059,10 +1070,13 @@ Tcl_MakeFileChannel(rawHandle, mode)
result = 0;
__asm__ __volatile__ (
- "pushl %ebp" "\n\t"
- "pushl $__except_makefilechannel_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_makefilechannel_handler)
+ );
#else
__try {
#endif /* HAVE_NO_SEH */
@@ -1126,6 +1140,22 @@ Tcl_MakeFileChannel(rawHandle, mode)
return channel;
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * _except_makefilechannel_handler --
+ *
+ * SEH exception handler for Tcl_MakeFileChannel.
+ *
+ * Results:
+ * See Tcl_MakeFileChannel.
+ *
+ * Side effects:
+ * See Tcl_MakeFileChannel.
+ *
+ *----------------------------------------------------------------------
+ */
#ifdef HAVE_NO_SEH
static
__attribute__ ((cdecl))
@@ -1138,8 +1168,6 @@ _except_makefilechannel_handler(
{
__asm__ __volatile__ (
"jmp makefilechannel_reentry");
- /* Nuke compiler warning about unused static function */
- _except_makefilechannel_handler(NULL, NULL, NULL, NULL);
return 0; /* Function does not return */
}
#endif
diff --git a/win/tclWinFCmd.c b/win/tclWinFCmd.c
index 3992fb2..e8033f9 100644
--- a/win/tclWinFCmd.c
+++ b/win/tclWinFCmd.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: tclWinFCmd.c,v 1.35.2.1 2003/10/03 17:45:37 vincentdarley Exp $
+ * RCS: @(#) $Id: tclWinFCmd.c,v 1.35.2.2 2004/06/21 22:07:32 mdejong Exp $
*/
#include "tclWinInt.h"
@@ -82,6 +82,27 @@ static void *INITIAL_ESP,
*RESTORED_HANDLER;
#endif /* HAVE_NO_SEH && TCL_MEM_DEBUG */
+#ifdef HAVE_NO_SEH
+static
+__attribute__ ((cdecl))
+EXCEPTION_DISPOSITION
+_except_dorenamefile_handler(
+ struct _EXCEPTION_RECORD *ExceptionRecord,
+ void *EstablisherFrame,
+ struct _CONTEXT *ContextRecord,
+ void *DispatcherContext);
+
+static
+__attribute__ ((cdecl))
+EXCEPTION_DISPOSITION
+_except_docopyfile_handler(
+ struct _EXCEPTION_RECORD *ExceptionRecord,
+ void *EstablisherFrame,
+ struct _CONTEXT *ContextRecord,
+ void *DispatcherContext);
+
+#endif /* HAVE_NO_SEH */
+
/*
* Prototype for the TraverseWinTree callback function.
*/
@@ -202,10 +223,13 @@ DoRenameFile(
# endif /* TCL_MEM_DEBUG */
__asm__ __volatile__ (
- "pushl %ebp" "\n\t"
- "pushl $__except_dorenamefile_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_dorenamefile_handler)
+ );
#else
__try {
#endif /* HAVE_NO_SEH */
@@ -467,6 +491,22 @@ DoRenameFile(
}
return TCL_ERROR;
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * _except_dorenamefile_handler --
+ *
+ * SEH exception handler for DoRenameFile.
+ *
+ * Results:
+ * See DoRenameFile.
+ *
+ * Side effects:
+ * See DoRenameFile.
+ *
+ *----------------------------------------------------------------------
+ */
#ifdef HAVE_NO_SEH
static
__attribute__ ((cdecl))
@@ -479,8 +519,6 @@ _except_dorenamefile_handler(
{
__asm__ __volatile__ (
"jmp dorenamefile_reentry");
- /* Nuke compiler warning about unused static function */
- _except_dorenamefile_handler(NULL, NULL, NULL, NULL);
return 0; /* Function does not return */
}
#endif /* HAVE_NO_SEH */
@@ -556,10 +594,13 @@ DoCopyFile(
# endif /* TCL_MEM_DEBUG */
__asm__ __volatile__ (
- "pushl %ebp" "\n\t"
- "pushl $__except_docopyfile_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_docopyfile_handler)
+ );
#else
__try {
#endif /* HAVE_NO_SEH */
@@ -649,6 +690,22 @@ DoCopyFile(
}
return TCL_ERROR;
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * _except_docopyfile_handler --
+ *
+ * SEH exception handler for DoCopyFile.
+ *
+ * Results:
+ * See DoCopyFile.
+ *
+ * Side effects:
+ * See DoCopyFile.
+ *
+ *----------------------------------------------------------------------
+ */
#ifdef HAVE_NO_SEH
static
__attribute__ ((cdecl))
@@ -661,7 +718,6 @@ _except_docopyfile_handler(
{
__asm__ __volatile__ (
"jmp docopyfile_reentry");
- _except_docopyfile_handler(NULL,NULL,NULL,NULL);
return 0; /* Function does not return */
}
#endif /* HAVE_NO_SEH */