source: trunk/libs/newlib/src/newlib/libc/stdio/ferror.c

Last change on this file 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<<ferror>>, <<ferror_unlocked>>---test whether read/write error has occurred
21
22INDEX
23        ferror
24INDEX
25        ferror_unlocked
26
27SYNOPSIS
28        #include <stdio.h>
29        int ferror(FILE *<[fp]>);
30
31        #define _BSD_SOURCE
32        #include <stdio.h>
33        int ferror_unlocked(FILE *<[fp]>);
34
35DESCRIPTION
36The <<stdio>> functions maintain an error indicator with each file
37pointer <[fp]>, to record whether any read or write errors have
38occurred on the associated file or stream.
39Use <<ferror>> to query this indicator.
40
41See <<clearerr>> to reset the error indicator.
42
43<<ferror_unlocked>> is a non-thread-safe version of <<ferror>>.
44<<ferror_unlocked>> may only safely be used within a scope
45protected by flockfile() (or ftrylockfile()) and funlockfile().  This
46function may safely be used in a multi-threaded program if and only
47if they are called while the invoking thread owns the (FILE *)
48object, as is the case after a successful call to the flockfile() or
49ftrylockfile() functions.  If threads are disabled, then
50<<ferror_unlocked>> is equivalent to <<ferror>>.
51
52RETURNS
53<<ferror>> returns <<0>> if no errors have occurred; it returns a
54nonzero value otherwise.
55
56PORTABILITY
57ANSI C requires <<ferror>>.
58
59<<ferror_unlocked>> is a BSD extension also provided by GNU libc.
60
61No supporting OS subroutines are required.
62*/
63
64#if defined(LIBC_SCCS) && !defined(lint)
65static char sccsid[] = "%W% (Berkeley) %G%";
66#endif /* LIBC_SCCS and not lint */
67
68#include <_ansi.h>
69#include <stdio.h>
70#include "local.h"
71
72/* A subroutine version of the macro ferror.  */
73
74#undef ferror
75
76int
77ferror (FILE * fp)
78{
79  int result;
80  CHECK_INIT(_REENT, fp);
81  _newlib_flockfile_start (fp);
82  result = __sferror (fp);
83  _newlib_flockfile_end (fp);
84  return result;
85}
Note: See TracBrowser for help on using the repository browser.