1 /* Copyright (c) 2011 Yaakov Selkowitz <yselkowi@redhat.com> */ 2 /* 3 * stdio_ext.h 4 * 5 * Definitions for I/O internal operations, originally from Solaris. 6 */ 7 8 #ifndef _STDIO_EXT_H_ 9 #define _STDIO_EXT_H_ 10 11 #ifdef __rtems__ 12 #error "<stdio_ext.h> not supported" 13 #endif 14 15 #include <stdio.h> 16 17 #define FSETLOCKING_QUERY 0 18 #define FSETLOCKING_INTERNAL 1 19 #define FSETLOCKING_BYCALLER 2 20 21 _BEGIN_STD_C 22 23 void __fpurge (FILE *); 24 int __fsetlocking (FILE *, int); 25 26 /* TODO: 27 28 void _flushlbf (void); 29 */ 30 31 #ifdef __GNUC__ 32 33 _ELIDABLE_INLINE size_t __fbufsize(FILE * __fp)34__fbufsize (FILE *__fp) { return (size_t) __fp->_bf._size; } 35 36 _ELIDABLE_INLINE int __freading(FILE * __fp)37__freading (FILE *__fp) { return (__fp->_flags & __SRD) != 0; } 38 39 _ELIDABLE_INLINE int __fwriting(FILE * __fp)40__fwriting (FILE *__fp) { return (__fp->_flags & __SWR) != 0; } 41 42 _ELIDABLE_INLINE int __freadable(FILE * __fp)43__freadable (FILE *__fp) { return (__fp->_flags & (__SRD | __SRW)) != 0; } 44 45 _ELIDABLE_INLINE int __fwritable(FILE * __fp)46__fwritable (FILE *__fp) { return (__fp->_flags & (__SWR | __SRW)) != 0; } 47 48 _ELIDABLE_INLINE int __flbf(FILE * __fp)49__flbf (FILE *__fp) { return (__fp->_flags & __SLBF) != 0; } 50 51 _ELIDABLE_INLINE size_t __fpending(FILE * __fp)52__fpending (FILE *__fp) { return __fp->_p - __fp->_bf._base; } 53 54 #else 55 56 size_t __fbufsize (FILE *); 57 int __freading (FILE *); 58 int __fwriting (FILE *); 59 int __freadable (FILE *); 60 int __fwritable (FILE *); 61 int __flbf (FILE *); 62 size_t __fpending (FILE *); 63 64 #ifndef __cplusplus 65 66 #define __fbufsize(__fp) ((size_t) (__fp)->_bf._size) 67 #define __freading(__fp) (((__fp)->_flags & __SRD) != 0) 68 #define __fwriting(__fp) (((__fp)->_flags & __SWR) != 0) 69 #define __freadable(__fp) (((__fp)->_flags & (__SRD | __SRW)) != 0) 70 #define __fwritable(__fp) (((__fp)->_flags & (__SWR | __SRW)) != 0) 71 #define __flbf(__fp) (((__fp)->_flags & __SLBF) != 0) 72 #define __fpending(__fp) ((size_t) ((__fp)->_p - (__fp)->_bf._base)) 73 74 #endif /* __cplusplus */ 75 76 #endif /* __GNUC__ */ 77 78 _END_STD_C 79 80 #endif /* _STDIO_EXT_H_ */ 81