Commit c3280d83 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

unix: Use printf() implementation in terms of mp_printf().

In other words, unix port now uses overriden printf(), instead of using
libc's. This should remove almost all dependency on libc stdio (which
is bloated).
parent ede1f547
...@@ -51,7 +51,14 @@ int vprintf(const char *fmt, va_list ap) { ...@@ -51,7 +51,14 @@ int vprintf(const char *fmt, va_list ap) {
int DEBUG_printf(const char *fmt, ...) { int DEBUG_printf(const char *fmt, ...) {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
#if MICROPY_DEBUG_STDERR
// Printing debug to stderr may give a chance tests which
// check stdout to pass, etc.
extern const mp_print_t mp_stderr_print;
int ret = mp_vprintf(&mp_stderr_print, fmt, ap);
#else
int ret = mp_vprintf(&mp_plat_print, fmt, ap); int ret = mp_vprintf(&mp_plat_print, fmt, ap);
#endif
va_end(ap); va_end(ap);
return ret; return ret;
} }
......
...@@ -129,6 +129,7 @@ endif ...@@ -129,6 +129,7 @@ endif
LIB_SRC_C = $(addprefix lib/,\ LIB_SRC_C = $(addprefix lib/,\
$(LIB_SRC_C_EXTRA) \ $(LIB_SRC_C_EXTRA) \
utils/printf.c \
) )
OBJ = $(PY_O) OBJ = $(PY_O)
......
...@@ -574,14 +574,6 @@ uint mp_import_stat(const char *path) { ...@@ -574,14 +574,6 @@ uint mp_import_stat(const char *path) {
return MP_IMPORT_STAT_NO_EXIST; return MP_IMPORT_STAT_NO_EXIST;
} }
int DEBUG_printf(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
int ret = mp_vprintf(&mp_stderr_print, fmt, ap);
va_end(ap);
return ret;
}
void nlr_jump_fail(void *val) { void nlr_jump_fail(void *val) {
printf("FATAL: uncaught NLR %p\n", val); printf("FATAL: uncaught NLR %p\n", val);
exit(1); exit(1);
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#define MICROPY_MALLOC_USES_ALLOCATED_SIZE (1) #define MICROPY_MALLOC_USES_ALLOCATED_SIZE (1)
#define MICROPY_MEM_STATS (1) #define MICROPY_MEM_STATS (1)
#define MICROPY_DEBUG_PRINTERS (1) #define MICROPY_DEBUG_PRINTERS (1)
#define MICROPY_DEBUG_STDERR (1)
#define MICROPY_USE_READLINE_HISTORY (1) #define MICROPY_USE_READLINE_HISTORY (1)
#define MICROPY_HELPER_REPL (1) #define MICROPY_HELPER_REPL (1)
#define MICROPY_REPL_EMACS_KEYS (1) #define MICROPY_REPL_EMACS_KEYS (1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment