diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2013-01-23 11:01:20 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-01-23 20:34:16 +0100 |
commit | b1da925c8a8ab9145cbbc3d9359f8d81881b261d (patch) | |
tree | a2d268343f2e9b7f2d33e94adef26ac2e8c10850 /include/stdio.h | |
parent | 2bdc28c475654435f0c92a578d7ad44de6638f61 (diff) | |
download | barebox-b1da925c8a8ab9145cbbc3d9359f8d81881b261d.tar.gz barebox-b1da925c8a8ab9145cbbc3d9359f8d81881b261d.tar.xz |
introduce console none support
this will allow to have no console support
Use full for bootstrap as we can save 6.5 KiB (barebox.bin) and
3.8 KiB (zbarebox.bin lzo) on at91sam9263 as example vs console simple
As on bootstrap we have often very limited size.
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/stdio.h')
-rw-r--r-- | include/stdio.h | 64 |
1 files changed, 54 insertions, 10 deletions
diff --git a/include/stdio.h b/include/stdio.h index 4901bc7182..5c091a8eab 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -11,6 +11,15 @@ /* serial stuff */ void serial_printf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2))); +int sprintf(char *buf, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3))); +int snprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format(__printf__, 3, 4))); +int vsprintf(char *buf, const char *fmt, va_list args); +char *asprintf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2))); +char *vasprintf(const char *fmt, va_list ap); +int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); +int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); + +#ifndef CONFIG_CONSOLE_NONE /* stdin */ int tstc(void); @@ -20,6 +29,51 @@ int getc(void); int console_puts(unsigned int ch, const char *s); void console_flush(void); + +int printf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2))); +int vprintf(const char *fmt, va_list args); +#else +static inline int tstc(void) +{ + return 0; +} + +static inline int console_puts(unsigned int ch, const char *str) +{ + return 0; +} + +static inline int getc(void) +{ + return -EINVAL; +} + +static inline void console_putc(unsigned int ch, char c) {} + +static inline void console_flush(void) {} + +static int printf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2))); +static inline int printf(const char *fmt, ...) +{ + return 0; +} + + +static inline int vprintf(const char *fmt, va_list args) +{ + return 0; +} + +#ifndef ARCH_HAS_CTRLC +/* test if ctrl-c was pressed */ +static inline int ctrlc (void) +{ + return 0; +} +#endif /* ARCH_HAS_CTRC */ + +#endif + static inline int puts(const char *s) { return console_puts(CONSOLE_STDOUT, s); @@ -30,16 +84,6 @@ static inline void putchar(char c) console_putc(CONSOLE_STDOUT, c); } -int printf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2))); -int vprintf(const char *fmt, va_list args); -int sprintf(char *buf, const char *fmt, ...) __attribute__ ((format(__printf__, 2, 3))); -int snprintf(char *buf, size_t size, const char *fmt, ...) __attribute__ ((format(__printf__, 3, 4))); -int vsprintf(char *buf, const char *fmt, va_list args); -char *asprintf(const char *fmt, ...) __attribute__ ((format(__printf__, 1, 2))); -char *vasprintf(const char *fmt, va_list ap); -int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); -int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); - /* stderr */ #define eputc(c) console_putc(CONSOLE_STDERR, c) #define eputs(s) console_puts(CONSOLE_STDERR, s) |