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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [stdio/] [getchar.c] - Blame information for rev 1773

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

Line No. Rev Author Line
1 1010 ivang
/*
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
<<getchar>>---read a character (macro)
21
 
22
INDEX
23
        getchar
24
INDEX
25
        _getchar_r
26
 
27
ANSI_SYNOPSIS
28
        #include <stdio.h>
29
        int getchar(void);
30
 
31
        int _getchar_r(void *<[reent]>);
32
 
33
TRAD_SYNOPSIS
34
        #include <stdio.h>
35
        int getchar();
36
 
37
        int _getchar_r(<[reent]>)
38
        char * <[reent]>;
39
 
40
DESCRIPTION
41
<<getchar>> is a macro, defined in <<stdio.h>>.  You can use <<getchar>>
42
to get the next single character from the standard input stream.
43
As a side effect, <<getchar>> advances the standard input's
44
current position indicator.
45
 
46
The alternate function <<_getchar_r>> is a reentrant version.  The
47
extra argument <[reent]> is a pointer to a reentrancy structure.
48
 
49
 
50
RETURNS
51
The next character (read as an <<unsigned char>>, and cast to
52
<<int>>), unless there is no more data, or the host system reports a
53
read error; in either of these situations, <<getchar>> returns <<EOF>>.
54
 
55
You can distinguish the two situations that cause an <<EOF>> result by
56
using `<<ferror(stdin)>>' and `<<feof(stdin)>>'.
57
 
58
PORTABILITY
59
ANSI C requires <<getchar>>; it suggests, but does not require, that
60
<<getchar>> be implemented as a macro.
61
 
62
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
63
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
64
*/
65
 
66
#if defined(LIBC_SCCS) && !defined(lint)
67
static char sccsid[] = "%W% (Berkeley) %G%";
68
#endif /* LIBC_SCCS and not lint */
69
 
70
/*
71
 * A subroutine version of the macro getchar.
72
 */
73
 
74
#include <stdio.h>
75
#include <reent.h>
76
 
77
#undef getchar
78
 
79
int
80
_getchar_r (f)
81
     struct _reent *f;
82
{
83
  return getc (_stdin_r (f));
84
}
85
 
86
#ifndef _REENT_ONLY
87
 
88
int
89
getchar ()
90
{
91
  /* CHECK_INIT is called (eventually) by __srefill.  */
92
 
93
  return _getchar_r (_REENT);
94
}
95
 
96
#endif

powered by: WebSVN 2.1.0

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