diff options
Diffstat (limited to 'win/tclWin32Dll.c')
-rw-r--r-- | win/tclWin32Dll.c | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c index dde720e..c17285e 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.14 2002/03/08 01:45:52 mdejong Exp $ + * RCS: @(#) $Id: tclWin32Dll.c,v 1.15 2002/03/15 01:10:19 mdejong Exp $ */ #include "tclWinInt.h" @@ -37,6 +37,11 @@ typedef VOID (WINAPI UTUNREGISTER)(HANDLE hModule); static HINSTANCE hInstance; /* HINSTANCE of this DLL. */ static int platformId; /* Running under NT, or 95/98? */ +#ifdef HAVE_NO_SEH +static void *ESP; +static void *EBP; +#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, @@ -349,17 +354,56 @@ TclpCheckStackSpace() * exception if the stack pointer is set below the bottom of the stack. */ +#ifdef HAVE_NO_SEH + __asm__ __volatile__ ( + "movl %esp, _ESP" "\n\t" + "movl %ebp, _EBP"); + + __asm__ __volatile__ ( + "pushl $__except_checkstackspace_handler" "\n\t" + "pushl %fs:0" "\n\t" + "mov %esp, %fs:0"); +#else __try { +#endif /* HAVE_NO_SEH */ alloca(TCL_WIN_STACK_THRESHOLD); retval = 1; +#ifdef HAVE_NO_SEH + __asm__ __volatile__ ( + "jmp checkstackspace_pop" "\n" + "checkstackspace_reentry:" "\n\t" + "movl _ESP, %esp" "\n\t" + "movl _EBP, %ebp"); + + __asm__ __volatile__ ( + "checkstackspace_pop:" "\n\t" + "mov (%esp), %eax" "\n\t" + "mov %eax, %fs:0" "\n\t" + "add $8, %esp"); +#else } __except (EXCEPTION_EXECUTE_HANDLER) {} +#endif /* HAVE_NO_SEH */ /* * Avoid using control flow statements in the SEH guarded block! */ return retval; } - +#ifdef HAVE_NO_SEH +static +__attribute__ ((cdecl)) +EXCEPTION_DISPOSITION +_except_checkstackspace_handler( + struct _EXCEPTION_RECORD *ExceptionRecord, + void *EstablisherFrame, + struct _CONTEXT *ContextRecord, + void *DispatcherContext) +{ + __asm__ __volatile__ ( + "jmp checkstackspace_reentry"); + return 0; /* Function does not return */ +} +#endif /* HAVE_NO_SEH */ /* *---------------------------------------------------------------------- |