Files
wazero/internal/sysfs/select_linux.go
Crypt Keeper 180ff682d9 sysfs: changes PollRead to accept int32 timeoutMillis (#1597)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Co-authored-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-07-28 10:01:00 +08:00

20 lines
525 B
Go

package sysfs
import (
"syscall"
"github.com/tetratelabs/wazero/experimental/sys"
"github.com/tetratelabs/wazero/internal/platform"
)
// syscall_select implements _select on Linux
func syscall_select(n int, r, w, e *platform.FdSet, timeoutNanos int32) (bool, sys.Errno) {
var t *syscall.Timeval
if timeoutNanos >= 0 {
tv := syscall.NsecToTimeval(int64(timeoutNanos))
t = &tv
}
n, err := syscall.Select(n, (*syscall.FdSet)(r), (*syscall.FdSet)(w), (*syscall.FdSet)(e), t)
return n > 0, sys.UnwrapOSError(err)
}