diff options
author | stanton <stanton> | 1999-03-04 00:59:04 (GMT) |
---|---|---|
committer | stanton <stanton> | 1999-03-04 00:59:04 (GMT) |
commit | 8f454748c96a81bfa1d37e8d7623fa5aeee9e22a (patch) | |
tree | 058a9a158cb0e0604b3a04093c6edad0bb7d09a5 /win | |
parent | e0ebc1eba1e0844b07f50bb167e3497fa3048b62 (diff) | |
download | tcl-8f454748c96a81bfa1d37e8d7623fa5aeee9e22a.zip tcl-8f454748c96a81bfa1d37e8d7623fa5aeee9e22a.tar.gz tcl-8f454748c96a81bfa1d37e8d7623fa5aeee9e22a.tar.bz2 |
* win/tclWinInt.h:
* win/tclWin32Dll.c:
* unix/tclUnixInit.c: Added TclpCheckStackSpace.
Diffstat (limited to 'win')
-rw-r--r-- | win/tclWin32Dll.c | 37 | ||||
-rw-r--r-- | win/tclWinInt.h | 10 |
2 files changed, 45 insertions, 2 deletions
diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c index 9de0589..c3de691 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.4 1998/09/14 18:40:19 stanton Exp $ + * RCS: @(#) $Id: tclWin32Dll.c,v 1.4.4.1 1999/03/04 00:59:04 stanton Exp $ */ #include "tclWinInt.h" @@ -378,6 +378,41 @@ TclWinGetTclInstance() /* *---------------------------------------------------------------------- * + * TclpCheckStackSpace -- + * + * Detect if we are about to blow the stack. Called before an + * evaluation can happen when nesting depth is checked. + * + * Results: + * 1 if there is enough stack space to continue; 0 if not. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int +TclpCheckStackSpace() +{ + /* + * We can recurse only if there is at least TCL_WIN_STACK_THRESHOLD + * bytes of stack space left. alloca() is cheap on windows; basically + * it just subtracts from the stack pointer causing the OS to throw an + * exception if the stack pointer is set below the bottom of the stack. + */ + + try { + alloca(TCL_WIN_STACK_THRESHOLD); + return 1; + } except (1) {} + + return 0; +} + +/* + *---------------------------------------------------------------------- + * * TclWinGetPlatformId -- * * Determines whether running under NT, 95, or Win32s, to allow diff --git a/win/tclWinInt.h b/win/tclWinInt.h index 4169472..64c43f7 100644 --- a/win/tclWinInt.h +++ b/win/tclWinInt.h @@ -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: tclWinInt.h,v 1.5 1998/09/14 18:40:20 stanton Exp $ + * RCS: @(#) $Id: tclWinInt.h,v 1.5.4.1 1999/03/04 00:59:04 stanton Exp $ */ #ifndef _TCLWININT @@ -27,6 +27,14 @@ #endif /* + * The following specifies how much stack space TclpCheckStackSpace() + * ensures is available. TclpCheckStackSpace() is called by Tcl_EvalObj() + * to help avoid overflowing the stack in the case of infinite recursion. + */ + +#define TCL_WIN_STACK_THRESHOLD 0x2000 + +/* * Some versions of Borland C have a define for the OSVERSIONINFO for * Win32s and for NT, but not for Windows 95. */ |