diff options
author | Masahiro Yamada | 2017-09-16 14:10:39 +0900 |
---|---|---|
committer | Tom Rini | 2017-10-04 07:55:21 -0400 |
commit | 7fea7b1a37ad2b1c1e92bd87f7c6a1877d70e579 (patch) | |
tree | 0afa89044ca7886ed52a129f108d249b74c08aae /include/stdio.h | |
parent | 39dd65a059e503883dbf16d4c00ac083d15837da (diff) |
stdio.h: move printf() stuff from <common.h> to <stdio.h>
<common.h> 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 <stdio.h>.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'include/stdio.h')
-rw-r--r-- | include/stdio.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/include/stdio.h b/include/stdio.h new file mode 100644 index 00000000000..aedf3744525 --- /dev/null +++ b/include/stdio.h @@ -0,0 +1,59 @@ +#ifndef __STDIO_H +#define __STDIO_H + +#include <stdarg.h> +#include <linux/compiler.h> + +/* 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 */ |