* libc/include/stdio_ext.h: Rename __fwriteable to __fwritable.

[!__GNUC__]: Declare real functions for the macros, and make
the macros conditional on !__cplusplus.
* libc/stdio/Makefile.am (ELIX_4_SOURCES): Add stdio_ext.c.
(CHEWOUT_FILES): Add stdio_ext.def.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio/stdio.tex: Include stdio_ext.def.
* libc/stdio/stdio_ext.c: New file.
This commit is contained in:
Yaakov Selkowitz 2014-12-11 16:53:32 +00:00
parent 070d1cee7d
commit 6f34876e5e
6 changed files with 153 additions and 2 deletions

View File

@ -1,3 +1,14 @@
2014-12-11 Yaakov Selkowitz <yselkowi@redhat.com>
* libc/include/stdio_ext.h: Rename __fwriteable to __fwritable.
[!__GNUC__]: Declare real functions for the macros, and make
the macros conditional on !__cplusplus.
* libc/stdio/Makefile.am (ELIX_4_SOURCES): Add stdio_ext.c.
(CHEWOUT_FILES): Add stdio_ext.def.
* libc/stdio/Makefile.in: Regenerate.
* libc/stdio/stdio.tex: Include stdio_ext.def.
* libc/stdio/stdio_ext.c: New file.
2014-12-04 Corinna Vinschen <vinschen@redhat.com>
* libc/include/stdio_ext.h: Remove excess "inline".

View File

@ -38,7 +38,7 @@ _ELIDABLE_INLINE int
__freadable (FILE *__fp) { return (__fp->_flags & (__SRD | __SRW)) != 0; }
_ELIDABLE_INLINE int
__fwriteable (FILE *__fp) { return (__fp->_flags & (__SWR | __SRW)) != 0; }
__fwritable (FILE *__fp) { return (__fp->_flags & (__SWR | __SRW)) != 0; }
_ELIDABLE_INLINE int
__flbf (FILE *__fp) { return (__fp->_flags & __SLBF) != 0; }
@ -48,14 +48,26 @@ __fpending (FILE *__fp) { return __fp->_p - __fp->_bf._base; }
#else
size_t _EXFUN(__fbufsize,(FILE *));
int _EXFUN(__freading,(FILE *));
int _EXFUN(__fwriting,(FILE *));
int _EXFUN(__freadable,(FILE *));
int _EXFUN(__fwritable,(FILE *));
int _EXFUN(__flbf,(FILE *));
size_t _EXFUN(__fpending,(FILE *));
#ifndef __cplusplus
#define __fbufsize(__fp) ((size_t) (__fp)->_bf._size)
#define __freading(__fp) (((__fp)->_flags & __SRD) != 0)
#define __fwriting(__fp) (((__fp)->_flags & __SWR) != 0)
#define __freadable(__fp) (((__fp)->_flags & (__SRD | __SRW)) != 0)
#define __fwriteable(__fp) (((__fp)->_flags & (__SWR | __SRW)) != 0)
#define __fwritable(__fp) (((__fp)->_flags & (__SWR | __SRW)) != 0)
#define __flbf(__fp) (((__fp)->_flags & __SLBF) != 0)
#define __fpending(__fp) ((size_t) ((__fp)->_p - (__fp)->_bf._base))
#endif /* __cplusplus */
#endif /* __GNUC__ */
_END_STD_C

View File

@ -155,6 +155,7 @@ ELIX_4_SOURCES = \
open_memstream.c \
putwc.c \
putwchar.c \
stdio_ext.c \
swprintf.c \
swscanf.c \
ungetwc.c \
@ -391,6 +392,7 @@ CHEWOUT_FILES = \
setvbuf.def \
sprintf.def \
sscanf.def \
stdio_ext.def \
swprintf.def \
swscanf.def \
tmpfile.def \

View File

