summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2007-11-10 22:24:12 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2007-11-10 22:24:12 (GMT)
commit6e7b0d042d8e2395df7a6408768fde12c23abdae (patch)
tree566675aa0f9a8b20448e3bc3c1b1726ad3c82f0e /unix
parentdb8435f4f6d903ab177a991ed393676493928b77 (diff)
downloadtcl-6e7b0d042d8e2395df7a6408768fde12c23abdae.zip
tcl-6e7b0d042d8e2395df7a6408768fde12c23abdae.tar.gz
tcl-6e7b0d042d8e2395df7a6408768fde12c23abdae.tar.bz2
* generic/tclBasic.c:
* unix/configure.in: * unix/tclUnixInit.c: detect stack grwoth direction at compile time, only fall to runtime detection when crosscompiling.
Diffstat (limited to 'unix')
-rw-r--r--unix/configure.in31
-rw-r--r--unix/tclUnixInit.c15
2 files changed, 42 insertions, 4 deletions
diff --git a/unix/configure.in b/unix/configure.in
index 3901138..ed1cb51 100644
--- a/unix/configure.in
+++ b/unix/configure.in
@@ -3,7 +3,7 @@ dnl This file is an input file used by the GNU "autoconf" program to
dnl generate the file "configure", which is run during Tcl installation
dnl to configure the system for the local environment.
#
-# RCS: @(#) $Id: configure.in,v 1.167 2007/10/30 19:03:57 dgp Exp $
+# RCS: @(#) $Id: configure.in,v 1.168 2007/11/10 22:24:14 msofer Exp $
AC_INIT([tcl],[8.5])
AC_PREREQ(2.59)
@@ -658,6 +658,35 @@ fi
AC_MSG_RESULT([$tcl_ok])
#--------------------------------------------------------------------
+# Does the C stack grow upwards or downwards? Or cross-compiling?
+#--------------------------------------------------------------------
+
+AC_CACHE_CHECK([does the C stack grow upwards in memory?], tcl_cv_stack_grows_up, [
+ AC_TRY_RUN([
+ int StackGrowsUp(int *parent)
+ {
+ int here;
+ return (&here < parent);
+ }
+
+ int main (int argc, char *argv[])
+ {
+ int foo;
+ return StackGrowsUp(&foo);
+ }
+ ],
+ tcl_cv_stack_grows_up=yes,
+ tcl_cv_stack_grows_up=no,
+ tcl_cv_stack_grows_up=unknown)])
+if test $tcl_cv_stack_grows_up = unknown; then
+ AC_DEFINE(TCL_CROSS_COMPILE, 1,
+ [Are we cross-compiling?])
+elif test $tcl_cv_stack_grows_up = yes; then
+ AC_DEFINE(TCL_STACK_GROWS_UP, 1,
+ [The C stack grows upwards in memory])
+fi
+
+#--------------------------------------------------------------------
# The statements below define a collection of symbols related to
# building libtcl as a shared library instead of a static library.
#--------------------------------------------------------------------
diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c
index e4ba0f2..9202c26 100644
--- a/unix/tclUnixInit.c
+++ b/unix/tclUnixInit.c
@@ -7,7 +7,7 @@
* Copyright (c) 1999 by Scriptics Corporation.
* All rights reserved.
*
- * RCS: @(#) $Id: tclUnixInit.c,v 1.77 2007/11/10 20:49:21 das Exp $
+ * RCS: @(#) $Id: tclUnixInit.c,v 1.78 2007/11/10 22:24:14 msofer Exp $
*/
#include "tclInt.h"
@@ -81,8 +81,14 @@ typedef struct ThreadSpecificData {
int *stackBound; /* The current stack boundary */
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
+#ifdef TCL_CROSS_COMPILE
static int stackGrowsDown = -1;
static int StackGrowsDown(int *parent);
+#elif defined(TCL_STACK_GROWS_UP)
+static int stackGrowsDown = 0;
+#else
+static int stackGrowsDown = 1;
+#endif
#endif /* TCL_NO_STACK_CHECK */
#ifdef TCL_DEBUG_STACK_CHECK
@@ -1035,7 +1041,7 @@ TclpGetCStackParams(
/* Most variables are actually in a
* thread-specific data block to minimise the
* impact on the stack. */
-
+#ifdef TCL_CROSS_COMPILE
if (stackGrowsDown == -1) {
/*
* Not initialised!
@@ -1043,7 +1049,8 @@ TclpGetCStackParams(
stackGrowsDown = StackGrowsDown(&result);
}
-
+#endif
+
/*
* The first time through in a thread: record the "outermost" stack
* frame and inquire with the OS about the stack size.
@@ -1094,6 +1101,7 @@ TclpGetCStackParams(
return stackGrowsDown;
}
+#ifdef TCL_CROSS_COMPILE
int
StackGrowsDown(
int *parent)
@@ -1102,6 +1110,7 @@ StackGrowsDown(
return (&here < parent);
}
#endif
+#endif
/*