diff options
Diffstat (limited to 'newlib/libc/stdio/fgetc.c')
-rw-r--r-- | newlib/libc/stdio/fgetc.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/newlib/libc/stdio/fgetc.c b/newlib/libc/stdio/fgetc.c index 020b2da3a..1802acf7e 100644 --- a/newlib/libc/stdio/fgetc.c +++ b/newlib/libc/stdio/fgetc.c @@ -21,16 +21,26 @@ FUNCTION INDEX fgetc +INDEX + _fgetc_r ANSI_SYNOPSIS #include <stdio.h> int fgetc(FILE *<[fp]>); + #include <stdio.h> + int _fgetc_r(struct _reent *<[ptr]>, FILE *<[fp]>); + TRAD_SYNOPSIS #include <stdio.h> int fgetc(<[fp]>) FILE *<[fp]>; + #include <stdio.h> + int _fgetc_r(<[ptr]>, <[fp]>) + struct _reent *<[ptr]>; + FILE *<[fp]>; + DESCRIPTION Use <<fgetc>> to get the next single character from the file or stream identified by <[fp]>. As a side effect, <<fgetc>> advances the file's @@ -38,6 +48,10 @@ current position indicator. For a macro version of this function, see <<getc>>. +The function <<_fgetc_r>> is simply a reentrant version of +<<fgetc>> that is passed the additional reentrant structure +pointer argument: <[ptr]>. + RETURNS The next character (read as an <<unsigned char>>, and cast to <<int>>), unless there is no more data, or the host system reports a @@ -58,13 +72,35 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>, #include "local.h" int +_DEFUN(_fgetc_r, (ptr, fp), + struct _reent * ptr _AND + FILE * fp) +{ + int result; + CHECK_INIT(ptr); + _flockfile (fp); + result = __sgetc_r (ptr, fp); + _funlockfile (fp); + return result; +} + +#ifndef _REENT_ONLY + +int _DEFUN(fgetc, (fp), FILE * fp) { +#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) int result; CHECK_INIT(_REENT); _flockfile (fp); - result = __sgetc (fp); + result = __sgetc_r (_REENT, fp); _funlockfile (fp); return result; +#else + return _fgetc_r (_REENT, fp); +#endif } + +#endif /* !_REENT_ONLY */ + |