"Das U-Boot" Source Tree
at master 88 lines 2.0 kB view raw
1#ifndef __STDIO_H 2#define __STDIO_H 3 4#include <stdarg.h> 5#include <linux/compiler.h> 6 7/* stdin */ 8int getchar(void); 9int tstc(void); 10 11/* stdout */ 12#if !defined(CONFIG_XPL_BUILD) || CONFIG_IS_ENABLED(SERIAL) 13void putc(const char c); 14void puts(const char *s); 15#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT 16void flush(void); 17#else 18static inline void flush(void) {} 19#endif 20int __printf(1, 2) printf(const char *fmt, ...); 21int vprintf(const char *fmt, va_list args); 22#else 23static inline void putc(const char c) 24{ 25} 26 27static inline void puts(const char *s) 28{ 29} 30 31static inline void flush(void) 32{ 33} 34 35static inline int __printf(1, 2) printf(const char *fmt, ...) 36{ 37 return 0; 38} 39 40static inline int vprintf(const char *fmt, va_list args) 41{ 42 return 0; 43} 44#endif 45 46/** 47 * Format a string and place it in a buffer 48 * 49 * @buf: The buffer to place the result into 50 * @size: The size of the buffer, including the trailing null space 51 * @fmt: The format string to use 52 * @...: Arguments for the format string 53 * Return: the number of characters which would be 54 * generated for the given input, excluding the trailing null, 55 * as per ISO C99. If the return is greater than or equal to 56 * @size, the resulting string is truncated. 57 * 58 * See the vsprintf() documentation for format string extensions over C99. 59 */ 60int snprintf(char *buf, size_t size, const char *fmt, ...) 61 __attribute__ ((format (__printf__, 3, 4))); 62 63/* 64 * FILE based functions (can only be used AFTER relocation!) 65 */ 66#define stdin 0 67#define stdout 1 68#define stderr 2 69#define MAX_FILES 3 70 71/* stderr */ 72#define eputc(c) fputc(stderr, c) 73#define eputs(s) fputs(stderr, s) 74#define eflush() fflush(stderr) 75#define eprintf(fmt, args...) fprintf(stderr, fmt, ##args) 76 77int __printf(2, 3) fprintf(int file, const char *fmt, ...); 78void fputs(int file, const char *s); 79void fputc(int file, const char c); 80#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT 81void fflush(int file); 82#else 83static inline void fflush(int file) {} 84#endif 85int ftstc(int file); 86int fgetc(int file); 87 88#endif /* __STDIO_H */