package platform
import "github.com/tetratelabs/wazero/internal/platform"
Package platform includes runtime-specific code needed for the compiler or otherwise.
Note: This is a dependency-free alternative to depending on parts of Go's x/sys. See /RATIONALE.md for more context.
Index ¶
- Constants
- Variables
- func CompilerSupported() bool
- func MmapCodeSegment(size int) ([]byte, error)
- func MprotectRX(b []byte) (err error)
- func MunmapCodeSegment(code []byte) error
- func Nanosleep(ns int64)
- func Nanotime() int64
- func NewFakeNanotime() sys.Nanotime
- func NewFakeRandSource() io.Reader
- func NewFakeWalltime() sys.Walltime
- func RemapCodeSegment(code []byte, size int) ([]byte, error)
- func ToPosixPath(in string) string
- func UnwrapOSError(err error) syscall.Errno
- func Walltime() (sec int64, nsec int32)
- type FdSet
Constants ¶
const ( // FakeEpochNanos is midnight UTC 2022-01-01 and exposed for testing FakeEpochNanos = 1640995200000 * ms )
Variables ¶
FakeNanosleep implements sys.Nanosleep by returning without sleeping.
FakeOsyield implements sys.Osyield by returning without yielding.
IsAtLeastGo120 checks features added in 1.20. We can remove this when Go 1.22 is out.
Functions ¶
func CompilerSupported ¶
func CompilerSupported() bool
CompilerSupported is exported for tests and includes constraints here and also the assembler.
func MmapCodeSegment ¶
MmapCodeSegment copies the code into the executable region and returns the byte slice of the region.
See https://man7.org/linux/man-pages/man2/mmap.2.html for mmap API and flags.
func MprotectRX ¶
func MunmapCodeSegment ¶
MunmapCodeSegment unmaps the given memory region.
func Nanosleep ¶
func Nanosleep(ns int64)
Nanosleep implements sys.Nanosleep with time.Sleep.
func Nanotime ¶
func Nanotime() int64
Nanotime implements sys.Nanotime with runtime.nanotime() if CGO is available and time.Since if not.
func NewFakeNanotime ¶
NewFakeNanotime implements sys.Nanotime that increases by 1ms each reading. See /RATIONALE.md
func NewFakeRandSource ¶
NewFakeRandSource returns a deterministic source of random values.
func NewFakeWalltime ¶
NewFakeWalltime implements sys.Walltime with FakeEpochNanos that increases by 1ms each reading. See /RATIONALE.md
func RemapCodeSegment ¶
RemapCodeSegment reallocates the memory mapping of an existing code segment to increase its size. The previous code mapping is unmapped and must not be reused after the function returns.
This is similar to mremap(2) on linux, and emulated on platforms which do not have this syscall.
See https://man7.org/linux/man-pages/man2/mremap.2.html
func ToPosixPath ¶
ToPosixPath returns the input, as only windows might return backslashes.
func UnwrapOSError ¶
UnwrapOSError returns a syscall.Errno or zero if the input is nil.
func Walltime ¶
Walltime implements sys.Walltime with time.Now.
Note: This is only notably less efficient than it could be is reading runtime.walltime(). time.Now defensively reads nanotime also, just in case time.Since is used. This doubles the performance impact. However, wall time is likely to be read less frequently than Nanotime. Also, doubling the cost matters less on fast platforms that can return both in <=100ns.
Types ¶
type FdSet ¶
type FdSet struct { Bits [16]int64 }
FdSet mocks syscall.FdSet on systems that do not support it.
func (*FdSet) Clear ¶
Clear removes the given fd from the set.
func (*FdSet) IsSet ¶
IsSet returns true when fd is in the set.
func (*FdSet) Set ¶
Set adds the given fd to the set.
func (*FdSet) Zero ¶
func (f *FdSet) Zero()
Zero clears the set.
Source Files ¶
crypto.go errno.go error.go fdset.go fdset_unsupported.go mmap_unsupported.go mremap_other.go path.go platform.go time.go time_cgo.go
- Version
- v1.3.0
- Published
- Jul 11, 2023
- Platform
- js/wasm
- Imports
- 12 packages
- Last checked
- 1 hour ago –
Tools for package owners.