mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 18:47:47 +00:00
9da8b5c786
This adds support for the `//go:wasmexport` pragma as proposed here: https://github.com/golang/go/issues/65199 It is currently implemented only for wasip1 and wasm-unknown, but it is certainly possible to extend it to other targets like GOOS=js and wasip2.
39 lines
668 B
Go
39 lines
668 B
Go
//go:build wasm_unknown
|
|
|
|
package runtime
|
|
|
|
// TODO: this is essentially reactor mode wasm. So we might want to support
|
|
// -buildmode=c-shared (and default to it).
|
|
|
|
type timeUnit int64
|
|
|
|
// libc constructors
|
|
//
|
|
//export __wasm_call_ctors
|
|
func __wasm_call_ctors()
|
|
|
|
func init() {
|
|
__wasm_call_ctors()
|
|
}
|
|
|
|
func ticksToNanoseconds(ticks timeUnit) int64 {
|
|
return int64(ticks)
|
|
}
|
|
|
|
func nanosecondsToTicks(ns int64) timeUnit {
|
|
return timeUnit(ns)
|
|
}
|
|
|
|
// with the wasm32-unknown-unknown target there is no way to determine any `precision`
|
|
const timePrecisionNanoseconds = 1000
|
|
|
|
func sleepTicks(d timeUnit) {
|
|
}
|
|
|
|
func ticks() timeUnit {
|
|
return timeUnit(0)
|
|
}
|
|
|
|
func beforeExit() {
|
|
}
|