Skip to content

Commit caa7334

Browse files
committed
stackctrl: Add "mp_" prefix.
1 parent e95b6b5 commit caa7334

8 files changed

Lines changed: 20 additions & 20 deletions

File tree

py/obj.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void printf_wrapper(void *env, const char *fmt, ...) {
6161

6262
void mp_obj_print_helper(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
6363
// There can be data structures nested too deep, or just recursive
64-
STACK_CHECK();
64+
MP_STACK_CHECK();
6565
#if !NDEBUG
6666
if (o_in == NULL) {
6767
print(env, "(nil)");

py/objfun.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ continue2:;
356356

357357

358358
STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
359-
STACK_CHECK();
359+
MP_STACK_CHECK();
360360

361361
DEBUG_printf("Input n_args: %d, n_kw: %d\n", n_args, n_kw);
362362
DEBUG_printf("Input pos args: ");

py/runtime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const mp_obj_module_t mp_module___main__ = {
7070
};
7171

7272
void mp_init(void) {
73-
stack_ctrl_init();
73+
mp_stack_ctrl_init();
7474

7575
// call port specific initialization if any
7676
#ifdef MICROPY_PORT_INIT_FUNC

py/stackctrl.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,27 @@
3535
// Stack top at the start of program
3636
char *stack_top;
3737

38-
void stack_ctrl_init() {
38+
void mp_stack_ctrl_init() {
3939
volatile int stack_dummy;
4040
stack_top = (char*)&stack_dummy;
4141
}
4242

43-
uint stack_usage() {
43+
uint mp_stack_usage() {
4444
// Assumes descending stack
4545
volatile int stack_dummy;
4646
return stack_top - (char*)&stack_dummy;
4747
}
4848

4949
#if MICROPY_STACK_CHECK
5050

51-
uint stack_limit = 10240;
51+
static uint stack_limit = 10240;
5252

53-
void stack_set_limit(uint limit) {
53+
void mp_stack_set_limit(uint limit) {
5454
stack_limit = limit;
5555
}
5656

57-
void stack_check() {
58-
if (stack_usage() >= stack_limit) {
57+
void mp_stack_check() {
58+
if (mp_stack_usage() >= stack_limit) {
5959
nlr_raise(mp_obj_new_exception_msg(&mp_type_RuntimeError, "maximum recursion depth exceeded"));
6060
}
6161
}

py/stackctrl.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@
2424
* THE SOFTWARE.
2525
*/
2626

27-
void stack_ctrl_init();
28-
uint stack_usage();
27+
void mp_stack_ctrl_init();
28+
uint mp_stack_usage();
2929

3030
#if MICROPY_STACK_CHECK
3131

32-
void stack_set_limit(uint limit);
33-
void stack_check();
34-
#define STACK_CHECK() stack_check()
32+
void mp_stack_set_limit(uint limit);
33+
void mp_stack_check();
34+
#define MP_STACK_CHECK() mp_stack_check()
3535

3636
#else
3737

38-
#define stack_set_limit(limit)
39-
#define STACK_CHECK()
38+
#define mp_stack_set_limit(limit)
39+
#define MP_STACK_CHECK()
4040

4141
#endif

stmhal/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ int main(void) {
188188

189189
// Stack limit should be less than real stack size, so we
190190
// had chance to recover from limit hit.
191-
stack_set_limit(&_ram_end - &_heap_end - 512);
191+
mp_stack_set_limit(&_ram_end - &_heap_end - 512);
192192

193193
/* STM32F4xx HAL library initialization:
194194
- Configure the Flash prefetch, instruction and Data caches

unix/gccollect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
#if MICROPY_ENABLE_GC
3434

35-
extern void *stack_top;
35+
extern char *stack_top;
3636

3737
#if MICROPY_GCREGS_SETJMP
3838
#include <setjmp.h>

unix/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ int usage(char **argv) {
214214
mp_obj_t mem_info(void) {
215215
printf("mem: total=%d, current=%d, peak=%d\n",
216216
m_get_total_bytes_allocated(), m_get_current_bytes_allocated(), m_get_peak_bytes_allocated());
217-
printf("stack: %u\n", stack_usage());
217+
printf("stack: %u\n", mp_stack_usage());
218218
#if MICROPY_ENABLE_GC
219219
gc_dump_info();
220220
#endif
@@ -265,7 +265,7 @@ void pre_process_options(int argc, char **argv) {
265265
#endif
266266

267267
int main(int argc, char **argv) {
268-
stack_set_limit(32768);
268+
mp_stack_set_limit(32768);
269269

270270
pre_process_options(argc, argv);
271271

0 commit comments

Comments
 (0)