This source file includes following definitions.
- freadahead
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #include <config.h>
18
19
20 #include "freadahead.h"
21
22 #include <stdlib.h>
23 #include "stdio-impl.h"
24
25 #if defined __DragonFly__
26
27 extern size_t __sreadahead (FILE *);
28 #endif
29
30
31
32
33 size_t
34 freadahead (FILE *fp)
35 {
36 #if defined _IO_EOF_SEEN || defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1
37
38 if (fp->_IO_write_ptr > fp->_IO_write_base)
39 return 0;
40 return (fp->_IO_read_end - fp->_IO_read_ptr)
41 + (fp->_flags & _IO_IN_BACKUP ? fp->_IO_save_end - fp->_IO_save_base :
42 0);
43 #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
44
45 if ((fp_->_flags & __SWR) != 0 || fp_->_r < 0)
46 return 0;
47 # if defined __DragonFly__
48 return __sreadahead (fp);
49 # else
50 return fp_->_r
51 + (HASUB (fp) ? fp_->_ur : 0);
52 # endif
53 #elif defined __EMX__
54 if ((fp->_flags & _IOWRT) != 0)
55 return 0;
56
57
58
59
60 return (fp->_rcount > 0 ? fp->_rcount : fp->_ungetc_count - fp->_rcount);
61 #elif defined __minix
62 if ((fp_->_flags & _IOWRITING) != 0)
63 return 0;
64 return fp_->_count;
65 #elif defined _IOERR
66 if ((fp_->_flag & _IOWRT) != 0)
67 return 0;
68 return fp_->_cnt;
69 #elif defined __UCLIBC__
70 # ifdef __STDIO_BUFFERS
71 if (fp->__modeflags & __FLAG_WRITING)
72 return 0;
73 return (fp->__bufread - fp->__bufpos)
74 + (fp->__modeflags & __FLAG_UNGOT ? 1 : 0);
75 # else
76 return 0;
77 # endif
78 #elif defined __QNX__
79 if ((fp->_Mode & 0x2000 ) != 0)
80 return 0;
81
82
83 return ((fp->_Rsave ? fp->_Rsave : fp->_Rend) - fp->_Next)
84 + (fp->_Mode & 0x4000
85 ? (fp->_Back + sizeof (fp->_Back)) - fp->_Rback
86 : 0);
87 #elif defined __MINT__
88 if (!fp->__mode.__read)
89 return 0;
90 return (fp->__pushed_back
91 ? fp->__get_limit - fp->__pushback_bufp + 1
92 : fp->__get_limit - fp->__bufp);
93 #elif defined EPLAN9
94 if (fp->state == 4 || fp->rp >= fp->wp)
95 return 0;
96 return fp->wp - fp->rp;
97 #elif defined SLOW_BUT_NO_HACKS
98 abort ();
99 return 0;
100 #else
101 #error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then report this to bug-gnulib."
102 #endif
103 }