updated vendor
This commit is contained in:
+62
-9
@@ -7,11 +7,10 @@ import (
|
||||
"time"
|
||||
|
||||
experimentalsys "github.com/tetratelabs/wazero/experimental/sys"
|
||||
"github.com/tetratelabs/wazero/internal/fsapi"
|
||||
"github.com/tetratelabs/wazero/sys"
|
||||
)
|
||||
|
||||
func NewStdioFile(stdin bool, f fs.File) (fsapi.File, error) {
|
||||
func NewStdioFile(stdin bool, f fs.File) (experimentalsys.File, error) {
|
||||
// Return constant stat, which has fake times, but keep the underlying
|
||||
// file mode. Fake times are needed to pass wasi-testsuite.
|
||||
// https://github.com/WebAssembly/wasi-testsuite/blob/af57727/tests/rust/src/bin/fd_filestat_get.rs#L1-L19
|
||||
@@ -27,7 +26,7 @@ func NewStdioFile(stdin bool, f fs.File) (fsapi.File, error) {
|
||||
} else {
|
||||
flag = experimentalsys.O_WRONLY
|
||||
}
|
||||
var file fsapi.File
|
||||
var file experimentalsys.File
|
||||
if of, ok := f.(*os.File); ok {
|
||||
// This is ok because functions that need path aren't used by stdioFile
|
||||
file = newOsFile("", flag, 0, of)
|
||||
@@ -63,10 +62,37 @@ func OpenFSFile(fs fs.FS, path string, flag experimentalsys.Oflag, perm fs.FileM
|
||||
}
|
||||
|
||||
type stdioFile struct {
|
||||
fsapi.File
|
||||
experimentalsys.File
|
||||
st sys.Stat_t
|
||||
}
|
||||
|
||||
// IsNonblock implements experimentalsys.PollableFile by forwarding to the
|
||||
// underlying file if it supports it.
|
||||
func (f *stdioFile) IsNonblock() bool {
|
||||
if pf, ok := f.File.(experimentalsys.PollableFile); ok {
|
||||
return pf.IsNonblock()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// SetNonblock implements experimentalsys.PollableFile by forwarding to the
|
||||
// underlying file if it supports it.
|
||||
func (f *stdioFile) SetNonblock(enable bool) experimentalsys.Errno {
|
||||
if pf, ok := f.File.(experimentalsys.PollableFile); ok {
|
||||
return pf.SetNonblock(enable)
|
||||
}
|
||||
return experimentalsys.ENOSYS
|
||||
}
|
||||
|
||||
// Poll implements experimentalsys.Pollable by forwarding to the underlying file
|
||||
// if it supports polling.
|
||||
func (f *stdioFile) Poll(flag experimentalsys.Pflag, timeoutMillis int32) (ready bool, errno experimentalsys.Errno) {
|
||||
if p, ok := f.File.(experimentalsys.Pollable); ok {
|
||||
return p.Poll(flag, timeoutMillis)
|
||||
}
|
||||
return false, experimentalsys.ENOSYS
|
||||
}
|
||||
|
||||
// SetAppend implements File.SetAppend
|
||||
func (f *stdioFile) SetAppend(bool) experimentalsys.Errno {
|
||||
// Ignore for stdio.
|
||||
@@ -341,18 +367,45 @@ func (f *fsFile) close() experimentalsys.Errno {
|
||||
return experimentalsys.UnwrapOSError(f.file.Close())
|
||||
}
|
||||
|
||||
// IsNonblock implements the same method as documented on fsapi.File
|
||||
// nonblocker is a subset of PollableFile for checking non-blocking mode on
|
||||
// an fs.File. fs.File cannot implement PollableFile due to conflicting Close
|
||||
// signatures (error vs Errno), so we use this narrower interface.
|
||||
type nonblocker interface {
|
||||
IsNonblock() bool
|
||||
SetNonblock(enable bool) experimentalsys.Errno
|
||||
}
|
||||
|
||||
// IsNonblock implements experimentalsys.PollableFile by forwarding to the
|
||||
// underlying fs.File if it supports it.
|
||||
func (f *fsFile) IsNonblock() bool {
|
||||
if nb, ok := f.file.(nonblocker); ok {
|
||||
return nb.IsNonblock()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// SetNonblock implements the same method as documented on fsapi.File
|
||||
func (f *fsFile) SetNonblock(bool) experimentalsys.Errno {
|
||||
// SetNonblock implements experimentalsys.PollableFile by forwarding to the
|
||||
// underlying fs.File if it supports it.
|
||||
func (f *fsFile) SetNonblock(enable bool) experimentalsys.Errno {
|
||||
if nb, ok := f.file.(nonblocker); ok {
|
||||
return nb.SetNonblock(enable)
|
||||
}
|
||||
if !enable {
|
||||
return 0 // disabling nonblock on a file that doesn't support it is a no-op
|
||||
}
|
||||
return experimentalsys.ENOSYS
|
||||
}
|
||||
|
||||
// Poll implements the same method as documented on fsapi.File
|
||||
func (f *fsFile) Poll(fsapi.Pflag, int32) (ready bool, errno experimentalsys.Errno) {
|
||||
// Poll implements experimentalsys.Pollable by forwarding to the underlying
|
||||
// fs.File if it supports polling.
|
||||
//
|
||||
// Note: fsFile cannot implement PollableFile because fs.File and
|
||||
// experimentalsys.File have conflicting Close signatures (error vs Errno),
|
||||
// so no type can satisfy both. Pollable has no such conflict.
|
||||
func (f *fsFile) Poll(flag experimentalsys.Pflag, timeoutMillis int32) (ready bool, errno experimentalsys.Errno) {
|
||||
if p, ok := f.file.(experimentalsys.Pollable); ok {
|
||||
return p.Poll(flag, timeoutMillis)
|
||||
}
|
||||
return false, experimentalsys.ENOSYS
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user