Browse Source

stackctrl: Add "mp_" prefix.

pull/739/head
Paul Sokolovsky 11 years ago
parent
commit
caa7334141
  1. 2
      py/obj.c
  2. 2
      py/objfun.c
  3. 2
      py/runtime.c
  4. 12
      py/stackctrl.c
  5. 14
      py/stackctrl.h
  6. 2
      stmhal/main.c
  7. 2
      unix/gccollect.c
  8. 4
      unix/main.c

2
py/obj.c

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

2
py/objfun.c

@ -356,7 +356,7 @@ continue2:;
STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
STACK_CHECK();
MP_STACK_CHECK();
DEBUG_printf("Input n_args: %d, n_kw: %d\n", n_args, n_kw);
DEBUG_printf("Input pos args: ");

2
py/runtime.c

@ -70,7 +70,7 @@ const mp_obj_module_t mp_module___main__ = {
};
void mp_init(void) {
stack_ctrl_init();
mp_stack_ctrl_init();
// call port specific initialization if any
#ifdef MICROPY_PORT_INIT_FUNC

12
py/stackctrl.c

@ -35,12 +35,12 @@
// Stack top at the start of program
char *stack_top;
void stack_ctrl_init() {
void mp_stack_ctrl_init() {
volatile int stack_dummy;
stack_top = (char*)&stack_dummy;
}
uint stack_usage() {
uint mp_stack_usage() {
// Assumes descending stack
volatile int stack_dummy;
return stack_top - (char*)&stack_dummy;
@ -48,14 +48,14 @@ uint stack_usage() {
#if MICROPY_STACK_CHECK
uint stack_limit = 10240;
static uint stack_limit = 10240;
void stack_set_limit(uint limit) {
void mp_stack_set_limit(uint limit) {
stack_limit = limit;
}
void stack_check() {
if (stack_usage() >= stack_limit) {
void mp_stack_check() {
if (mp_stack_usage() >= stack_limit) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_RuntimeError, "maximum recursion depth exceeded"));
}
}

14
py/stackctrl.h

@ -24,18 +24,18 @@
* THE SOFTWARE.
*/
void stack_ctrl_init();
uint stack_usage();
void mp_stack_ctrl_init();
uint mp_stack_usage();
#if MICROPY_STACK_CHECK
void stack_set_limit(uint limit);
void stack_check();
#define STACK_CHECK() stack_check()
void mp_stack_set_limit(uint limit);
void mp_stack_check();
#define MP_STACK_CHECK() mp_stack_check()
#else
#define stack_set_limit(limit)
#define STACK_CHECK()
#define mp_stack_set_limit(limit)
#define MP_STACK_CHECK()
#endif

2
stmhal/main.c

@ -188,7 +188,7 @@ int main(void) {
// Stack limit should be less than real stack size, so we
// had chance to recover from limit hit.
stack_set_limit(&_ram_end - &_heap_end - 512);
mp_stack_set_limit(&_ram_end - &_heap_end - 512);
/* STM32F4xx HAL library initialization:
- Configure the Flash prefetch, instruction and Data caches

2
unix/gccollect.c

@ -32,7 +32,7 @@
#if MICROPY_ENABLE_GC
extern void *stack_top;
extern char *stack_top;
#if MICROPY_GCREGS_SETJMP
#include <setjmp.h>

4
unix/main.c

@ -214,7 +214,7 @@ int usage(char **argv) {
mp_obj_t mem_info(void) {
printf("mem: total=%d, current=%d, peak=%d\n",
m_get_total_bytes_allocated(), m_get_current_bytes_allocated(), m_get_peak_bytes_allocated());
printf("stack: %u\n", stack_usage());
printf("stack: %u\n", mp_stack_usage());
#if MICROPY_ENABLE_GC
gc_dump_info();
#endif
@ -265,7 +265,7 @@ void pre_process_options(int argc, char **argv) {
#endif
int main(int argc, char **argv) {
stack_set_limit(32768);
mp_stack_set_limit(32768);
pre_process_options(argc, argv);

Loading…
Cancel
Save