Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / stdio / feof.c
blob674986b2fda988fb294a5f3d472fb9f51b16538b
1 /*
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
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 * and/or 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.
19 FUNCTION
20 <<feof>>, <<feof_unlocked>>---test for end of file
22 INDEX
23 feof
24 INDEX
25 feof_unlocked
27 SYNOPSIS
28 #include <stdio.h>
29 int feof(FILE *<[fp]>);
31 #define _BSD_SOURCE
32 #include <stdio.h>
33 int feof_unlocked(FILE *<[fp]>);
35 DESCRIPTION
36 <<feof>> tests whether or not the end of the file identified by <[fp]>
37 has been reached.
39 <<feof_unlocked>> is a non-thread-safe version of <<feof>>.
40 <<feof_unlocked>> may only safely be used within a scope
41 protected by flockfile() (or ftrylockfile()) and funlockfile(). This
42 function may safely be used in a multi-threaded program if and only
43 if they are called while the invoking thread owns the (FILE *)
44 object, as is the case after a successful call to the flockfile() or
45 ftrylockfile() functions. If threads are disabled, then
46 <<feof_unlocked>> is equivalent to <<feof>>.
48 RETURNS
49 <<feof>> returns <<0>> if the end of file has not yet been reached; if
50 at end of file, the result is nonzero.
52 PORTABILITY
53 <<feof>> is required by ANSI C.
55 <<feof_unlocked>> is a BSD extension also provided by GNU libc.
57 No supporting OS subroutines are required.
60 #include <stdio.h>
61 #include "local.h"
63 /* A subroutine version of the macro feof. */
65 #undef feof
67 int
68 feof (FILE * fp)
70 int result;
71 CHECK_INIT(_REENT, fp);
72 _newlib_flockfile_start (fp);
73 result = __sfeof (fp);
74 _newlib_flockfile_end (fp);
75 return result;