1 package runtime
2 3 import "unsafe"
4 5 // tracePuts and traceU64 write an instrumented build's counters to a file
6 // descriptor. The alloc_trace and cover runtimes both dump "site count" lines
7 // that a host or a reporter reads back, so the writers live here rather than
8 // once per instrumented runtime.
9 //
10 // An untagged build carries them unreferenced and the linker drops them.
11 12 func tracePuts(fd int32, s string) {
13 if len(s) == 0 {
14 return
15 }
16 MoxieWrite(fd, unsafe.Pointer(&([]byte(s))[0]), int32(len(s)))
17 }
18 19 func traceU64(fd int32, v uint64) {
20 buf := []byte{:24}
21 i := int32(24)
22 if v == 0 {
23 i--
24 buf[i] = '0'
25 }
26 for v > 0 {
27 i--
28 buf[i] = byte(v%10) + '0'
29 v = v / 10
30 }
31 MoxieWrite(fd, unsafe.Pointer(&buf[i]), 24-i)
32 }
33