summaryrefslogtreecommitdiffstatshomepage
path: root/lib/utils
diff options
context:
space:
mode:
authorstijn <stijn@ignitron.net>2018-07-03 12:22:39 +0200
committerDamien George <damien.p.george@gmail.com>2018-07-05 19:44:18 +1000
commit8ad30fa433ec917aee1780abfa5ddea7a86c9596 (patch)
treed50dc583049c84c8b69b14286ca0d059f446c9cc /lib/utils
parent1751f5ac7bd48f5673791801b052487ae73d064d (diff)
downloadmicropython-8ad30fa433ec917aee1780abfa5ddea7a86c9596.tar.gz
micropython-8ad30fa433ec917aee1780abfa5ddea7a86c9596.zip
lib/utils/printf: Make DEBUG_printf implementation more accessible.
The definition of DEBUG_printf doesn't depend on MICROPY_USE_INTERNAL_PRINTF so move it out of that preprocessor block and compile it conditionally just depending on the MICROPY_DEBUG_PRINTERS macro. This allows a port to use DEBUG_printf while providing it's own printf definition.
Diffstat (limited to 'lib/utils')
-rw-r--r--lib/utils/printf.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/lib/utils/printf.c b/lib/utils/printf.c
index 51dfa5b963..117efff42c 100644
--- a/lib/utils/printf.c
+++ b/lib/utils/printf.c
@@ -26,8 +26,6 @@
#include "py/mpconfig.h"
-#if MICROPY_USE_INTERNAL_PRINTF
-
#include <stdint.h>
#include <string.h>
#include <stdarg.h>
@@ -39,6 +37,22 @@
#include "py/formatfloat.h"
#endif
+#if MICROPY_DEBUG_PRINTERS
+int DEBUG_printf(const char *fmt, ...) {
+ va_list ap;
+ va_start(ap, fmt);
+ #ifndef MICROPY_DEBUG_PRINTER_DEST
+ #define MICROPY_DEBUG_PRINTER_DEST mp_plat_print
+ #endif
+ extern const mp_print_t MICROPY_DEBUG_PRINTER_DEST;
+ int ret = mp_vprintf(&MICROPY_DEBUG_PRINTER_DEST, fmt, ap);
+ va_end(ap);
+ return ret;
+}
+#endif
+
+#if MICROPY_USE_INTERNAL_PRINTF
+
#undef putchar // Some stdlibs have a #define for putchar
int printf(const char *fmt, ...);
int vprintf(const char *fmt, va_list ap);
@@ -59,20 +73,6 @@ int vprintf(const char *fmt, va_list ap) {
return mp_vprintf(&mp_plat_print, fmt, ap);
}
-#if MICROPY_DEBUG_PRINTERS
-int DEBUG_printf(const char *fmt, ...) {
- va_list ap;
- va_start(ap, fmt);
- #ifndef MICROPY_DEBUG_PRINTER_DEST
- #define MICROPY_DEBUG_PRINTER_DEST mp_plat_print
- #endif
- extern const mp_print_t MICROPY_DEBUG_PRINTER_DEST;
- int ret = mp_vprintf(&MICROPY_DEBUG_PRINTER_DEST, fmt, ap);
- va_end(ap);
- return ret;
-}
-#endif
-
// need this because gcc optimises printf("%c", c) -> putchar(c), and printf("a") -> putchar('a')
int putchar(int c) {
char chr = c;