summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/builtin.h6
-rw-r--r--py/modbuiltins.c1
-rw-r--r--py/modsys.c5
-rw-r--r--py/obj.c8
-rw-r--r--py/pfenv.h4
-rw-r--r--py/pfenv_printf.c8
-rw-r--r--py/warning.c2
7 files changed, 20 insertions, 14 deletions
diff --git a/py/builtin.h b/py/builtin.h
index 70cc28ae14..ddd63a7dad 100644
--- a/py/builtin.h
+++ b/py/builtin.h
@@ -30,6 +30,7 @@
mp_obj_t mp_builtin___import__(mp_uint_t n_args, const mp_obj_t *args);
mp_obj_t mp_builtin_open(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
+mp_obj_t mp_micropython_mem_info(mp_uint_t n_args, const mp_obj_t *args);
MP_DECLARE_CONST_FUN_OBJ(mp_builtin___build_class___obj);
MP_DECLARE_CONST_FUN_OBJ(mp_builtin___import___obj);
@@ -91,11 +92,6 @@ extern const mp_obj_module_t mp_module_gc;
extern const mp_obj_dict_t mp_module_builtins_globals;
-struct _dummy_t;
-extern struct _dummy_t mp_sys_stdin_obj;
-extern struct _dummy_t mp_sys_stdout_obj;
-extern struct _dummy_t mp_sys_stderr_obj;
-
// extmod modules
extern const mp_obj_module_t mp_module_uctypes;
extern const mp_obj_module_t mp_module_uzlib;
diff --git a/py/modbuiltins.c b/py/modbuiltins.c
index 2a5b7a19cf..b739503ade 100644
--- a/py/modbuiltins.c
+++ b/py/modbuiltins.c
@@ -406,6 +406,7 @@ STATIC mp_obj_t mp_builtin_print(mp_uint_t n_args, const mp_obj_t *args, mp_map_
end_data = mp_obj_str_get_data(end_elem->value, &end_len);
}
#if MICROPY_PY_IO
+ extern mp_uint_t mp_sys_stdout_obj; // type is irrelevant, just need pointer
mp_obj_t stream_obj = &mp_sys_stdout_obj;
mp_map_elem_t *file_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_file), MP_MAP_LOOKUP);
if (file_elem != NULL && file_elem->value != mp_const_none) {
diff --git a/py/modsys.c b/py/modsys.c
index 51bd6bfbb4..51e10dae54 100644
--- a/py/modsys.c
+++ b/py/modsys.c
@@ -37,6 +37,11 @@
/// \module sys - system specific functions
+// defined per port; type of these is irrelevant, just need pointer
+extern mp_uint_t mp_sys_stdin_obj;
+extern mp_uint_t mp_sys_stdout_obj;
+extern mp_uint_t mp_sys_stderr_obj;
+
// These two lists must be initialised per port (after the call to mp_init).
// TODO document these properly, they aren't constants or functions...
/// \constant path - a mutable list of directories to search for imported modules
diff --git a/py/obj.c b/py/obj.c
index e58330a9d5..1133914bb9 100644
--- a/py/obj.c
+++ b/py/obj.c
@@ -36,6 +36,7 @@
#include "py/runtime0.h"
#include "py/runtime.h"
#include "py/stackctrl.h"
+#include "py/pfenv.h"
mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) {
if (MP_OBJ_IS_SMALL_INT(o_in)) {
@@ -52,13 +53,6 @@ const char *mp_obj_get_type_str(mp_const_obj_t o_in) {
return qstr_str(mp_obj_get_type(o_in)->name);
}
-void printf_wrapper(void *env, const char *fmt, ...) {
- va_list args;
- va_start(args, fmt);
- vprintf(fmt, args);
- va_end(args);
-}
-
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
MP_STACK_CHECK();
diff --git a/py/pfenv.h b/py/pfenv.h
index 074c0012f8..01258f8202 100644
--- a/py/pfenv.h
+++ b/py/pfenv.h
@@ -26,6 +26,8 @@
#ifndef __MICROPY_INCLUDED_PY_PFENV_H__
#define __MICROPY_INCLUDED_PY_PFENV_H__
+#include <stdarg.h>
+
#include "py/obj.h"
#define PF_FLAG_LEFT_ADJUST (0x001)
@@ -54,7 +56,7 @@ int pfenv_print_mp_int(const pfenv_t *pfenv, mp_obj_t x, int sgn, int base, int
int pfenv_print_float(const pfenv_t *pfenv, mp_float_t f, char fmt, int flags, char fill, int width, int prec);
#endif
-//int pfenv_vprintf(const pfenv_t *pfenv, const char *fmt, va_list args);
+int pfenv_vprintf(const pfenv_t *pfenv, const char *fmt, va_list args);
int pfenv_printf(const pfenv_t *pfenv, const char *fmt, ...);
// Wrapper for system printf
diff --git a/py/pfenv_printf.c b/py/pfenv_printf.c
index 39bf321ce3..a68788a7f6 100644
--- a/py/pfenv_printf.c
+++ b/py/pfenv_printf.c
@@ -27,6 +27,7 @@
#include <assert.h>
#include <string.h>
#include <stdarg.h>
+#include <stdio.h>
#include "py/pfenv.h"
@@ -193,3 +194,10 @@ int pfenv_printf(const pfenv_t *pfenv, const char *fmt, ...) {
va_end(ap);
return ret;
}
+
+void printf_wrapper(void *env, const char *fmt, ...) {
+ va_list args;
+ va_start(args, fmt);
+ vprintf(fmt, args);
+ va_end(args);
+}
diff --git a/py/warning.c b/py/warning.c
index 4cce177664..469c19cea7 100644
--- a/py/warning.c
+++ b/py/warning.c
@@ -27,8 +27,8 @@
#include <stdarg.h>
#include <stdio.h>
-#include "py/obj.h"
#include "py/emit.h"
+#include "py/runtime.h"
#if MICROPY_WARNINGS