@ -152,6 +152,7 @@ am__objects_2 = $(am__objects_1) lib_a-clearerr.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-open_memstream.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-putwc.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-putwchar.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-stdio_ext.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-swprintf.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-swscanf.$(OBJEXT) \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ lib_a-ungetwc.$(OBJEXT) \
@ -214,6 +215,7 @@ am__objects_8 = $(am__objects_7) clearerr.lo fclose.lo fdopen.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ open_memstream.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ putwc.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ putwchar.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ stdio_ext.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ swprintf.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ swscanf.lo \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ ungetwc.lo \
@ -521,6 +523,7 @@ GENERAL_SOURCES = \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ open_memstream.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ putwc.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ putwchar.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ stdio_ext.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ swprintf.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ swscanf.c \
@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ ungetwc.c \
@ -663,6 +666,7 @@ CHEWOUT_FILES = \
setvbuf.def \
sprintf.def \
sscanf.def \
stdio_ext.def \
swprintf.def \
swscanf.def \
tmpfile.def \
@ -1405,6 +1409,12 @@ lib_a-putwchar.o: putwchar.c
lib_a-putwchar.obj: putwchar.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-putwchar.obj `if test -f 'putwchar.c'; then $(CYGPATH_W) 'putwchar.c'; else $(CYGPATH_W) '$(srcdir)/putwchar.c'; fi`
lib_a-stdio_ext.o: stdio_ext.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-stdio_ext.o `test -f 'stdio_ext.c' || echo '$(srcdir)/'`stdio_ext.c
lib_a-stdio_ext.obj: stdio_ext.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-stdio_ext.obj `if test -f 'stdio_ext.c'; then $(CYGPATH_W) 'stdio_ext.c'; else $(CYGPATH_W) '$(srcdir)/stdio_ext.c'; fi`
lib_a-swprintf.o: swprintf.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-swprintf.o `test -f 'swprintf.c' || echo '$(srcdir)/'`swprintf.c

View File

@ -282,6 +282,9 @@ structure.
@page
@include stdio/sscanf.def
@page
@include stdio/stdio_ext.def
@page
@include stdio/swprintf.def

View File

@ -0,0 +1,113 @@
/*
FUNCTION
<<__fbufsize>>, <<__fpending>>, <<__flbf>>, <<__freadable>>, <<__fwritable>> <<__freading>>, <<__fwriting>>,---access internals of FILE structure
INDEX
__fbufsize
INDEX
__fpending
INDEX
__flbf
INDEX
__freadable
INDEX
__fwritable
INDEX
__freading
INDEX
__fwriting
ANSI_SYNOPSIS
#include <stdio.h>
#include <stdio_ext.h>
size_t __fbufsize(FILE *<[fp]>);
size_t __fpending(FILE *<[fp]>);
int __flbf(FILE *<[fp]>);
int __freadable(FILE *<[fp]>);
int __fwritable(FILE *<[fp]>);
int __freading(FILE *<[fp]>);
int __fwriting(FILE *<[fp]>);
DESCRIPTION
These functions provides access to the internals of the FILE structure <[fp]>.
RETURNS
<<__fbufsize>> returns the number of bytes in the buffer of stream <[fp]>.
<<__fpending>> returns the number of bytes in the output buffer of stream <[fp]>.
<<__flbf>> returns nonzero if stream <[fp]> is line-buffered, and <<0>> if not.
<<__freadable>> returns nonzero if stream <[fp]> may be read, and <<0>> if not.
<<__fwritable>> returns nonzero if stream <[fp]> may be written, and <<0>> if not.
<<__freading>> returns nonzero if stream <[fp]> if the last operation on
it was a read, or if it read-only, and <<0>> if not.
<<__fwriting>> returns nonzero if stream <[fp]> if the last operation on
it was a write, or if it write-only, and <<0>> if not.
PORTABILITY
These functions originate from Solaris and are also provided by GNU libc.
No supporting OS subroutines are required.
*/
#ifndef __rtems__
#include <_ansi.h>
#include <stdio.h>
/* Subroutine versions of the inline or macro functions. */
size_t
_DEFUN(__fbufsize, (fp),
FILE * fp)
{
return (size_t) fp->_bf._size;
}
size_t
_DEFUN(__fpending, (fp),
FILE * fp)
{
return fp->_p - fp->_bf._base;
}
int
_DEFUN(__flbf, (fp),
FILE * fp)
{
return (fp->_flags & __SLBF) != 0;
}
int
_DEFUN(__freadable, (fp),
FILE * fp)
{
return (fp->_flags & (__SRD | __SRW)) != 0;
}
int
_DEFUN(__fwritable, (fp),
FILE * fp)
{
return (fp->_flags & (__SWR | __SRW)) != 0;
}
int
_DEFUN(__freading, (fp),
FILE * fp)
{
return (fp->_flags & __SRD) != 0;
}
int
_DEFUN(__fwriting, (fp),
FILE * fp)
{
return (fp->_flags & __SWR) != 0;
}
#endif /* __rtems__ */