35
35
extern uint32_t _estack ;
36
36
37
37
// Requested size.
38
- static uint32_t next_stack_size = CIRCUITPY_DEFAULT_STACK_SIZE ;
38
+ static uint32_t next_stack_size = 0 ;
39
39
static uint32_t current_stack_size = 0 ;
40
40
// Actual location and size, may be larger than requested.
41
41
static uint32_t * stack_limit = NULL ;
@@ -49,11 +49,15 @@ static void allocate_stack(void) {
49
49
stack_limit = port_stack_get_limit ();
50
50
stack_length = (port_stack_get_top () - stack_limit ) * sizeof (uint32_t );
51
51
current_stack_size = stack_length ;
52
+ next_stack_size = stack_length ;
52
53
} else {
53
54
mp_uint_t regs [10 ];
54
55
mp_uint_t sp = cpu_get_regs_and_sp (regs );
55
56
56
57
mp_uint_t c_size = (mp_uint_t )port_stack_get_top () - sp ;
58
+ if (next_stack_size == 0 ) {
59
+ next_stack_size = CIRCUITPY_DEFAULT_STACK_SIZE ;
60
+ }
57
61
supervisor_allocation * stack_alloc = allocate_memory (c_size + next_stack_size + EXCEPTION_STACK_SIZE , true, false);
58
62
if (stack_alloc == NULL ) {
59
63
stack_alloc = allocate_memory (c_size + CIRCUITPY_DEFAULT_STACK_SIZE + EXCEPTION_STACK_SIZE , true, false);
@@ -103,8 +107,12 @@ size_t stack_get_length(void) {
103
107
return stack_length ;
104
108
}
105
109
106
- void set_next_stack_size (uint32_t size ) {
110
+ bool set_next_stack_size (uint32_t size ) {
111
+ if (port_has_fixed_stack ()) {
112
+ return false;
113
+ }
107
114
next_stack_size = size ;
115
+ return true;
108
116
}
109
117
110
118
uint32_t get_next_stack_size (void ) {
0 commit comments