stdio_impl.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef _STDIO_IMPL_H
  2. #define _STDIO_IMPL_H
  3. #include <stdio.h>
  4. #include "syscall.h"
  5. #include "libc.h"
  6. #define UNGET 8
  7. #define FFINALLOCK(f) ((f)->lock>=0 ? __lockfile((f)) : 0)
  8. #define FLOCK(f) int __need_unlock = ((f)->lock>=0 ? __lockfile((f)) : 0)
  9. #define FUNLOCK(f) if (__need_unlock) __unlockfile((f)); else
  10. #define F_PERM 1
  11. #define F_NORD 4
  12. #define F_NOWR 8
  13. #define F_EOF 16
  14. #define F_ERR 32
  15. #define F_SVB 64
  16. #define F_APP 128
  17. struct _IO_FILE {
  18. unsigned flags;
  19. unsigned char *rpos, *rend;
  20. int (*close)(FILE *);
  21. unsigned char *wend, *wpos;
  22. unsigned char *mustbezero_1;
  23. unsigned char *wbase;
  24. size_t (*read)(FILE *, unsigned char *, size_t);
  25. size_t (*write)(FILE *, const unsigned char *, size_t);
  26. off_t (*seek)(FILE *, off_t, int);
  27. unsigned char *buf;
  28. size_t buf_size;
  29. FILE *prev, *next;
  30. int fd;
  31. int pipe_pid;
  32. long lockcount;
  33. short dummy3;
  34. signed char mode;
  35. signed char lbf;
  36. volatile int lock;
  37. volatile int waiters;
  38. void *cookie;
  39. off_t off;
  40. char *getln_buf;
  41. void *mustbezero_2;
  42. unsigned char *shend;
  43. off_t shlim, shcnt;
  44. FILE *prev_locked, *next_locked;
  45. struct __locale_struct *locale;
  46. };
  47. size_t __stdio_read(FILE *, unsigned char *, size_t);
  48. size_t __stdio_write(FILE *, const unsigned char *, size_t);
  49. size_t __stdout_write(FILE *, const unsigned char *, size_t);
  50. off_t __stdio_seek(FILE *, off_t, int);
  51. int __stdio_close(FILE *);
  52. size_t __string_read(FILE *, unsigned char *, size_t);
  53. int __toread(FILE *);
  54. int __towrite(FILE *);
  55. #if defined(__PIC__) && (100*__GNUC__+__GNUC_MINOR__ >= 303)
  56. __attribute__((visibility("protected")))
  57. #endif
  58. int __overflow(FILE *, int), __uflow(FILE *);
  59. int __fseeko(FILE *, off_t, int);
  60. int __fseeko_unlocked(FILE *, off_t, int);
  61. off_t __ftello(FILE *);
  62. off_t __ftello_unlocked(FILE *);
  63. size_t __fwritex(const unsigned char *, size_t, FILE *);
  64. int __putc_unlocked(int, FILE *);
  65. FILE *__fdopen(int, const char *);
  66. int __fmodeflags(const char *);
  67. FILE *__ofl_add(FILE *f);
  68. FILE **__ofl_lock(void);
  69. void __ofl_unlock(void);
  70. #define feof(f) ((f)->flags & F_EOF)
  71. #define ferror(f) ((f)->flags & F_ERR)
  72. #define getc_unlocked(f) \
  73. ( ((f)->rpos < (f)->rend) ? *(f)->rpos++ : __uflow((f)) )
  74. #define putc_unlocked(c, f) \
  75. ( ((unsigned char)(c)!=(f)->lbf && (f)->wpos<(f)->wend) \
  76. ? *(f)->wpos++ = (c) : __overflow((f),(c)) )
  77. /* Caller-allocated FILE * operations */
  78. FILE *__fopen_rb_ca(const char *, FILE *, unsigned char *, size_t);
  79. int __fclose_ca(FILE *);
  80. #endif