3535extern uint32_t _estack ;
3636
3737// Requested size.
38- static uint32_t next_stack_size = CIRCUITPY_DEFAULT_STACK_SIZE ;
38+ static uint32_t next_stack_size = 0 ;
3939static uint32_t current_stack_size = 0 ;
4040// Actual location and size, may be larger than requested.
4141static uint32_t * stack_limit = NULL ;
@@ -49,11 +49,15 @@ static void allocate_stack(void) {
4949 stack_limit = port_stack_get_limit ();
5050 stack_length = (port_stack_get_top () - stack_limit ) * sizeof (uint32_t );
5151 current_stack_size = stack_length ;
52+ next_stack_size = stack_length ;
5253 } else {
5354 mp_uint_t regs [10 ];
5455 mp_uint_t sp = cpu_get_regs_and_sp (regs );
5556
5657 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+ }
5761 supervisor_allocation * stack_alloc = allocate_memory (c_size + next_stack_size + EXCEPTION_STACK_SIZE , true, false);
5862 if (stack_alloc == NULL ) {
5963 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) {
103107 return stack_length ;
104108}
105109
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+ }
107114 next_stack_size = size ;
115+ return true;
108116}
109117
110118uint32_t get_next_stack_size (void ) {
0 commit comments