2 * Copyright (c) 1990 The Regents of the University of California.
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.
20 <<fflush>>---flush buffered file output
27 int fflush(FILE *<[fp]>);
35 The <<stdio>> output functions can buffer output before delivering it
36 to the host system, in order to minimize the overhead of system calls.
38 Use <<fflush>> to deliver any such pending output (for the file
39 or stream identified by <[fp]>) to the host system.
41 If <[fp]> is <<NULL>>, <<fflush>> delivers pending output from all
45 <<fflush>> returns <<0>> unless it encounters a write error; in that
46 situation, it returns <<EOF>>.
49 ANSI C requires <<fflush>>.
51 No supporting OS subroutines are required.
57 /* Flush a single file, or (if fp is NULL) all files. */
63 register unsigned char *p
;
67 return _fwalk (_GLOBAL_REENT
, fflush
);
74 if ((t
& __SWR
) == 0 || (p
= fp
->_bf
._base
) == NULL
)
79 n
= fp
->_p
- p
; /* write this much */
82 * Set these immediately to avoid problems with longjmp
83 * and to allow exchange buffering (via setvbuf) in user
87 fp
->_w
= t
& (__SLBF
| __SNBF
) ? 0 : fp
->_bf
._size
;
91 t
= (*fp
->_write
) (fp
->_cookie
, (char *) p
, n
);