musl/src/stdio/setvbuf.c
Rich Felker 400c5e5c83 use restrict everywhere it's required by c99 and/or posix 2008
to deal with the fact that the public headers may be used with pre-c99
compilers, __restrict is used in place of restrict, and defined
appropriately for any supported compiler. we also avoid the form
[restrict] since older versions of gcc rejected it due to a bug in the
original c99 standard, and instead use the form *restrict.
2012-09-06 22:44:55 -04:00

25 lines
732 B
C

#include "stdio_impl.h"
/* This function makes no attempt to protect the user from his/her own
* stupidity. If called any time but when then ISO C standard specifically
* allows it, all hell can and will break loose, especially with threads!
*
* This implementation ignores all arguments except the buffering type,
* and uses the existing buffer allocated alongside the FILE object.
* In the case of stderr where the preexisting buffer is length 1, it
* is not possible to set line buffering or full buffering. */
int setvbuf(FILE *restrict f, char *restrict buf, int type, size_t size)
{
f->lbf = EOF;
if (type == _IONBF)
f->buf_size = 0;
else if (type == _IOLBF)
f->lbf = '\n';
f->flags |= F_SVB;
return 0;
}