-
Notifications
You must be signed in to change notification settings - Fork 920
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
syscall: populate wasiStreams map with stdin/stdout/stderr
- Loading branch information
Showing
1 changed file
with
28 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,10 +103,36 @@ var nextLibcFd = int32(Stderr) + 1 | |
var wasiErrno error | ||
|
||
func init() { | ||
// TODO(dgryski): pre-populate with stdin/stdout/stderr | ||
wasiStreams = make(map[int32]*wasiFile) | ||
wasiStreams = map[int32]*wasiFile{ | ||
Stdin: &wasiFile{ | ||
d: -1, | ||
in: __wasi_cli_stdout_get_stdin(), | ||
out: -1, | ||
}, | ||
|
||
Stdout: &wasiFile{ | ||
d: -1, | ||
in: -1, | ||
out: __wasi_cli_stdout_get_stdout(), | ||
}, | ||
|
||
Stderr: &wasiFile{ | ||
d: -1, | ||
in: -1, | ||
out: __wasi_cli_stdout_get_stderr(), | ||
}, | ||
} | ||
} | ||
|
||
//go:wasmimport wasi:cli/[email protected] get-stdin | ||
func __wasi_cli_stdout_get_stdin() __wasi_io_streams_input_stream | ||
|
||
//go:wasmimport wasi:cli/[email protected] get-stdout | ||
func __wasi_cli_stdout_get_stdout() __wasi_io_streams_output_stream | ||
|
||
//go:wasmimport wasi:cli/[email protected] get-stderr | ||
func __wasi_cli_stdout_get_stderr() __wasi_io_streams_output_stream | ||
|
||
// ssize_t read(int fd, void *buf, size_t count); | ||
// | ||
//go:export read | ||
|