1 #ifndef _STDIO_IMPL_H 2 #define _STDIO_IMPL_H 3 4 #include <stdio.h> 5 6 #define UNGET 8 7 8 #define FLOCK(f) __lockfile(f) 9 #define FUNLOCK(f) __unlockfile(f) 10 11 #define F_PERM 1 12 #define F_NORD 4 13 #define F_NOWR 8 14 #define F_EOF 16 15 #define F_ERR 32 16 #define F_SVB 64 17 #define F_APP 128 18 19 struct _IO_FILE { 20 unsigned flags; 21 unsigned char *rpos, *rend; 22 int (*close)(FILE *); 23 unsigned char *wend, *wpos; 24 unsigned char *mustbezero_1; 25 unsigned char *wbase; 26 size_t (*read)(FILE *, unsigned char *, size_t); 27 size_t (*write)(FILE *, const unsigned char *, size_t); 28 off_t (*seek)(FILE *, off_t, int); 29 unsigned char *buf; 30 size_t buf_size; 31 FILE *prev, *next; 32 int fd; 33 int pipe_pid; 34 int mode; 35 void *lock; 36 int lbf; 37 void *cookie; 38 off_t off; 39 char *getln_buf; 40 void *mustbezero_2; 41 unsigned char *shend; 42 off_t shlim, shcnt; 43 struct __locale_struct *locale; 44 }; 45 46 extern hidden FILE *volatile __stdin_used; 47 extern hidden FILE *volatile __stdout_used; 48 extern hidden FILE *volatile __stderr_used; 49 50 hidden int __lockfile(FILE *); 51 hidden int __unlockfile(FILE *); 52 53 hidden size_t __stdio_read(FILE *, unsigned char *, size_t); 54 hidden size_t __stdio_write(FILE *, const unsigned char *, size_t); 55 hidden size_t __stdout_write(FILE *, const unsigned char *, size_t); 56 hidden off_t __stdio_seek(FILE *, off_t, int); 57 hidden int __stdio_close(FILE *); 58 59 hidden int __toread(FILE *); 60 hidden int __towrite(FILE *); 61 62 hidden void __stdio_exit(void); 63 hidden void __stdio_exit_needed(void); 64 65 #if defined(__PIC__) && (100*__GNUC__+__GNUC_MINOR__ >= 303) 66 __attribute__((visibility("protected"))) 67 #endif 68 int __overflow(FILE *, int), __uflow(FILE *); 69 70 hidden int __fseeko(FILE *, off_t, int); 71 hidden int __fseeko_unlocked(FILE *, off_t, int); 72 hidden off_t __ftello(FILE *); 73 hidden off_t __ftello_unlocked(FILE *); 74 hidden size_t __fwritex(const unsigned char *, size_t, FILE *); 75 hidden int __putc_unlocked(int, FILE *); 76 77 hidden FILE *__fdopen(int, const char *); 78 hidden int __fmodeflags(const char *); 79 80 hidden FILE *__ofl_add(FILE *f); 81 hidden FILE **__ofl_lock(void); 82 hidden void __ofl_unlock(void); 83 84 struct __pthread; 85 hidden void __register_locked_file(FILE *, struct __pthread *); 86 hidden void __unlist_locked_file(FILE *); 87 hidden void __do_orphaned_stdio_locks(void); 88 89 #define MAYBE_WAITERS 0x40000000 90 91 hidden void __getopt_msg(const char *, const char *, const char *, size_t); 92 93 #define feof(f) ((f)->flags & F_EOF) 94 #define ferror(f) ((f)->flags & F_ERR) 95 96 #define getc_unlocked(f) \ 97 ( ((f)->rpos != (f)->rend) ? *(f)->rpos++ : __uflow((f)) ) 98 99 #define putc_unlocked(c, f) \ 100 ( (((unsigned char)(c)!=(f)->lbf && (f)->wpos!=(f)->wend)) \ 101 ? *(f)->wpos++ = (unsigned char)(c) \ 102 : __overflow((f),(unsigned char)(c)) ) 103 104 /* Caller-allocated FILE * operations */ 105 hidden FILE *__fopen_rb_ca(const char *, FILE *, unsigned char *, size_t); 106 hidden int __fclose_ca(FILE *); 107 108 #endif 109