1 /* Retrieve information about a FILE stream.
2 Copyright (C) 2007 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 # include <stdio_ext.h>
29 /* Most systems provide FILE as a struct and the necessary bitmask in
30 <stdio.h>, because they need it for implementing getc() and putc() as
32 #if defined _IO_ferror_unlocked /* GNU libc, BeOS */
33 # if HAVE___FLBF /* glibc >= 2.2 */
37 if (fp->_flags & _IO_LINE_BUF)
40 if (fp->_flags & _IO_UNBUFFERED)
43 #elif defined __sferror /* FreeBSD, NetBSD, OpenBSD, MacOS X, Cygwin */
44 if (fp->_flags & __SLBF)
46 if (fp->_flags & __SNBF)
49 #elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, mingw */
50 # if HAVE___FLBF /* Solaris >= 7 */
54 if (fp->_flag & _IOLBF)
57 # if defined __sun && defined _LP64 /* Solaris/{SPARC,AMD64} 64-bit */
58 # define fp_ ((struct { unsigned char *_ptr; \
59 unsigned char *_base; \
60 unsigned char *_end; \
65 return fp_->_flag & (_IONBF | _IOFBF);
67 if (fp->_flag & _IONBF)
71 #elif defined __UCLIBC__ /* uClibc */
72 if (fp->__modeflags & __FLAG_LBF)
74 if (fp->__modeflags & __FLAG_NBF)
77 #elif defined __QNX__ /* QNX */
78 if (fp->_Mode & 0x400 /* _MLBF */)
80 if (fp->_Mode & 0x800 /* _MNBF */)
84 #error "Please port gnulib fbufmode.c to your platform! Look at the setvbuf implementation."