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
+5
View File
@@ -1,6 +1,7 @@
package main
/*
#include <stdio.h>
int fortytwo(void);
#include "main.h"
int mul(int, int);
@@ -139,6 +140,10 @@ func main() {
buf2 := make([]byte, len(buf1))
C.strcpy((*C.char)(unsafe.Pointer(&buf2[0])), (*C.char)(unsafe.Pointer(&buf1[0])))
println("copied string:", string(buf2[:C.strlen((*C.char)(unsafe.Pointer(&buf2[0])))]))
// libc: test basic stdio functionality
putsBuf := []byte("line written using C puts\x00")
C.puts((*C.char)(unsafe.Pointer(&putsBuf[0])))
}
func printUnion(union C.joined_t) C.joined_t {
+1
View File
@@ -62,3 +62,4 @@ option 3A: 21
enum width matches: true
CFLAGS value: 17
copied string: foobar
line written using C puts