Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Unified Diff: fusl/src/stdio/setvbuf.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fusl/src/stdio/setlinebuf.c ('k') | fusl/src/stdio/snprintf.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fusl/src/stdio/setvbuf.c
diff --git a/fusl/src/stdio/setvbuf.c b/fusl/src/stdio/setvbuf.c
new file mode 100644
index 0000000000000000000000000000000000000000..541a125ff124b1c1b5aa15949f0890a3d12c6f6b
--- /dev/null
+++ b/fusl/src/stdio/setvbuf.c
@@ -0,0 +1,24 @@
+#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;
+}
« no previous file with comments | « fusl/src/stdio/setlinebuf.c ('k') | fusl/src/stdio/snprintf.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698