limit the configurable default stack/guard size for threads
[musl.git] / src / stdio / setvbuf.c
blob06ea296c6a64202ed4f95e23c6af884f5305e1e7
1 #include "stdio_impl.h"
3 /* The behavior of this function is undefined except when it is the first
4 * operation on the stream, so the presence or absence of locking is not
5 * observable in a program whose behavior is defined. Thus no locking is
6 * performed here. No allocation of buffers is performed, but a buffer
7 * provided by the caller is used as long as it is suitably sized. */
9 int setvbuf(FILE *restrict f, char *restrict buf, int type, size_t size)
11 f->lbf = EOF;
13 if (type == _IONBF) {
14 f->buf_size = 0;
15 } else {
16 if (buf && size >= UNGET) {
17 f->buf = (void *)(buf + UNGET);
18 f->buf_size = size - UNGET;
20 if (type == _IOLBF && f->buf_size)
21 f->lbf = '\n';
24 f->flags |= F_SVB;
26 return 0;