package sys
import "github.com/tetratelabs/wazero/sys"
Package sys includes constants and types used by both public and internal APIs.
Index ¶
- type ClockResolution
- type ExitError
- func NewExitError(moduleName string, exitCode uint32) *ExitError
- func (e *ExitError) Error() string
- func (e *ExitError) ExitCode() uint32
- func (e *ExitError) Is(err error) bool
- func (e *ExitError) ModuleName() string
- type Nanosleep
- type Nanotime
- type Walltime
Types ¶
type ClockResolution ¶
type ClockResolution uint32
ClockResolution is a positive granularity of clock precision in nanoseconds. For example, if the resolution is 1us, this returns 1000.
Note: Some implementations return arbitrary resolution because there's no perfect alternative. For example, according to the source in time.go, windows monotonic resolution can be 15ms. See /RATIONALE.md.
type ExitError ¶
type ExitError struct {
// contains filtered or unexported fields
}
ExitError is returned to a caller of api.Function still running when api.Module CloseWithExitCode was invoked. ExitCode zero value means success, while any other value is an error.
Here's an example of how to get the exit code:
main := module.ExportedFunction("main") if err := main(ctx); err != nil { if exitErr, ok := err.(*sys.ExitError); ok { // If your main function expects to exit, this could be ok if Code == 0 } --snip--
Note: While possible the reason of this was "proc_exit" from "wasi_snapshot_preview1", it could be from other host functions, for example an AssemblyScript's abort handler, or any arbitrary caller of CloseWithExitCode.
See https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#proc_exit and https://www.assemblyscript.org/concepts.html#special-imports
func NewExitError ¶
func (*ExitError) Error ¶
Error implements the error interface.
func (*ExitError) ExitCode ¶
ExitCode returns zero on success, and an arbitrary value otherwise.
func (*ExitError) Is ¶
Is allows use via errors.Is
func (*ExitError) ModuleName ¶
ModuleName is the api.Module that was closed.
type Nanosleep ¶
type Nanosleep func(ns int64)
Nanosleep puts the current goroutine to sleep for at least ns nanoseconds.
type Nanotime ¶
type Nanotime func() int64
Nanotime returns nanoseconds since an arbitrary start point, used to measure elapsed time. This is sometimes referred to as a tick or monotonic time.
Note: There are no constraints on the value return except that it increments. For example, -1 is a valid if the next value is >= 0.
type Walltime ¶
Walltime returns the current time in epoch seconds with a nanosecond fraction.
Source Files ¶
- Version
- v1.0.0-pre.8
- Published
- Jan 31, 2023
- Platform
- darwin/amd64
- Imports
- 1 packages
- Last checked
- 9 minutes ago –
Tools for package owners.