forked from tetratelabs/wazero
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wasi: add nonblock_test.go from gotip, fix nonblock read on Unix-like (…
…tetratelabs#1517) Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
- Loading branch information
Showing
7 changed files
with
259 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//go:build !unix && !linux && !darwin | ||
|
||
package sysfs | ||
|
||
import "syscall" | ||
|
||
const NonBlockingFileIoSupported = false | ||
|
||
// readFd returns ENOSYS on unsupported platforms. | ||
func readFd(fd uintptr, buf []byte) (int, syscall.Errno) { | ||
return -1, syscall.ENOSYS | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters