stackctrl: Add "mp_" prefix.

This commit is contained in:
Paul Sokolovsky 2014-07-01 02:13:42 +03:00
parent e95b6b5e07
commit caa7334141
8 changed files with 20 additions and 20 deletions

View File

@ -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) { 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 // There can be data structures nested too deep, or just recursive
STACK_CHECK(); MP_STACK_CHECK();
#if !NDEBUG #if !NDEBUG
if (o_in == NULL) { if (o_in == NULL) {
print(env, "(nil)"); print(env, "(nil)");

View File

@ -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) { 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 n_args: %d, n_kw: %d\n", n_args, n_kw);
DEBUG_printf("Input pos args: "); DEBUG_printf("Input pos args: ");

View File

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

View File

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

View File

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

View File

@ -188,7 +188,7 @@ int main(void) {
// Stack limit should be less than real stack size, so we // Stack limit should be less than real stack size, so we
// had chance to recover from limit hit. // 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: /* STM32F4xx HAL library initialization:
- Configure the Flash prefetch, instruction and Data caches - Configure the Flash prefetch, instruction and Data caches

View File

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

View File

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