Files
wazero/internal/sysfs/file_unix.go
Edoardo Vacchi b01ba67fdc
Some checks failed
Release CLI / Pre-release build (push) Has been cancelled
Release CLI / Pre-release test (macos-12) (push) Has been cancelled
Release CLI / Pre-release test (ubuntu-22.04) (push) Has been cancelled
Release CLI / Pre-release test (windows-2022) (push) Has been cancelled
Release CLI / Release (push) Has been cancelled
wasi: add nonblock_test.go from gotip, fix nonblock read on Unix-like (#1517)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-06-15 07:08:44 +08:00

22 lines
420 B
Go

//go:build unix || darwin || linux
package sysfs
import (
"syscall"
"github.com/tetratelabs/wazero/internal/platform"
)
const NonBlockingFileIoSupported = true
// readFd exposes syscall.Read.
func readFd(fd uintptr, buf []byte) (int, syscall.Errno) {
if len(buf) == 0 {
return 0, 0 // Short-circuit 0-len reads.
}
n, err := syscall.Read(int(fd), buf)
errno := platform.UnwrapOSError(err)
return n, errno
}