The R Project SVN R

Rev

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

Rev 63454 Rev 63481
Line 81... Line 81...
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)
86
void R_SignalCStackOverflow(intptr_t usage)
87
{
87
{
88
    /* We do need some stack space to process error recovery, so
88
    /* We do need some stack space to process error recovery, so
89
       temporarily raise the limit.  We have 5% head room because we
89
       temporarily raise the limit.  We have 5% head room because we
90
       reduced R_CStackLimit to 95% of the initial value in
90
       reduced R_CStackLimit to 95% of the initial value in
91
       setup_Rmainloop.
91
       setup_Rmainloop.
Line 96... Line 96...
96
    begincontext(&cntxt, CTXT_CCODE, R_NilValue, R_BaseEnv, R_BaseEnv,
96
    begincontext(&cntxt, CTXT_CCODE, R_NilValue, R_BaseEnv, R_BaseEnv,
97
		 R_NilValue, R_NilValue);
97
		 R_NilValue, R_NilValue);
98
    cntxt.cend = &reset_stack_limit;
98
    cntxt.cend = &reset_stack_limit;
99
    cntxt.cenddata = &stacklimit;
99
    cntxt.cenddata = &stacklimit;
100
 
100
 
101
    errorcall(R_NilValue, "C stack usage is too close to the limit");
101
    errorcall(R_NilValue, "C stack usage  %ld is too close to the limit", usage);
102
    /* Do not translate this, to save stack space */
102
    /* Do not translate this, to save stack space */
103
}
103
}
104
 
104
 
105
void (R_CheckStack)(void)
105
void (R_CheckStack)(void)
106
{
106
{
107
    int dummy;
107
    int dummy;
108
    intptr_t usage = R_CStackDir * (R_CStackStart - (uintptr_t)&dummy);
108
    intptr_t usage = R_CStackDir * (R_CStackStart - (uintptr_t)&dummy);
109
 
109
 
110
    /* printf("usage %ld\n", usage); */
110
    /* printf("usage %ld\n", usage); */
111
    if(R_CStackLimit != -1 && usage > ((intptr_t) R_CStackLimit))
111
    if(R_CStackLimit != -1 && usage > ((intptr_t) R_CStackLimit))
112
	R_SignalCStackOverflow();
112
	R_SignalCStackOverflow(usage);
113
}
113
}
114
 
114
 
115
void R_CheckStack2(size_t extra)
115
void R_CheckStack2(size_t extra)
116
{
116
{
117
    int dummy;
117
    int dummy;
Line 119... Line 119...
119
 
119
 
120
    /* do it this way, as some compilers do usage + extra 
120
    /* do it this way, as some compilers do usage + extra 
121
       in unsigned arithmetic */
121
       in unsigned arithmetic */
122
    usage += extra;
122
    usage += extra;
123
    if(R_CStackLimit != -1 && usage > ((intptr_t) R_CStackLimit))
123
    if(R_CStackLimit != -1 && usage > ((intptr_t) R_CStackLimit))
124
	R_SignalCStackOverflow();
124
	R_SignalCStackOverflow(usage);
125
 
125
 
126
}
126
}
127
 
127
 
128
void R_CheckUserInterrupt(void)
128
void R_CheckUserInterrupt(void)
129
{
129
{