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
a374d9c8
Commit
a374d9c8
authored
Mar 1, 2014
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
unix: Allow to set heap size using "-X heapsize=N" option.
parent
25f5a30e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
unix/main.c
+55
-28
55 additions, 28 deletions
unix/main.c
with
55 additions
and
28 deletions
unix/main.c
+
55
−
28
View file @
a374d9c8
...
...
@@ -24,9 +24,10 @@
#include
<readline/history.h>
#endif
#if MICROPY_ENABLE_GC
// Heap size of GC heap (if enabled)
// TODO: allow to specify on command line
#
define HEAP_SIZE 128*1024
long
heap_size
=
128
*
1024
;
#
endif
// Stack top at the start of program
void
*
stack_top
;
...
...
@@ -233,13 +234,34 @@ static mp_obj_t pyb_gc(void) {
MP_DEFINE_CONST_FUN_OBJ_0
(
pyb_gc_obj
,
pyb_gc
);
#endif
// Process options which set interpreter init options
void
pre_process_options
(
int
argc
,
char
**
argv
)
{
for
(
int
a
=
1
;
a
<
argc
;
a
++
)
{
if
(
argv
[
a
][
0
]
==
'-'
)
{
if
(
strcmp
(
argv
[
a
],
"-X"
)
==
0
)
{
if
(
a
+
1
>=
argc
)
{
exit
(
usage
());
}
#if MICROPY_ENABLE_GC
if
(
strncmp
(
argv
[
a
+
1
],
"heapsize="
,
sizeof
(
"heapsize="
)
-
1
)
==
0
)
{
heap_size
=
strtol
(
argv
[
a
+
1
]
+
sizeof
(
"heapsize="
)
-
1
,
NULL
,
0
);
}
#endif
a
++
;
}
}
}
}
int
main
(
int
argc
,
char
**
argv
)
{
volatile
int
stack_dummy
;
stack_top
=
(
void
*
)
&
stack_dummy
;
pre_process_options
(
argc
,
argv
);
#if MICROPY_ENABLE_GC
char
*
heap
=
malloc
(
HEAP_SIZE
);
gc_init
(
heap
,
heap
+
HEAP_SIZE
);
char
*
heap
=
malloc
(
heap_size
);
gc_init
(
heap
,
heap
+
heap_size
);
#endif
qstr_init
();
...
...
@@ -319,9 +341,7 @@ int main(int argc, char **argv) {
printf(" peak %d\n", m_get_peak_bytes_allocated());
*/
if
(
argc
==
1
)
{
do_repl
();
}
else
{
bool
executed
=
false
;
for
(
int
a
=
1
;
a
<
argc
;
a
++
)
{
if
(
argv
[
a
][
0
]
==
'-'
)
{
if
(
strcmp
(
argv
[
a
],
"-c"
)
==
0
)
{
...
...
@@ -329,6 +349,9 @@ int main(int argc, char **argv) {
return
usage
();
}
do_str
(
argv
[
a
+
1
]);
executed
=
true
;
a
+=
1
;
}
else
if
(
strcmp
(
argv
[
a
],
"-X"
)
==
0
)
{
a
+=
1
;
}
else
{
return
usage
();
...
...
@@ -345,9 +368,13 @@ int main(int argc, char **argv) {
rt_list_append
(
py_argv
,
MP_OBJ_NEW_QSTR
(
qstr_from_str
(
argv
[
i
])));
}
do_file
(
argv
[
a
]);
executed
=
true
;
break
;
}
}
if
(
!
executed
)
{
do_repl
();
}
rt_deinit
();
...
...
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