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 size_t __string_read(FILE *, unsigned char *, size_t); 60 61 hidden int __toread(FILE *); 62 hidden int __towrite(FILE *); 63 64 hidden void __stdio_exit(void); 65 hidden void __stdio_exit_needed(void); 66 67 #if defined(__PIC__) && (100*__GNUC__+__GNUC_MINOR__ >= 303) 68 __attribute__((visibility("protected"))) 69 #endif 70 int __overflow(FILE *, int), __uflow(FILE *); 71 72 hidden int __fseeko(FILE *, off_t, int); 73 hidden int __fseeko_unlocked(FILE *, off_t, int); 74 hidden off_t __ftello(FILE *); 75 hidden off_t __ftello_unlocked(FILE *); 76 hidden size_t __fwritex(const unsigned char *, size_t, FILE *); 77 hidden int __putc_unlocked(int, FILE *); 78 79 hidden FILE *__fdopen(int, const char *); 80 hidden int __fmodeflags(const char *); 81 82 hidden FILE *__ofl_add(FILE *f); 83 hidden FILE **__ofl_lock(void); 84 hidden void __ofl_unlock(void); 85 86 struct __pthread; 87 hidden void __register_locked_file(FILE *, struct __pthread *); 88 hidden void __unlist_locked_file(FILE *); 89 hidden void __do_orphaned_stdio_locks(void); 90 91 #define MAYBE_WAITERS 0x40000000 92 93 hidden void __getopt_msg(const char *, const char *, const char *, size_t); 94 95 #define feof(f) ((f)->flags & F_EOF) 96 #define ferror(f) ((f)->flags & F_ERR) 97 98 #define getc_unlocked(f) \ 99 ( ((f)->rpos != (f)->rend) ? *(f)->rpos++ : __uflow((f)) ) 100 101 #define putc_unlocked(c, f) \ 102 ( (((unsigned char)(c)!=(f)->lbf && (f)->wpos!=(f)->wend)) \ 103 ? *(f)->wpos++ = (unsigned char)(c) \ 104 : __overflow((f),(unsigned char)(c)) ) 105 106 /* Caller-allocated FILE * operations */ 107 hidden FILE *__fopen_rb_ca(const char *, FILE *, unsigned char *, size_t); 108 hidden int __fclose_ca(FILE *); 109 110 #endif 111