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
- func CompilerSupported() bool
- func FakeNanosleep(int64)
- func FakeOsyield()
- func Fdatasync(fd uintptr) (err error)
- func IsTerminal(fd uintptr) bool
- func MmapCodeSegment(code io.Reader, size int) ([]byte, 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 OpenFile(name string, flag int, perm fs.FileMode) (*os.File, error)
- func Rename(from, to string) error
- func SanitizeSeparator([]byte)
- func Stat(f fs.File, t os.FileInfo) (atimeNsec, mtimeNsec, ctimeNsec int64, nlink, dev, inode uint64, err error)
- func StatTimes(t os.FileInfo) (atimeNsec, mtimeNsec, ctimeNsec int64)
- func Walltime() (sec int64, nsec int32)
Constants ¶
const ( O_DIRECTORY = 1 << 29 O_NOFOLLOW = 1 << 30 )
See the comments on the same constants in open_file_windows.go
const ( // FakeEpochNanos is midnight UTC 2022-01-01 and exposed for testing FakeEpochNanos = 1640995200000 * ms )
Functions ¶
func CompilerSupported ¶
func CompilerSupported() bool
CompilerSupported is exported for tests and includes constraints here and also the assembler.
func FakeNanosleep ¶
func FakeNanosleep(int64)
FakeNanosleep implements sys.Nanosleep by returning without sleeping.
func FakeOsyield ¶
func FakeOsyield()
FakeOsyield implements sys.Osyield by returning without yielding.
func Fdatasync ¶
Fdatasync is like syscall.Fdatasync except that's only defined in linux. This returns syscall.ENOSYS when unimplemented.
func IsTerminal ¶
IsTerminal returns true if the given file descriptor is a terminal.
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 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 OpenFile ¶
func Rename ¶
func SanitizeSeparator ¶
func SanitizeSeparator([]byte)
SanitizeSeparator sanitizes the path separator in the given buffer. This does nothing on the non-windows platforms.
func Stat ¶
func Stat(f fs.File, t os.FileInfo) (atimeNsec, mtimeNsec, ctimeNsec int64, nlink, dev, inode uint64, err error)
Stat returns platform-specific values if os.FileInfo Sys is available.
func StatTimes ¶
StatTimes returns platform-specific values if os.FileInfo Sys is available. Otherwise, it returns the mod time for all values.
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.
Source Files ¶
buf_writer.go crypto.go mmap_unsupported.go open_file_js.go platform.go rename.go separator.go stat.go stat_unsupported.go sync.go sync_unsupported.go terminal_unsupported.go time.go time_cgo.go
- Version
- v1.0.0-pre.9
- Published
- Feb 17, 2023
- Platform
- js/wasm
- Imports
- 12 packages
- Last checked
- 6 hours ago –
Tools for package owners.