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
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
a1ddfcc2
Commit
a1ddfcc2
authored
11 years ago
by
Damien
Browse files
Options
Downloads
Patches
Plain Diff
Wrap out-native code in preprocessor declarations.
parent
eb19efb2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
py/runtime.c
+16
-0
16 additions, 0 deletions
py/runtime.c
with
16 additions
and
0 deletions
py/runtime.c
+
16
−
0
View file @
a1ddfcc2
...
...
@@ -10,6 +10,8 @@
#include
"bc.h"
#if 0 // print debugging info
#define DEBUG_PRINT (1)
#define WRITE_NATIVE (1)
#define DEBUG_printf(args...) printf(args)
#define DEBUG_OP_printf(args...) printf(args)
#else
// don't print debugging info
...
...
@@ -357,7 +359,9 @@ py_obj_t py_builtin___build_class__(py_obj_t o_class_fun, py_obj_t o_class_name)
return
o
;
}
#ifdef WRITE_NATIVE
FILE
*
fp_native
=
NULL
;
#endif
void
rt_init
()
{
q_append
=
qstr_from_str_static
(
"append"
);
...
...
@@ -383,13 +387,17 @@ void rt_init() {
fun_list_append
=
rt_make_function_2
(
list_append
);
#ifdef WRITE_NATIVE
fp_native
=
fopen
(
"out-native"
,
"wb"
);
#endif
}
void
rt_deinit
()
{
#ifdef WRITE_NATIVE
if
(
fp_native
!=
NULL
)
{
fclose
(
fp_native
);
}
#endif
}
int
rt_get_new_unique_code_id
()
{
...
...
@@ -425,6 +433,7 @@ void rt_assign_native_code(int unique_code_id, py_fun_t fun, uint len, int n_arg
unique_codes
[
unique_code_id
].
n_args
=
n_args
;
unique_codes
[
unique_code_id
].
u_native
.
fun
=
fun
;
#ifdef DEBUG_PRINT
DEBUG_printf
(
"assign native code: id=%d fun=%p len=%u n_args=%d
\n
"
,
unique_code_id
,
fun
,
len
,
n_args
);
byte
*
fun_data
=
(
byte
*
)(((
machine_uint_t
)
fun
)
&
(
~
1
));
// need to clear lower bit in case it's thumb code
for
(
int
i
=
0
;
i
<
128
&&
i
<
len
;
i
++
)
{
...
...
@@ -435,10 +444,13 @@ void rt_assign_native_code(int unique_code_id, py_fun_t fun, uint len, int n_arg
}
DEBUG_printf
(
"
\n
"
);
#ifdef WRITE_NATIVE
if
(
fp_native
!=
NULL
)
{
fwrite
(
fun_data
,
len
,
1
,
fp_native
);
fflush
(
fp_native
);
}
#endif
#endif
}
void
rt_assign_inline_asm_code
(
int
unique_code_id
,
py_fun_t
fun
,
uint
len
,
int
n_args
)
{
...
...
@@ -449,6 +461,7 @@ void rt_assign_inline_asm_code(int unique_code_id, py_fun_t fun, uint len, int n
unique_codes
[
unique_code_id
].
n_args
=
n_args
;
unique_codes
[
unique_code_id
].
u_inline_asm
.
fun
=
fun
;
#ifdef DEBUG_PRINT
DEBUG_printf
(
"assign inline asm code: id=%d fun=%p len=%u n_args=%d
\n
"
,
unique_code_id
,
fun
,
len
,
n_args
);
byte
*
fun_data
=
(
byte
*
)(((
machine_uint_t
)
fun
)
&
(
~
1
));
// need to clear lower bit in case it's thumb code
for
(
int
i
=
0
;
i
<
128
&&
i
<
len
;
i
++
)
{
...
...
@@ -459,9 +472,12 @@ void rt_assign_inline_asm_code(int unique_code_id, py_fun_t fun, uint len, int n
}
DEBUG_printf
(
"
\n
"
);
#ifdef WRITE_NATIVE
if
(
fp_native
!=
NULL
)
{
fwrite
(
fun_data
,
len
,
1
,
fp_native
);
}
#endif
#endif
}
bool
py_obj_is_callable
(
py_obj_t
o_in
)
{
...
...
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