remove LFS64 symbol aliases; replace with dynamic linker remapping
[musl.git] / src / stdio / setvbuf.c
blob523dddc8ba28f53a7b3fcc4e3e5323de092acc22
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 if (type == _IOLBF || type == _IOFBF) {
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';
22 } else {
23 return -1;
26 f->flags |= F_SVB;
28 return 0;