aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/stdio/getc.c
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/stdio/getc.c')
-rw-r--r--newlib/libc/stdio/getc.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/newlib/libc/stdio/getc.c b/newlib/libc/stdio/getc.c
index 9628a87..c02fe6b 100644
--- a/newlib/libc/stdio/getc.c
+++ b/newlib/libc/stdio/getc.c
@@ -21,16 +21,26 @@ FUNCTION
INDEX
getc
+INDEX
+ _getc_r
ANSI_SYNOPSIS
#include <stdio.h>
int getc(FILE *<[fp]>);
+ #include <stdio.h>
+ int _getc_r(struct _reent *<[ptr]>, FILE *<[fp]>);
+
TRAD_SYNOPSIS
#include <stdio.h>
int getc(<[fp]>)
FILE *<[fp]>;
+ #include <stdio.h>
+ int _getc_r(<[ptr]>, <[fp]>)
+ struct _reent *<[ptr]>;
+ FILE *<[fp]>;
+
DESCRIPTION
<<getc>> is a macro, defined in <<stdio.h>>. You can use <<getc>>
to get the next single character from the file or stream
@@ -39,6 +49,9 @@ current position indicator.
For a subroutine version of this macro, see <<fgetc>>.
+The <<_getc_r>> function is simply the reentrant version of <<getc>>
+which passes an additional reentrancy 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
@@ -73,13 +86,30 @@ static char sccsid[] = "%W% (Berkeley) %G%";
#undef getc
int
+_DEFUN(_getc_r, (ptr, fp),
+ struct _reent *ptr _AND
+ register FILE *fp)
+{
+ int result;
+ CHECK_INIT (ptr);
+ _flockfile (fp);
+ result = __sgetc_r (ptr, fp);
+ _funlockfile (fp);
+ return result;
+}
+
+#ifndef _REENT_ONLY
+
+int
_DEFUN(getc, (fp),
register FILE *fp)
{
int result;
CHECK_INIT (_REENT);
_flockfile (fp);
- result = __sgetc (fp);
+ result = __sgetc_r (_REENT, fp);
_funlockfile (fp);
return result;
}
+
+#endif /* !_REENT_ONLY */