tinygo/src/runtime/runtime_arm7tdmi.go
Ayke van Laethem 4ec1e58aa6 all: use unsafe.Add instead of unsafe.Pointer(uintptr(...) + ...)
We have an optimization for this specific pattern, but it's really just
a hack. With the addition of unsafe.Add in Go 1.17 we can directly
specify the intent instead and eventually remove this special case.

The code is also easier to read.
2023-03-03 16:55:13 +01:00

95 строки
1,4 КиБ
Go

//go:build arm7tdmi
package runtime
import (
_ "runtime/interrupt" // make sure the interrupt handler is defined
"unsafe"
)
type timeUnit int64
func putchar(c byte) {
// dummy, TODO
}
func getchar() byte {
// dummy, TODO
return 0
}
func buffered() int {
// dummy, TODO
return 0
}
//go:extern _sbss
var _sbss [0]byte
//go:extern _ebss
var _ebss [0]byte
//go:extern _sdata
var _sdata [0]byte
//go:extern _sidata
var _sidata [0]byte
//go:extern _edata
var _edata [0]byte
// Entry point for Go. Initialize all packages and call main.main().
//
//export main
func main() {
// Initialize .data and .bss sections.
preinit()
// Run program.
run()
}
func preinit() {
// Initialize .bss: zero-initialized global variables.
ptr := unsafe.Pointer(&_sbss)
for ptr != unsafe.Pointer(&_ebss) {
*(*uint32)(ptr) = 0
ptr = unsafe.Add(ptr, 4)
}
// Initialize .data: global variables initialized from flash.
src := unsafe.Pointer(&_sidata)
dst := unsafe.Pointer(&_sdata)
for dst != unsafe.Pointer(&_edata) {
*(*uint32)(dst) = *(*uint32)(src)
dst = unsafe.Add(dst, 4)
src = unsafe.Add(src, 4)
}
}
func ticksToNanoseconds(ticks timeUnit) int64 {
return int64(ticks)
}
func nanosecondsToTicks(ns int64) timeUnit {
return timeUnit(ns)
}
func ticks() timeUnit {
// TODO
return 0
}
func sleepTicks(d timeUnit) {
// TODO
}
func exit(code int) {
abort()
}
func abort() {
// TODO
for {
}
}