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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [stdio/] [getchar.c] - Blame information for rev 864

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
<<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(struct _reent *<[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 <_ansi.h>
75
#include <reent.h>
76
#include <stdio.h>
77
#include "local.h"
78
 
79
#undef getchar
80
 
81
int
82
_DEFUN(_getchar_r, (reent),
83
       struct _reent *reent)
84
{
85
  _REENT_SMALL_CHECK_INIT (reent);
86
  return _getc_r (reent, _stdin_r (reent));
87
}
88
 
89
#ifndef _REENT_ONLY
90
 
91
int
92
_DEFUN_VOID(getchar)
93
{
94
  /* CHECK_INIT is called (eventually) by __srefill_r.  */
95
  _REENT_SMALL_CHECK_INIT (_REENT);
96
  return _getc_r (_REENT, _stdin_r (_REENT));
97
}
98
 
99
#endif

powered by: WebSVN 2.1.0

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