From cd3420740909b3b6a2140b613b591b7556b417a2 Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 12 Jan 2015 22:30:49 +0000 Subject: [PATCH] py: Can compile with -Wmissing-declarations and -Wmissing-prototypes. --- py/builtin.h | 6 +----- py/modbuiltins.c | 1 + py/modsys.c | 5 +++++ py/obj.c | 8 +------- py/pfenv.h | 4 +++- py/pfenv_printf.c | 8 ++++++++ py/warning.c | 2 +- stmhal/printf.c | 2 -- unix/file.c | 1 + unix/gccollect.c | 2 +- unix/main.c | 1 - 11 files changed, 22 insertions(+), 18 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 + #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 #include #include +#include #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 #include -#include "py/obj.h" #include "py/emit.h" +#include "py/runtime.h" #if MICROPY_WARNINGS diff --git a/stmhal/printf.c b/stmhal/printf.c index a239e898c9..f7a4f1038f 100644 --- a/stmhal/printf.c +++ b/stmhal/printf.c @@ -36,8 +36,6 @@ #include "py/formatfloat.h" #endif -int pfenv_vprintf(const pfenv_t *pfenv, const char *fmt, va_list args); - STATIC void stdout_print_strn(void *dummy_env, const char *str, mp_uint_t len) { stdout_tx_strn_cooked(str, len); } diff --git a/unix/file.c b/unix/file.c index b62154baaa..7f1b285a5d 100644 --- a/unix/file.c +++ b/unix/file.c @@ -34,6 +34,7 @@ #include "py/nlr.h" #include "py/runtime.h" #include "py/stream.h" +#include "py/builtin.h" #ifdef _WIN32 #define fsync _commit diff --git a/unix/gccollect.c b/unix/gccollect.c index f8bcbf965d..16bfc3b486 100644 --- a/unix/gccollect.c +++ b/unix/gccollect.c @@ -51,7 +51,7 @@ STATIC void gc_helper_get_regs(regs_t arr) { #ifdef __x86_64__ typedef mp_uint_t regs_t[6]; -void gc_helper_get_regs(regs_t arr) { +STATIC void gc_helper_get_regs(regs_t arr) { register long rbx asm ("rbx"); register long rbp asm ("rbp"); register long r12 asm ("r12"); diff --git a/unix/main.c b/unix/main.c index 3dd71eff8c..d635127783 100644 --- a/unix/main.c +++ b/unix/main.c @@ -482,7 +482,6 @@ int main(int argc, char **argv) { } if (mp_verbose_flag) { - extern mp_obj_t mp_micropython_mem_info(mp_uint_t n_args, const mp_obj_t *args); mp_micropython_mem_info(0, NULL); }