Masahiro Yamada | 7fea7b1 | 2017-09-16 14:10:39 +0900 | [diff] [blame] | 1 | #ifndef __STDIO_H |
| 2 | #define __STDIO_H |
| 3 | |
| 4 | #include <stdarg.h> |
| 5 | #include <linux/compiler.h> |
| 6 | |
| 7 | /* stdin */ |
Heinrich Schuchardt | c670aee | 2020-10-07 18:11:48 +0200 | [diff] [blame] | 8 | int getchar(void); |
Masahiro Yamada | 7fea7b1 | 2017-09-16 14:10:39 +0900 | [diff] [blame] | 9 | int tstc(void); |
| 10 | |
| 11 | /* stdout */ |
| 12 | #if !defined(CONFIG_SPL_BUILD) || \ |
Simon Glass | 2a73606 | 2021-08-08 12:20:12 -0600 | [diff] [blame] | 13 | (defined(CONFIG_TPL_BUILD) && defined(CONFIG_TPL_SERIAL)) || \ |
Masahiro Yamada | 7fea7b1 | 2017-09-16 14:10:39 +0900 | [diff] [blame] | 14 | (defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD) && \ |
Simon Glass | 2a73606 | 2021-08-08 12:20:12 -0600 | [diff] [blame] | 15 | defined(CONFIG_SPL_SERIAL)) |
Masahiro Yamada | 7fea7b1 | 2017-09-16 14:10:39 +0900 | [diff] [blame] | 16 | void putc(const char c); |
| 17 | void puts(const char *s); |
Pali Rohár | 974f483 | 2022-09-05 11:31:17 +0200 | [diff] [blame] | 18 | #ifdef CONFIG_CONSOLE_FLUSH_SUPPORT |
| 19 | void flush(void); |
| 20 | #else |
| 21 | static inline void flush(void) {} |
| 22 | #endif |
Masahiro Yamada | 7fea7b1 | 2017-09-16 14:10:39 +0900 | [diff] [blame] | 23 | int __printf(1, 2) printf(const char *fmt, ...); |
| 24 | int vprintf(const char *fmt, va_list args); |
| 25 | #else |
| 26 | static inline void putc(const char c) |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | static inline void puts(const char *s) |
| 31 | { |
| 32 | } |
| 33 | |
Pali Rohár | 974f483 | 2022-09-05 11:31:17 +0200 | [diff] [blame] | 34 | static inline void flush(void) |
| 35 | { |
| 36 | } |
| 37 | |
Masahiro Yamada | 7fea7b1 | 2017-09-16 14:10:39 +0900 | [diff] [blame] | 38 | static inline int __printf(1, 2) printf(const char *fmt, ...) |
| 39 | { |
| 40 | return 0; |
| 41 | } |
| 42 | |
| 43 | static inline int vprintf(const char *fmt, va_list args) |
| 44 | { |
| 45 | return 0; |
| 46 | } |
| 47 | #endif |
| 48 | |
| 49 | /* |
| 50 | * FILE based functions (can only be used AFTER relocation!) |
| 51 | */ |
| 52 | #define stdin 0 |
| 53 | #define stdout 1 |
| 54 | #define stderr 2 |
| 55 | #define MAX_FILES 3 |
| 56 | |
| 57 | /* stderr */ |
| 58 | #define eputc(c) fputc(stderr, c) |
| 59 | #define eputs(s) fputs(stderr, s) |
Pali Rohár | 974f483 | 2022-09-05 11:31:17 +0200 | [diff] [blame] | 60 | #define eflush() fflush(stderr) |
Masahiro Yamada | 7fea7b1 | 2017-09-16 14:10:39 +0900 | [diff] [blame] | 61 | #define eprintf(fmt, args...) fprintf(stderr, fmt, ##args) |
| 62 | |
| 63 | int __printf(2, 3) fprintf(int file, const char *fmt, ...); |
| 64 | void fputs(int file, const char *s); |
| 65 | void fputc(int file, const char c); |
Pali Rohár | 974f483 | 2022-09-05 11:31:17 +0200 | [diff] [blame] | 66 | #ifdef CONFIG_CONSOLE_FLUSH_SUPPORT |
| 67 | void fflush(int file); |
| 68 | #else |
| 69 | static inline void fflush(int file) {} |
| 70 | #endif |
Masahiro Yamada | 7fea7b1 | 2017-09-16 14:10:39 +0900 | [diff] [blame] | 71 | int ftstc(int file); |
| 72 | int fgetc(int file); |
| 73 | |
| 74 | #endif /* __STDIO_H */ |