github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/runtime/runtime_tinygoriscv64.go (about) 1 //go:build tinygo.riscv64 2 3 package runtime 4 5 import "unsafe" 6 7 //go:extern _sbss 8 var _sbss [0]byte 9 10 //go:extern _ebss 11 var _ebss [0]byte 12 13 //go:extern _sdata 14 var _sdata [0]byte 15 16 //go:extern _sidata 17 var _sidata [0]byte 18 19 //go:extern _edata 20 var _edata [0]byte 21 22 func preinit() { 23 // Initialize .bss: zero-initialized global variables. 24 ptr := unsafe.Pointer(&_sbss) 25 for ptr != unsafe.Pointer(&_ebss) { 26 *(*uint64)(ptr) = 0 27 ptr = unsafe.Add(ptr, 8) 28 } 29 30 // Initialize .data: global variables initialized from flash. 31 src := unsafe.Pointer(&_sidata) 32 dst := unsafe.Pointer(&_sdata) 33 for dst != unsafe.Pointer(&_edata) { 34 *(*uint64)(dst) = *(*uint64)(src) 35 dst = unsafe.Add(dst, 8) 36 src = unsafe.Add(src, 8) 37 } 38 }