source: trunk/libs/newlib/src/newlib/libc/stdio/getchar_u.c @ 577

Last change on this file since 577 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.5 KB
Line 
1/*
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/*
19FUNCTION
20<<getchar_unlocked>>---non-thread-safe version of getchar (macro)
21
22INDEX
23        getchar_unlocked
24INDEX
25        _getchar_unlocked_r
26
27SYNOPSIS
28        #include <stdio.h>
29        int getchar_unlocked(void);
30
31        #include <stdio.h>
32        int _getchar_unlocked_r(struct _reent *<[ptr]>);
33
34DESCRIPTION
35<<getchar_unlocked>> is a non-thread-safe version of <<getchar>>
36declared in <<stdio.h>>.  <<getchar_unlocked>> may only safely be used
37within a scope protected by flockfile() (or ftrylockfile()) and
38funlockfile().  These functions may safely be used in a multi-threaded
39program if and only if they are called while the invoking thread owns
40the ( FILE *) object, as is the case after a successful call to the
41flockfile() or ftrylockfile() functions.  If threads are disabled,
42then <<getchar_unlocked>> is equivalent to <<getchar>>.
43
44The <<_getchar_unlocked_r>> function is simply the reentrant version of
45<<getchar_unlocked>> which passes an addtional reentrancy structure pointer
46argument: <[ptr]>.
47
48RETURNS
49See <<getchar>>.
50
51PORTABILITY
52POSIX 1003.1 requires <<getchar_unlocked>>.  <<getchar_unlocked>> may
53be implemented as a macro.
54
55Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
56<<lseek>>, <<read>>, <<sbrk>>, <<write>>.  */
57
58#if defined(LIBC_SCCS) && !defined(lint)
59static char sccsid[] = "%W% (Berkeley) %G%";
60#endif /* LIBC_SCCS and not lint */
61
62/*
63 * A subroutine version of the macro getchar_unlocked.
64 */
65
66#include <_ansi.h>
67#include <reent.h>
68#include <stdio.h>
69
70#undef getchar_unlocked
71
72int
73_getchar_unlocked_r (struct _reent *ptr)
74{
75  return _getc_unlocked_r (ptr, _stdin_r (ptr));
76}
77
78#ifndef _REENT_ONLY
79
80int
81getchar_unlocked (void)
82{
83  /* CHECK_INIT is called (eventually) by __srefill_r.  */
84
85  return _getc_unlocked_r (_REENT, _stdin_r (_REENT));
86}
87
88#endif
Note: See TracBrowser for help on using the repository browser.