aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2024-11-07 13:38:28 +0100
committerRon Evans <[email protected]>2024-12-01 11:12:00 +0100
commit26c36d0a2e11ba6b31300881b8dd729b1ad8cfe6 (patch)
treec65ca380fe496864f5be593bebed68cc51bf7c94 /testdata
parent09a22ac4b48b5a008cedc527c70cf41117a6b338 (diff)
downloadtinygo-26c36d0a2e11ba6b31300881b8dd729b1ad8cfe6.tar.gz
tinygo-26c36d0a2e11ba6b31300881b8dd729b1ad8cfe6.zip
runtime: lock output in print/println
This ensures that calls to print/println happening in different threads are not interleaved. It's a task.PMutex, so this should only change things when threading is used. This matches the Go compiler, which does the same thing: https://godbolt.org/z/na5KzE7en The locks are not recursive, which means that we need to be careful to not call `print` or `println` inside a runtime.print* implementation, inside putchar (recursively), and inside signal handlers. Making them recursive might be useful to do in the future, but it's not really necessary.
Diffstat (limited to 'testdata')
-rw-r--r--testdata/print.go6
-rw-r--r--testdata/print.txt6
2 files changed, 12 insertions, 0 deletions
diff --git a/testdata/print.go b/testdata/print.go
index 7f7f843c4..5156ad58e 100644
--- a/testdata/print.go
+++ b/testdata/print.go
@@ -37,6 +37,12 @@ func main() {
// print interface
println(interface{}(nil))
+ println(interface{}(true))
+ println(interface{}("foobar"))
+ println(interface{}(int64(-3)))
+ println(interface{}(uint64(3)))
+ println(interface{}(int(-3)))
+ println(interface{}(uint(3)))
// print map
println(map[string]int{"three": 3, "five": 5})
diff --git a/testdata/print.txt b/testdata/print.txt
index 116de945d..3a88cf91e 100644
--- a/testdata/print.txt
+++ b/testdata/print.txt
@@ -19,6 +19,12 @@ a b c
+3.140000e+000
(+5.000000e+000+1.234500e+000i)
(0:nil)
+true
+foobar
+-3
+3
+-3
+3
map[2]
true false
[0/0]nil