1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
-
+
|
/*
* tclUnixInit.c --
*
* Contains the Unix-specific interpreter initialization functions.
*
* Copyright (c) 1995-1997 Sun Microsystems, Inc.
* Copyright (c) 1999 by Scriptics Corporation.
* All rights reserved.
*
* RCS: @(#) $Id: tclUnixInit.c,v 1.76 2007/11/10 19:01:35 msofer Exp $
* RCS: @(#) $Id: tclUnixInit.c,v 1.77 2007/11/10 20:49:21 das Exp $
*/
#include "tclInt.h"
#include <stddef.h>
#include <locale.h>
#ifdef HAVE_LANGINFO
# include <langinfo.h>
|
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
-
+
|
#ifndef TCL_NO_STACK_CHECK
typedef struct ThreadSpecificData {
int *outerVarPtr; /* The "outermost" stack frame pointer for
* this thread. */
int *stackBound; /* The current stack boundary */
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
static stackGrowsDown = -1;
static int stackGrowsDown = -1;
static int StackGrowsDown(int *parent);
#endif /* TCL_NO_STACK_CHECK */
#ifdef TCL_DEBUG_STACK_CHECK
#define STACK_DEBUG(args) printf args
#else
#define STACK_DEBUG(args) (void)0
|
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
|
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
|
-
+
-
-
-
+
+
+
|
*/
stackGrowsDown = StackGrowsDown(&result);
}
/*
* The first time through in a thread: record the "outermost" stack
* frame and inquire the OS about the stack size.
* frame and inquire with the OS about the stack size.
*/
if (tsdPtr->outerVarPtr == NULL) {
tsdPtr->outerVarPtr = &result;
result = GetStackSize(&stackSize);
if (result != TCL_OK) {
/* Can't check, assume it always succeeds */
stackGrowsDown = 1;
tsdPtr->stackBound = NULL;
goto done;
}
}
if (stackSize || (stackGrowsDown && (&result < tsdPtr->stackBound))
|| (!stackGrowsDown && (&result > tsdPtr->stackBound))) {
/*
* Either the thread's first pass or stack failure: set the params
*/
/*
* Either the thread's first pass or stack failure: set the params
*/
if (!stackSize) {
/*
* Stack failure: if we didn't already blow up, we are within the
* safety area. Recheck with the OS in case the stack was grown.
*/
result = GetStackSize(&stackSize);
|