Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
caa73341
Commit
caa73341
authored
Jul 01, 2014
by
Paul Sokolovsky
Browse files
stackctrl: Add "mp_" prefix.
parent
e95b6b5e
Changes
8
Hide whitespace changes
Inline
Side-by-side
py/obj.c
View file @
caa73341
...
...
@@ -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)"
);
...
...
py/objfun.c
View file @
caa73341
...
...
@@ -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: "
);
...
...
py/runtime.c
View file @
caa73341
...
...
@@ -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
...
...
py/stackctrl.c
View file @
caa73341
...
...
@@ -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"
));
}
}
...
...
py/stackctrl.h
View file @
caa73341
...
...
@@ -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
stmhal/main.c
View file @
caa73341
...
...
@@ -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
...
...
unix/gccollect.c
View file @
caa73341
...
...
@@ -32,7 +32,7 @@
#if MICROPY_ENABLE_GC
extern
void
*
stack_top
;
extern
char
*
stack_top
;
#if MICROPY_GCREGS_SETJMP
#include
<setjmp.h>
...
...
unix/main.c
View file @
caa73341
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment