OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [stdio/] [getc.c] - Blame information for rev 179

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/*
2
 * Copyright (c) 1990 The Regents of the University of California.
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms are permitted
6
 * provided that the above copyright notice and this paragraph are
7
 * duplicated in all such forms and that any documentation,
8
 * advertising materials, and other materials related to such
9
 * distribution and use acknowledge that the software was developed
10
 * by the University of California, Berkeley.  The name of the
11
 * University may not be used to endorse or promote products derived
12
 * from this software without specific prior written permission.
13
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16
 */
17
 
18
/*
19
FUNCTION
20
<<getc>>---read a character (macro)
21
 
22
INDEX
23
        getc
24
INDEX
25
        _getc_r
26
 
27
ANSI_SYNOPSIS
28
        #include <stdio.h>
29
        int getc(FILE *<[fp]>);
30
 
31
        #include <stdio.h>
32
        int _getc_r(struct _reent *<[ptr]>, FILE *<[fp]>);
33
 
34
TRAD_SYNOPSIS
35
        #include <stdio.h>
36
        int getc(<[fp]>)
37
        FILE *<[fp]>;
38
 
39
        #include <stdio.h>
40
        int _getc_r(<[ptr]>, <[fp]>)
41
        struct _reent *<[ptr]>;
42
        FILE *<[fp]>;
43
 
44
DESCRIPTION
45
<<getc>> is a macro, defined in <<stdio.h>>.  You can use <<getc>>
46
to get the next single character from the file or stream
47
identified by <[fp]>.  As a side effect, <<getc>> advances the file's
48
current position indicator.
49
 
50
For a subroutine version of this macro, see <<fgetc>>.
51
 
52
The <<_getc_r>> function is simply the reentrant version of <<getc>>
53
which passes an additional reentrancy structure pointer argument: <[ptr]>.
54
 
55
RETURNS
56
The next character (read as an <<unsigned char>>, and cast to
57
<<int>>), unless there is no more data, or the host system reports a
58
read error; in either of these situations, <<getc>> returns <<EOF>>.
59
 
60
You can distinguish the two situations that cause an <<EOF>> result by
61
using the <<ferror>> and <<feof>> functions.
62
 
63
PORTABILITY
64
ANSI C requires <<getc>>; it suggests, but does not require, that
65
<<getc>> be implemented as a macro.  The standard explicitly permits
66
macro implementations of <<getc>> to use the argument more than once;
67
therefore, in a portable program, you should not use an expression
68
with side effects as the <<getc>> argument.
69
 
70
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
71
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
72
*/
73
 
74
#if defined(LIBC_SCCS) && !defined(lint)
75
static char sccsid[] = "%W% (Berkeley) %G%";
76
#endif /* LIBC_SCCS and not lint */
77
 
78
#include <_ansi.h>
79
#include <stdio.h>
80
#include "local.h"
81
 
82
/*
83
 * A subroutine version of the macro getc.
84
 */
85
 
86
#undef getc
87
 
88
int
89
_DEFUN(_getc_r, (ptr, fp),
90
       struct _reent *ptr _AND
91
       register FILE *fp)
92
{
93
  int result;
94
  CHECK_INIT (ptr, fp);
95
  _flockfile (fp);
96
  result = __sgetc_r (ptr, fp);
97
  _funlockfile (fp);
98
  return result;
99
}
100
 
101
#ifndef _REENT_ONLY
102
 
103
int
104
_DEFUN(getc, (fp),
105
       register FILE *fp)
106
{
107
  int result;
108
  CHECK_INIT (_REENT, fp);
109
  _flockfile (fp);
110
  result = __sgetc_r (_REENT, fp);
111
  _funlockfile (fp);
112
  return result;
113
}
114
 
115
#endif /* !_REENT_ONLY */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.