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

Unified Diff: wasm-tests/hello-putchar.c

Issue 1876413002: Subzero. WASM. Additional progress. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Merging with master Created 4 years, 8 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
Index: wasm-tests/hello-putchar.c
diff --git a/wasm-tests/hello-putchar.c b/wasm-tests/hello-putchar.c
new file mode 100644
index 0000000000000000000000000000000000000000..eacbf067adddce5eb033673e232f83afc5460964
--- /dev/null
+++ b/wasm-tests/hello-putchar.c
@@ -0,0 +1,45 @@
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+void write_int_(int fd, int n) {
+ if (n > 0) {
+ write_int_(fd, n / 10);
+
+ int rem = n % 10;
+ char c = '0' + rem;
+ write(fd, &c, 1);
+ }
+}
+
+void write_int(int fd, int n) {
+ if (n == 0) {
+ write(fd, "0", 1);
+ } else {
+ if (n < 0) {
+ write(fd, "-", 1);
+ write_int_(fd, -n);
+ } else {
+ write_int_(fd, n);
+ }
+ }
+}
+
+void stderr_int(int n) {
+ write_int(2, n);
+ write(2, "\n", 1);
+}
+
+int main(int argc, const char **argv) {
+ char *str = "Hello, World!\n";
+ for (int i = 0; str[i]; ++i) {
+ putchar(str[i]);
+
+ // write(2, "---\n", 4);
Jim Stichnoth 2016/04/14 20:03:44 Do these commented lines need to stay?
Eric Holk 2016/04/15 15:24:27 Nope. Done.
+ // write(2, "wpos: ", 6);
+ // stderr_int(((int *)stdout)[5]); //wpos
+ // write(2, "wend: ", 6);
+ // stderr_int(((int *)stdout)[4]); //wend
+ }
+ return 0;
+}
« src/WasmTranslator.cpp ('K') | « wasm-tests/hello-printf.c ('k') | wasm-tests/hello-puts.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698