From 7fea7b1a37ad2b1c1e92bd87f7c6a1877d70e579 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sat, 16 Sep 2017 14:10:39 +0900 Subject: stdio.h: move printf() stuff from to pulls in a lot of headers. Including it from every .c file is a bad idea. We need to remove contents until it contains nothing. Move printf() and friends to . Signed-off-by: Masahiro Yamada --- include/stdio.h | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 include/stdio.h (limited to 'include/stdio.h') diff --git a/include/stdio.h b/include/stdio.h new file mode 100644 index 0000000..aedf374 --- /dev/null +++ b/include/stdio.h @@ -0,0 +1,59 @@ +#ifndef __STDIO_H +#define __STDIO_H + +#include +#include + +/* stdin */ +int getc(void); +int tstc(void); + +/* stdout */ +#if !defined(CONFIG_SPL_BUILD) || \ + (defined(CONFIG_TPL_BUILD) && defined(CONFIG_TPL_SERIAL_SUPPORT)) || \ + (defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD) && \ + defined(CONFIG_SPL_SERIAL_SUPPORT)) +void putc(const char c); +void puts(const char *s); +int __printf(1, 2) printf(const char *fmt, ...); +int vprintf(const char *fmt, va_list args); +#else +static inline void putc(const char c) +{ +} + +static inline void puts(const char *s) +{ +} + +static inline int __printf(1, 2) printf(const char *fmt, ...) +{ + return 0; +} + +static inline int vprintf(const char *fmt, va_list args) +{ + return 0; +} +#endif + +/* + * FILE based functions (can only be used AFTER relocation!) + */ +#define stdin 0 +#define stdout 1 +#define stderr 2 +#define MAX_FILES 3 + +/* stderr */ +#define eputc(c) fputc(stderr, c) +#define eputs(s) fputs(stderr, s) +#define eprintf(fmt, args...) fprintf(stderr, fmt, ##args) + +int __printf(2, 3) fprintf(int file, const char *fmt, ...); +void fputs(int file, const char *s); +void fputc(int file, const char c); +int ftstc(int file); +int fgetc(int file); + +#endif /* __STDIO_H */ -- cgit v1.1