Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
91d457a2
Commit
91d457a2
authored
Jan 20, 2014
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py: Put micropython module init code in builtinmp.c.
parent
58923362
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
py/builtin.h
+1
-3
1 addition, 3 deletions
py/builtin.h
py/builtinmp.c
+16
-3
16 additions, 3 deletions
py/builtinmp.c
py/runtime.c
+1
-7
1 addition, 7 deletions
py/runtime.c
with
18 additions
and
13 deletions
py/builtin.h
+
1
−
3
View file @
91d457a2
...
@@ -27,6 +27,4 @@ MP_DECLARE_CONST_FUN_OBJ(mp_builtin_sorted_obj);
...
@@ -27,6 +27,4 @@ MP_DECLARE_CONST_FUN_OBJ(mp_builtin_sorted_obj);
MP_DECLARE_CONST_FUN_OBJ
(
mp_builtin_sum_obj
);
MP_DECLARE_CONST_FUN_OBJ
(
mp_builtin_sum_obj
);
MP_DECLARE_CONST_FUN_OBJ
(
mp_builtin_str_obj
);
MP_DECLARE_CONST_FUN_OBJ
(
mp_builtin_str_obj
);
MP_DECLARE_CONST_FUN_OBJ
(
mp_builtin_mem_total_obj
);
void
mp_module_micropython_init
(
void
);
MP_DECLARE_CONST_FUN_OBJ
(
mp_builtin_mem_current_obj
);
MP_DECLARE_CONST_FUN_OBJ
(
mp_builtin_mem_peak_obj
);
This diff is collapsed.
Click to expand it.
py/builtinmp.c
+
16
−
3
View file @
91d457a2
...
@@ -7,7 +7,9 @@
...
@@ -7,7 +7,9 @@
#include
"misc.h"
#include
"misc.h"
#include
"mpconfig.h"
#include
"mpconfig.h"
#include
"mpqstr.h"
#include
"obj.h"
#include
"obj.h"
#include
"runtime.h"
#include
"builtin.h"
#include
"builtin.h"
// Various builtins specific to MicroPython runtime,
// Various builtins specific to MicroPython runtime,
...
@@ -15,18 +17,29 @@
...
@@ -15,18 +17,29 @@
#if MICROPY_MEM_STATS
#if MICROPY_MEM_STATS
static
mp_obj_t
mem_total
()
{
static
mp_obj_t
mem_total
()
{
return
MP_OBJ_NEW_SMALL_INT
(
m_get_total_bytes_allocated
());
return
MP_OBJ_NEW_SMALL_INT
(
(
machine_int_t
)
m_get_total_bytes_allocated
());
}
}
static
mp_obj_t
mem_current
()
{
static
mp_obj_t
mem_current
()
{
return
MP_OBJ_NEW_SMALL_INT
(
m_get_current_bytes_allocated
());
return
MP_OBJ_NEW_SMALL_INT
(
(
machine_int_t
)
m_get_current_bytes_allocated
());
}
}
static
mp_obj_t
mem_peak
()
{
static
mp_obj_t
mem_peak
()
{
return
MP_OBJ_NEW_SMALL_INT
(
m_get_peak_bytes_allocated
());
return
MP_OBJ_NEW_SMALL_INT
(
(
machine_int_t
)
m_get_peak_bytes_allocated
());
}
}
MP_DEFINE_CONST_FUN_OBJ_0
(
mp_builtin_mem_total_obj
,
mem_total
);
MP_DEFINE_CONST_FUN_OBJ_0
(
mp_builtin_mem_total_obj
,
mem_total
);
MP_DEFINE_CONST_FUN_OBJ_0
(
mp_builtin_mem_current_obj
,
mem_current
);
MP_DEFINE_CONST_FUN_OBJ_0
(
mp_builtin_mem_current_obj
,
mem_current
);
MP_DEFINE_CONST_FUN_OBJ_0
(
mp_builtin_mem_peak_obj
,
mem_peak
);
MP_DEFINE_CONST_FUN_OBJ_0
(
mp_builtin_mem_peak_obj
,
mem_peak
);
#endif
#endif
void
mp_module_micropython_init
(
void
)
{
mp_obj_t
m_mp
=
mp_obj_new_module
(
MP_QSTR_micropython
);
rt_store_name
(
MP_QSTR_micropython
,
m_mp
);
#if MICROPY_MEM_STATS
rt_store_attr
(
m_mp
,
qstr_from_str_static
(
"mem_total"
),
(
mp_obj_t
)
&
mp_builtin_mem_total_obj
);
rt_store_attr
(
m_mp
,
qstr_from_str_static
(
"mem_current"
),
(
mp_obj_t
)
&
mp_builtin_mem_current_obj
);
rt_store_attr
(
m_mp
,
qstr_from_str_static
(
"mem_peak"
),
(
mp_obj_t
)
&
mp_builtin_mem_peak_obj
);
#endif
}
This diff is collapsed.
Click to expand it.
py/runtime.c
+
1
−
7
View file @
91d457a2
...
@@ -157,13 +157,7 @@ void rt_init(void) {
...
@@ -157,13 +157,7 @@ void rt_init(void) {
mp_obj_new_module
(
qstr_from_str_static
(
"sys"
));
mp_obj_new_module
(
qstr_from_str_static
(
"sys"
));
#endif
#endif
mp_obj_t
m_mp
=
mp_obj_new_module
(
qstr_from_str_static
(
"micropython"
));
mp_module_micropython_init
();
rt_store_name
(
qstr_from_str_static
(
"micropython"
),
m_mp
);
#if MICROPY_MEM_STATS
rt_store_attr
(
m_mp
,
qstr_from_str_static
(
"mem_total"
),
(
mp_obj_t
)
&
mp_builtin_mem_total_obj
);
rt_store_attr
(
m_mp
,
qstr_from_str_static
(
"mem_current"
),
(
mp_obj_t
)
&
mp_builtin_mem_current_obj
);
rt_store_attr
(
m_mp
,
qstr_from_str_static
(
"mem_peak"
),
(
mp_obj_t
)
&
mp_builtin_mem_peak_obj
);
#endif
next_unique_code_id
=
1
;
// 0 indicates "no code"
next_unique_code_id
=
1
;
// 0 indicates "no code"
unique_codes_alloc
=
0
;
unique_codes_alloc
=
0
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment