diff options
author | Ayke van Laethem <[email protected]> | 2021-09-24 01:39:56 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2021-10-26 17:08:30 +0200 |
commit | 14bb90c3c0f59b752cd4017648521b9adcfeb013 (patch) | |
tree | 3816fe95aae891c160213a2a2f8359015ec36919 /testdata/cgo | |
parent | 1645f45c1a42c57426017741643caebfaabc19ea (diff) | |
download | tinygo-14bb90c3c0f59b752cd4017648521b9adcfeb013.tar.gz tinygo-14bb90c3c0f59b752cd4017648521b9adcfeb013.zip |
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.
Diffstat (limited to 'testdata/cgo')
-rw-r--r-- | testdata/cgo/main.go | 5 | ||||
-rw-r--r-- | testdata/cgo/out.txt | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/testdata/cgo/main.go b/testdata/cgo/main.go index b1880c7b9..cc25152e4 100644 --- a/testdata/cgo/main.go +++ b/testdata/cgo/main.go @@ -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 { diff --git a/testdata/cgo/out.txt b/testdata/cgo/out.txt index 00444cfa3..ca77594f5 100644 --- a/testdata/cgo/out.txt +++ b/testdata/cgo/out.txt @@ -62,3 +62,4 @@ option 3A: 21 enum width matches: true CFLAGS value: 17 copied string: foobar +line written using C puts |