]>
Commit | Line | Data |
---|---|---|
7fea7b1a MY |
1 | #ifndef __STDIO_H |
2 | #define __STDIO_H | |
3 | ||
4 | #include <stdarg.h> | |
5 | #include <linux/compiler.h> | |
6 | ||
7 | /* stdin */ | |
c670aeee | 8 | int getchar(void); |
7fea7b1a MY |
9 | int tstc(void); |
10 | ||
11 | /* stdout */ | |
12 | #if !defined(CONFIG_SPL_BUILD) || \ | |
2a736066 | 13 | (defined(CONFIG_TPL_BUILD) && defined(CONFIG_TPL_SERIAL)) || \ |
7fea7b1a | 14 | (defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD) && \ |
2a736066 | 15 | defined(CONFIG_SPL_SERIAL)) |
7fea7b1a MY |
16 | void putc(const char c); |
17 | void puts(const char *s); | |
974f4836 T |
18 | #ifdef CONFIG_CONSOLE_FLUSH_SUPPORT |
19 | void flush(void); | |
20 | #else | |
21 | static inline void flush(void) {} | |
22 | #endif | |
7fea7b1a MY |
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 | ||
974f4836 T |
34 | static inline void flush(void) |
35 | { | |
36 | } | |
37 | ||
7fea7b1a MY |
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 | ||
cb73fe9e RM |
49 | /** |
50 | * Format a string and place it in a buffer | |
51 | * | |
52 | * @buf: The buffer to place the result into | |
53 | * @size: The size of the buffer, including the trailing null space | |
54 | * @fmt: The format string to use | |
55 | * @...: Arguments for the format string | |
56 | * Return: the number of characters which would be | |
57 | * generated for the given input, excluding the trailing null, | |
58 | * as per ISO C99. If the return is greater than or equal to | |
59 | * @size, the resulting string is truncated. | |
60 | * | |
61 | * See the vsprintf() documentation for format string extensions over C99. | |
62 | */ | |
63 | int snprintf(char *buf, size_t size, const char *fmt, ...) | |
64 | __attribute__ ((format (__printf__, 3, 4))); | |
65 | ||
7fea7b1a MY |
66 | /* |
67 | * FILE based functions (can only be used AFTER relocation!) | |
68 | */ | |
69 | #define stdin 0 | |
70 | #define stdout 1 | |
71 | #define stderr 2 | |
72 | #define MAX_FILES 3 | |
73 | ||
74 | /* stderr */ | |
75 | #define eputc(c) fputc(stderr, c) | |
76 | #define eputs(s) fputs(stderr, s) | |
974f4836 | 77 | #define eflush() fflush(stderr) |
7fea7b1a MY |
78 | #define eprintf(fmt, args...) fprintf(stderr, fmt, ##args) |
79 | ||
80 | int __printf(2, 3) fprintf(int file, const char *fmt, ...); | |
81 | void fputs(int file, const char *s); | |
82 | void fputc(int file, const char c); | |
974f4836 T |
83 | #ifdef CONFIG_CONSOLE_FLUSH_SUPPORT |
84 | void fflush(int file); | |
85 | #else | |
86 | static inline void fflush(int file) {} | |
87 | #endif | |
7fea7b1a MY |
88 | int ftstc(int file); |
89 | int fgetc(int file); | |
90 | ||
91 | #endif /* __STDIO_H */ |