Index: wasm-tests/write_loop.c |
diff --git a/wasm-tests/write_loop.c b/wasm-tests/write_loop.c |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d398d6b5d0060912178d72fe2778257dd0564dd6 |
--- /dev/null |
+++ b/wasm-tests/write_loop.c |
@@ -0,0 +1,14 @@ |
+// This is derived from the loop in musl's __fwritex that looks for newlines. |
+ |
+int puts(const char *s); |
+ |
+int main(int argc, const char **argv) { |
+ const char *p = (const char *)argv; |
+ char *s = "Hello\nWorld"; |
+ unsigned i = 0; |
+ // Depend on argc to avoid having this whole thing get dead-code-eliminated. |
+ for (i = 14 - argc; i && p[i - 1] != '\n'; i--) |
+ ; |
+ puts(s); |
+ return i; |
+} |