fixed more binutils issues (newer gcc/libc)
[zpugcc/jano.git] / toolchain / gcc / newlib / libc / stdio / setbuffer.c
blobc74c7fce14a076e7c04d9f183566dabb4f036cd2
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 * 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.
18 /*
19 Modified copy of setbuf.c to support the setbuffer function
20 defined as part of BSD.
21 Modifications by Gareth Pearce, 2001.
25 FUNCTION
26 <<setbuffer>>---specify full buffering for a file or stream with size
28 INDEX
29 setbuffer
31 ANSI_SYNOPSIS
32 #include <stdio.h>
33 void setbuffer(FILE *<[fp]>, char *<[buf]>, int <[size]>);
35 TRAD_SYNOPSIS
36 #include <stdio.h>
37 void setbuffer(<[fp]>, <[buf]>, <[size]>)
38 FILE *<[fp]>;
39 char *<[buf]>;
40 int <[size]>;
42 DESCRIPTION
43 <<setbuffer>> specifies that output to the file or stream identified by
44 <[fp]> should be fully buffered. All output for this file will go to a
45 buffer (of size <[size]>). Output will be passed on to the host system
46 only when the buffer is full, or when an input operation intervenes.
48 You may, if you wish, supply your own buffer by passing a pointer to
49 it as the argument <[buf]>. It must have size <[size]>. You can
50 also use <<NULL>> as the value of <[buf]>, to signal that the
51 <<setbuffer>> function is to allocate the buffer.
53 WARNINGS
54 You may only use <<setbuffer>> before performing any file operation
55 other than opening the file.
57 If you supply a non-null <[buf]>, you must ensure that the associated
58 storage continues to be available until you close the stream
59 identified by <[fp]>.
61 RETURNS
62 <<setbuffer>> does not return a result.
64 PORTABILITY
65 This function comes from BSD not ANSI or POSIX.
67 Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
68 <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
71 FUNCTION
73 <<setlinebuf>>---specify line buffering for a file or stream
75 INDEX
76 setlinebuf
78 ANSI_SYNOPSIS
79 #include <stdio.h>
80 void setlinebuf(FILE *<[fp]>);
82 TRAD_SYNOPSIS
83 #include <stdio.h>
84 void setlinebuf(<[fp]>)
85 FILE *<[fp]>;
87 DESCRIPTION
88 <<setlinebuf>> specifies that output to the file or stream identified by
89 <[fp]> should be line buffered. This causes the file or stream to pass
90 on output to the host system at every newline, as well as when the
91 buffer is full, or when an input operation intervenes.
93 WARNINGS
94 You may only use <<setlinebuf>> before performing any file operation
95 other than opening the file.
97 RETURNS
98 <<setlinebuf>> returns as per setvbuf.
100 PORTABILITY
101 This function comes from BSD not ANSI or POSIX.
103 Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
104 <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
107 #include <_ansi.h>
108 #include <stdio.h>
109 #include "local.h"
111 void
112 _DEFUN (setbuffer, (fp, buf, size),
113 FILE * fp _AND
114 char *buf _AND
115 int size)
117 (void) setvbuf (fp, buf, buf ? _IOFBF : _IONBF, (size_t) size);