diff options
author | mdejong <mdejong> | 2003-01-25 12:48:12 (GMT) |
---|---|---|
committer | mdejong <mdejong> | 2003-01-25 12:48:12 (GMT) |
commit | 758234180a856302c7aa063a7fbb6cb06145cd56 (patch) | |
tree | 218e72ad308897b4b323ce9ce00ba395738f37c9 /win/tclWin32Dll.c | |
parent | f9b9d749cefde03a0e20c3fe82fd51cb3298e0f0 (diff) | |
download | tcl-758234180a856302c7aa063a7fbb6cb06145cd56.zip tcl-758234180a856302c7aa063a7fbb6cb06145cd56.tar.gz tcl-758234180a856302c7aa063a7fbb6cb06145cd56.tar.bz2 |
* win/configure:
* win/configure.in: Define HAVE_ALLOCA_GCC_INLINE
when we detect that no alloca function is found
in malloc.h and we are compiling with GCC.
Remove HAVE_NO_ALLOC_DECL define.
* win/tclWin32Dll.c (TclpCheckStackSpace):
Don't define alloca as a cdecl function.
Doing this caused a tricky runtime bug because
the _alloca function expects the size argument
to be passed in a register and not on the stack.
To fix this problem, we use inline ASM when
compiling with gcc to invoke _alloca with the
size argument loaded into a register.
Diffstat (limited to 'win/tclWin32Dll.c')
-rw-r--r-- | win/tclWin32Dll.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c index 1c029f8..13f2a4b 100644 --- a/win/tclWin32Dll.c +++ b/win/tclWin32Dll.c @@ -9,16 +9,11 @@ * 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.21 2003/01/24 08:04:29 mdejong Exp $ + * RCS: @(#) $Id: tclWin32Dll.c,v 1.22 2003/01/25 12:48:12 mdejong Exp $ */ #include "tclWinInt.h" -#if defined(HAVE_NO_ALLOC_DECL) -void* __cdecl _alloca(size_t size); -#define alloca _alloca -#endif /* HAVE_NO_ALLOC_DECL */ - /* * The following data structures are used when loading the thunking * library for execing child processes under Win32s. @@ -395,7 +390,16 @@ TclpCheckStackSpace() #else __try { #endif /* HAVE_NO_SEH */ +#ifdef HAVE_ALLOCA_GCC_INLINE + __asm__ __volatile__ ( + "movl %0, %%eax" "\n\t" + "call __alloca" "\n\t" + : + : "i"(TCL_WIN_STACK_THRESHOLD) + : "%eax"); +#else alloca(TCL_WIN_STACK_THRESHOLD); +#endif /* HAVE_ALLOCA_GCC_INLINE */ retval = 1; #ifdef HAVE_NO_SEH __asm__ __volatile__ ( |