stdio.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef __STDIO_H
  2. #define __STDIO_H
  3. #include <stdarg.h>
  4. #include <linux/compiler.h>
  5. /* stdin */
  6. int getchar(void);
  7. int tstc(void);
  8. /* stdout */
  9. #if !defined(CONFIG_SPL_BUILD) || \
  10. (defined(CONFIG_TPL_BUILD) && defined(CONFIG_TPL_SERIAL)) || \
  11. (defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD) && \
  12. defined(CONFIG_SPL_SERIAL))
  13. void putc(const char c);
  14. void puts(const char *s);
  15. #ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
  16. void flush(void);
  17. #else
  18. static inline void flush(void) {}
  19. #endif
  20. int __printf(1, 2) printf(const char *fmt, ...);
  21. int vprintf(const char *fmt, va_list args);
  22. #else
  23. static inline void putc(const char c)
  24. {
  25. }
  26. static inline void puts(const char *s)
  27. {
  28. }
  29. static inline void flush(void)
  30. {
  31. }
  32. static inline int __printf(1, 2) printf(const char *fmt, ...)
  33. {
  34. return 0;
  35. }
  36. static inline int vprintf(const char *fmt, va_list args)
  37. {
  38. return 0;
  39. }
  40. #endif
  41. /*
  42. * FILE based functions (can only be used AFTER relocation!)
  43. */
  44. #define stdin 0
  45. #define stdout 1
  46. #define stderr 2
  47. #define MAX_FILES 3
  48. /* stderr */
  49. #define eputc(c) fputc(stderr, c)
  50. #define eputs(s) fputs(stderr, s)
  51. #define eflush() fflush(stderr)
  52. #define eprintf(fmt, args...) fprintf(stderr, fmt, ##args)
  53. int __printf(2, 3) fprintf(int file, const char *fmt, ...);
  54. void fputs(int file, const char *s);
  55. void fputc(int file, const char c);
  56. #ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
  57. void fflush(int file);
  58. #else
  59. static inline void fflush(int file) {}
  60. #endif
  61. int ftstc(int file);
  62. int fgetc(int file);
  63. #endif /* __STDIO_H */