cgo: add support for stdio in picolibc and wasi-libc

This adds support for stdio in picolibc and fixes wasm_exec.js so that
it can also support C puts. With this, C stdout works on all supported
platforms.
This commit is contained in:
Ayke van Laethem
2021-09-24 01:39:56 +02:00
committed by Ron Evans
parent 1645f45c1a
commit 14bb90c3c0
11 changed files with 158 additions and 7 deletions
+4
View File
@@ -256,6 +256,7 @@
let iov_ptr = iovs_ptr+iovs_i*8; // assuming wasm32
let ptr = mem().getUint32(iov_ptr + 0, true);
let len = mem().getUint32(iov_ptr + 4, true);
nwritten += len;
for (let i=0; i<len; i++) {
let c = mem().getUint8(ptr+i);
if (c == 13) { // CR
@@ -276,6 +277,9 @@
mem().setUint32(nwritten_ptr, nwritten, true);
return 0;
},
fd_close: () => 0, // dummy
fd_fdstat_get: () => 0, // dummy
fd_seek: () => 0, // dummy
"proc_exit": (code) => {
if (global.process) {
// Node.js