| 1 |
|
| 2 |
#include "common_header.h" |
| 3 |
#include "structdef.h" |
| 4 |
#include <src/stack.h> |
| 5 |
#include <src/threadlocal.h> |
| 6 |
#include <stdio.h> |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
rpy_stacktoobig_t rpy_stacktoobig = { |
| 15 |
NULL, |
| 16 |
MAX_STACK_SIZE, |
| 17 |
1 |
| 18 |
}; |
| 19 |
|
| 20 |
void LL_stack_set_length_fraction(double fraction) |
| 21 |
{ |
| 22 |
rpy_stacktoobig.stack_length = (Signed)(MAX_STACK_SIZE * fraction); |
| 23 |
} |
| 24 |
|
| 25 |
char LL_stack_too_big_slowpath(Signed current) |
| 26 |
{ |
| 27 |
Signed diff, max_stack_size; |
| 28 |
char *baseptr, *curptr = (char*)current; |
| 29 |
char *tl; |
| 30 |
struct pypy_threadlocal_s *tl1; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
OP_THREADLOCALREF_ADDR(tl); |
| 39 |
tl1 = (struct pypy_threadlocal_s *)tl; |
| 40 |
baseptr = tl1->stack_end; |
| 41 |
max_stack_size = rpy_stacktoobig.stack_length; |
| 42 |
if (baseptr == NULL) { |
| 43 |
|
| 44 |
} |
| 45 |
else { |
| 46 |
diff = baseptr - curptr; |
| 47 |
if (((Unsigned)diff) <= (Unsigned)max_stack_size) { |
| 48 |
|
| 49 |
rpy_stacktoobig.stack_end = baseptr; |
| 50 |
return 0; |
| 51 |
} |
| 52 |
if (((Unsigned)-diff) <= (Unsigned)max_stack_size) { |
| 53 |
|
| 54 |
|
| 55 |
} |
| 56 |
else { |
| 57 |
return rpy_stacktoobig.report_error; |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
baseptr = curptr; |
| 63 |
tl1->stack_end = baseptr; |
| 64 |
rpy_stacktoobig.stack_end = baseptr; |
| 65 |
return 0; |
| 66 |
} |