The R Project SVN R

Rev

Rev 63292 | Rev 63431 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 63292 Rev 63426
Line 72... Line 72...
72
			     /
72
			     /
73
		    warning /
73
		    warning /
74
 
74
 
75
  ErrorMessage()-> errorcall   (but with message from ErrorDB[])
75
  ErrorMessage()-> errorcall   (but with message from ErrorDB[])
76
 
76
 
77
  WarningMessage()-> warningcall (but with message from WarningDB[]).
77
  WarningMessage()-> warningcall (but with message Rfrom WarningDB[]).
78
*/
78
*/
79
 
79
 
80
static void reset_stack_limit(void *data)
80
static void reset_stack_limit(void *data)
81
{
81
{
82
    unsigned int *limit = (unsigned int *) data;
82
    unsigned int *limit = (unsigned int *) data;
83
    R_CStackLimit = *limit;
83
    R_CStackLimit = *limit;
84
}
84
}
85
 
85
 
-
 
86
void R_SignalCStackOverflow(void)
-
 
87
{
-
 
88
    /* We do need some stack space to process error recovery, so
-
 
89
       temporarily raise the limit.  We have 5% head room because we
-
 
90
       reduced R_CStackLimit to 95% of the initial value in
-
 
91
       setup_Rmainloop.
-
 
92
    */
-
 
93
    RCNTXT cntxt;
-
 
94
    uintptr_t stacklimit = R_CStackLimit;
-
 
95
    R_CStackLimit += 0.05*R_CStackLimit;
-
 
96
    begincontext(&cntxt, CTXT_CCODE, R_NilValue, R_BaseEnv, R_BaseEnv,
-
 
97
		 R_NilValue, R_NilValue);
-
 
98
    cntxt.cend = &reset_stack_limit;
-
 
99
    cntxt.cenddata = &stacklimit;
-
 
100
 
-
 
101
    errorcall(R_NilValue, "C stack usage is too close to the limit");
-
 
102
    /* Do not translate this, to save stack space */
-
 
103
}
-
 
104
 
86
void R_CheckStack(void)
105
void (R_CheckStack)(void)
87
{
106
{
88
    int dummy;
107
    int dummy;
89
    intptr_t usage = R_CStackDir * (R_CStackStart - (uintptr_t)&dummy);
108
    intptr_t usage = R_CStackDir * (R_CStackStart - (uintptr_t)&dummy);
90
 
109
 
91
    /* printf("usage %ld\n", usage); */
110
    /* printf("usage %ld\n", usage); */
92
    if(R_CStackLimit != -1 && usage > 0.95 * R_CStackLimit) {
111
    if(R_CStackLimit != -1 && usage > /*0.95 * */R_CStackLimit) 
93
	/* We do need some stack space to process error recovery,
-
 
94
	   so temporarily raise the limit.
-
 
95
	 */
-
 
96
	RCNTXT cntxt;
-
 
97
	uintptr_t stacklimit = R_CStackLimit;
-
 
98
	R_CStackLimit += 0.05*R_CStackLimit;
-
 
99
	begincontext(&cntxt, CTXT_CCODE, R_NilValue, R_BaseEnv, R_BaseEnv,
-
 
100
		     R_NilValue, R_NilValue);
112
	R_SignalCStackOverflow();
101
	cntxt.cend = &reset_stack_limit;
-
 
102
	cntxt.cenddata = &stacklimit;
-
 
103
 
-
 
104
	errorcall(R_NilValue, "C stack usage is too close to the limit");
-
 
105
	/* Do not translate this, to save stack space */
-
 
106
    }
-
 
107
}
113
}
108
 
114
 
109
void R_CheckStack2(size_t extra)
115
void R_CheckStack2(size_t extra)
110
{
116
{
111
    int dummy;
117
    int dummy;
112
    intptr_t usage = R_CStackDir * (R_CStackStart - (uintptr_t)&dummy);
118
    intptr_t usage = R_CStackDir * (R_CStackStart - (uintptr_t)&dummy);
113
 
119
 
114
    /* do it this way, as some compilers do usage + extra 
120
    /* do it this way, as some compilers do usage + extra 
115
       in unsigned arithmetic */
121
       in unsigned arithmetic */
116
    usage += extra;
122
    usage += extra;
117
    if(R_CStackLimit != -1 && usage > 0.95 * R_CStackLimit) {
123
    if(R_CStackLimit != -1 && usage > /*0.95 * */R_CStackLimit)
118
	/* We do need some stack space to process error recovery,
-
 
119
	   so temporarily raise the limit.
-
 
120
	 */
-
 
121
	RCNTXT cntxt;
-
 
122
	uintptr_t stacklimit = R_CStackLimit;
-
 
123
	R_CStackLimit += 0.05*R_CStackLimit;
-
 
124
	begincontext(&cntxt, CTXT_CCODE, R_NilValue, R_BaseEnv, R_BaseEnv,
-
 
125
		     R_NilValue, R_NilValue);
124
	R_SignalCStackOverflow();
126
	cntxt.cend = &reset_stack_limit;
-
 
127
	cntxt.cenddata = &stacklimit;
-
 
128
 
125
 
129
	errorcall(R_NilValue, "C stack usage is too close to the limit");
-
 
130
	/* Do not translate this, to save stack space */
-
 
131
    }
-
 
132
}
126
}
133
 
127
 
134
void R_CheckUserInterrupt(void)
128
void R_CheckUserInterrupt(void)
135
{
129
{
136
    R_CheckStack();
130
    R_CheckStack();