1 #ifndef _STDIO_IMPL_H 2 #define _STDIO_IMPL_H 3 4 #define __NEED_struct__IO_FILE 5 6 #include <stdio.h> 7 #include <bits/alltypes.h> 8 #include "../include/features.h" 9 10 #define UNGET 8 11 12 #define FLOCK(f) __lockfile(f) 13 #define FUNLOCK(f) __unlockfile(f) 14 15 #define F_PERM 1 16 #define F_NORD 4 17 #define F_NOWR 8 18 #define F_EOF 16 19 #define F_ERR 32 20 #define F_SVB 64 21 #define F_APP 128 22 23 #define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP PTHREAD_MUTEX_INITIALIZER 24 extern hidden FILE *volatile __stdin_used; 25 extern hidden FILE *volatile __stdout_used; 26 extern hidden FILE *volatile __stderr_used; 27 28 hidden int __lockfile(FILE *); 29 hidden int __unlockfile(FILE *); 30 31 hidden size_t __stdio_read(FILE *, unsigned char *, size_t); 32 hidden size_t __stdio_write(FILE *, const unsigned char *, size_t); 33 hidden size_t __stdout_write(FILE *, const unsigned char *, size_t); 34 hidden off_t __stdio_seek(FILE *, off_t, int); 35 hidden int __stdio_close(FILE *); 36 37 hidden size_t __string_read(FILE *, unsigned char *, size_t); 38 39 hidden int __toread(FILE *); 40 hidden int __towrite(FILE *); 41 42 hidden void __stdio_exit(void); 43 hidden void __stdio_exit_needed(void); 44 45 #if defined(__PIC__) && (100*__GNUC__+__GNUC_MINOR__ >= 303) 46 __attribute__((visibility("protected"))) 47 #endif 48 int __overflow(FILE *, int), __uflow(FILE *); 49 50 hidden int __fseeko(FILE *, off_t, int); 51 hidden int __fseeko_unlocked(FILE *, off_t, int); 52 hidden off_t __ftello(FILE *); 53 hidden off_t __ftello_unlocked(FILE *); 54 hidden size_t __fwritex(const unsigned char *, size_t, FILE *); 55 hidden int __putc_unlocked(int, FILE *); 56 57 hidden FILE *__fdopen(int, const char *); 58 hidden int __fmodeflags(const char *); 59 60 hidden FILE *__ofl_add(FILE *f); 61 hidden FILE **__ofl_lock(void); 62 hidden void __ofl_unlock(void); 63 64 struct __pthread; 65 hidden void __register_locked_file(FILE *, struct __pthread *); 66 hidden void __unlist_locked_file(FILE *); 67 hidden void __do_orphaned_stdio_locks(void); 68 69 #define MAYBE_WAITERS 0x40000000 70 71 hidden void __getopt_msg(const char *, const char *, const char *, size_t); 72 73 #define feof(f) ((f)->flags & F_EOF) 74 #define ferror(f) ((f)->flags & F_ERR) 75 76 #define getc_unlocked(f) \ 77 ( ((f)->rpos != (f)->rend) ? *(f)->rpos++ : __uflow((f)) ) 78 79 #define putc_unlocked(c, f) \ 80 ( (((unsigned char)(c)!=(f)->lbf && (f)->wpos!=(f)->wend)) \ 81 ? *(f)->wpos++ = (unsigned char)(c) \ 82 : __overflow((f),(unsigned char)(c)) ) 83 84 /* Caller-allocated FILE * operations */ 85 hidden FILE *__fopen_rb_ca(const char *, FILE *, unsigned char *, size_t); 86 hidden int __fclose_ca(FILE *); 87 88 #endif 89