Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / stdio / stdio_ext.c
blob857091fd7defcaddfc0eb916332623e8c4511993
1 /*
2 FUNCTION
3 <<stdio_ext>>,<<__fbufsize>>,<<__fpending>>,<<__flbf>>,<<__freadable>>,<<__fwritable>>,<<__freading>>,<<__fwriting>>---access internals of FILE structure
5 INDEX
6 __fbufsize
7 INDEX
8 __fpending
9 INDEX
10 __flbf
11 INDEX
12 __freadable
13 INDEX
14 __fwritable
15 INDEX
16 __freading
17 INDEX
18 __fwriting
20 SYNOPSIS
21 #include <stdio.h>
22 #include <stdio_ext.h>
23 size_t __fbufsize(FILE *<[fp]>);
24 size_t __fpending(FILE *<[fp]>);
25 int __flbf(FILE *<[fp]>);
26 int __freadable(FILE *<[fp]>);
27 int __fwritable(FILE *<[fp]>);
28 int __freading(FILE *<[fp]>);
29 int __fwriting(FILE *<[fp]>);
31 DESCRIPTION
32 These functions provides access to the internals of the FILE structure <[fp]>.
34 RETURNS
35 <<__fbufsize>> returns the number of bytes in the buffer of stream <[fp]>.
37 <<__fpending>> returns the number of bytes in the output buffer of stream <[fp]>.
39 <<__flbf>> returns nonzero if stream <[fp]> is line-buffered, and <<0>> if not.
41 <<__freadable>> returns nonzero if stream <[fp]> may be read, and <<0>> if not.
43 <<__fwritable>> returns nonzero if stream <[fp]> may be written, and <<0>> if not.
45 <<__freading>> returns nonzero if stream <[fp]> if the last operation on
46 it was a read, or if it read-only, and <<0>> if not.
48 <<__fwriting>> returns nonzero if stream <[fp]> if the last operation on
49 it was a write, or if it write-only, and <<0>> if not.
51 PORTABILITY
52 These functions originate from Solaris and are also provided by GNU libc.
54 No supporting OS subroutines are required.
57 #ifndef __rtems__
59 #include <_ansi.h>
60 #include <stdio.h>
62 /* Subroutine versions of the inline or macro functions. */
64 size_t
65 __fbufsize (FILE * fp)
67 return (size_t) fp->_bf._size;
70 size_t
71 __fpending (FILE * fp)
73 return fp->_p - fp->_bf._base;
76 int
77 __flbf (FILE * fp)
79 return (fp->_flags & __SLBF) != 0;
82 int
83 __freadable (FILE * fp)
85 return (fp->_flags & (__SRD | __SRW)) != 0;
88 int
89 __fwritable (FILE * fp)
91 return (fp->_flags & (__SWR | __SRW)) != 0;
94 int
95 __freading (FILE * fp)
97 return (fp->_flags & __SRD) != 0;
101 __fwriting (FILE * fp)
103 return (fp->_flags & __SWR) != 0;
106 #endif /* __rtems__ */