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
910843e8
Commit
910843e8
authored
11 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
Allow ports to define statically builtin functions.
Convert unix open() to such.
parent
70d7a83c
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
py/mpconfig.h
+4
-0
4 additions, 0 deletions
py/mpconfig.h
py/runtime.c
+3
-0
3 additions, 0 deletions
py/runtime.c
unix/file.c
+0
-2
0 additions, 2 deletions
unix/file.c
unix/main.c
+0
-1
0 additions, 1 deletion
unix/main.c
unix/mpconfigport.h
+5
-0
5 additions, 0 deletions
unix/mpconfigport.h
with
12 additions
and
3 deletions
py/mpconfig.h
+
4
−
0
View file @
910843e8
...
@@ -107,6 +107,10 @@ typedef long long mp_longint_impl_t;
...
@@ -107,6 +107,10 @@ typedef long long mp_longint_impl_t;
#define MICROPY_PATH_MAX (512)
#define MICROPY_PATH_MAX (512)
#endif
#endif
// Additional builtin function definitions - see runtime.c:builtin_table for format.
#ifndef MICROPY_EXTRA_BUILTINS
#define MICROPY_EXTRA_BUILTINS
#endif
/*****************************************************************************/
/*****************************************************************************/
/* Miscellaneous settings */
/* Miscellaneous settings */
...
...
This diff is collapsed.
Click to expand it.
py/runtime.c
+
3
−
0
View file @
910843e8
...
@@ -144,6 +144,9 @@ STATIC const mp_builtin_elem_t builtin_table[] = {
...
@@ -144,6 +144,9 @@ STATIC const mp_builtin_elem_t builtin_table[] = {
{
MP_QSTR_str
,
(
mp_obj_t
)
&
mp_builtin_str_obj
},
{
MP_QSTR_str
,
(
mp_obj_t
)
&
mp_builtin_str_obj
},
{
MP_QSTR_bytearray
,
(
mp_obj_t
)
&
mp_builtin_bytearray_obj
},
{
MP_QSTR_bytearray
,
(
mp_obj_t
)
&
mp_builtin_bytearray_obj
},
// Extra builtins as defined by a port
MICROPY_EXTRA_BUILTINS
{
MP_QSTR_
,
MP_OBJ_NULL
},
// end of list sentinel
{
MP_QSTR_
,
MP_OBJ_NULL
},
// end of list sentinel
};
};
...
...
This diff is collapsed.
Click to expand it.
unix/file.c
+
0
−
2
View file @
910843e8
...
@@ -136,8 +136,6 @@ mp_obj_t mp_builtin_open(uint n_args, const mp_obj_t *args) {
...
@@ -136,8 +136,6 @@ mp_obj_t mp_builtin_open(uint n_args, const mp_obj_t *args) {
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
mp_builtin_open_obj
,
1
,
2
,
mp_builtin_open
);
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
mp_builtin_open_obj
,
1
,
2
,
mp_builtin_open
);
void
file_init
()
{
void
file_init
()
{
rt_store_name
(
MP_QSTR_open
,
(
mp_obj_t
)
&
mp_builtin_open_obj
);
mp_obj_t
m_sys
=
mp_obj_new_module
(
MP_QSTR_sys
);
mp_obj_t
m_sys
=
mp_obj_new_module
(
MP_QSTR_sys
);
rt_store_attr
(
m_sys
,
MP_QSTR_stdin
,
fdfile_new
(
STDIN_FILENO
));
rt_store_attr
(
m_sys
,
MP_QSTR_stdin
,
fdfile_new
(
STDIN_FILENO
));
rt_store_attr
(
m_sys
,
MP_QSTR_stdout
,
fdfile_new
(
STDOUT_FILENO
));
rt_store_attr
(
m_sys
,
MP_QSTR_stdout
,
fdfile_new
(
STDOUT_FILENO
));
...
...
This diff is collapsed.
Click to expand it.
unix/main.c
+
0
−
1
View file @
910843e8
...
@@ -29,7 +29,6 @@
...
@@ -29,7 +29,6 @@
// Stack top at the start of program
// Stack top at the start of program
void
*
stack_top
;
void
*
stack_top
;
extern
const
mp_obj_fun_native_t
mp_builtin_open_obj
;
void
file_init
();
void
file_init
();
void
microsocket_init
();
void
microsocket_init
();
void
time_init
();
void
time_init
();
...
...
This diff is collapsed.
Click to expand it.
unix/mpconfigport.h
+
5
−
0
View file @
910843e8
...
@@ -36,3 +36,8 @@ typedef const void *machine_const_ptr_t; // must be of pointer size
...
@@ -36,3 +36,8 @@ typedef const void *machine_const_ptr_t; // must be of pointer size
typedef
double
machine_float_t
;
typedef
double
machine_float_t
;
machine_float_t
machine_sqrt
(
machine_float_t
x
);
machine_float_t
machine_sqrt
(
machine_float_t
x
);
struct
_mp_obj_fun_native_t
;
extern
const
struct
_mp_obj_fun_native_t
mp_builtin_open_obj
;
#define MICROPY_EXTRA_BUILTINS \
{ MP_QSTR_open, (mp_obj_t)&mp_builtin_open_obj },
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