Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compiler/natives/src/internal/poll: Create no-op I/O poller implement…
…ation. gopherjs test uses tempFile to create temporary files during execution of examples. tempFile calls os.OpenFile to create a file. os.OpenFile calls newFile, which in Go 1.9 tries to add the file to the runtime poller. Normally, on OSes like darwin, linux, etc., this tries to use a real runtime poller from internal/poll package. We override that package so that a no-op implementation (based on NaCL implementation) is used instead. Fixes: Error: runtime error: native function not implemented: internal/poll.runtime_pollServerInit After this change, some basic tests pass: $ gopherjs test errors github.com/gopherjs/gopherjs/tests PASS ok errors 0.453s PASS ok github.com/gopherjs/gopherjs/tests 0.606s
- Loading branch information
Showing
2 changed files
with
72 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// +build js | ||
|
||
package poll | ||
|
||
import "time" | ||
|
||
// pollDesc is a no-op implementation of an I/O poller for GOARCH=js. | ||
type pollDesc struct { | ||
closing bool | ||
} | ||
|
||
func (pd *pollDesc) init(fd *FD) error { return nil } | ||
|
||
func (pd *pollDesc) close() {} | ||
|
||
func (pd *pollDesc) evict() { pd.closing = true } | ||
|
||
func (pd *pollDesc) prepare(mode int, isFile bool) error { | ||
if pd.closing { | ||
return errClosing(isFile) | ||
} | ||
return nil | ||
} | ||
|
||
func (pd *pollDesc) prepareRead(isFile bool) error { return pd.prepare('r', isFile) } | ||
|
||
func (pd *pollDesc) prepareWrite(isFile bool) error { return pd.prepare('w', isFile) } | ||
|
||
func (pd *pollDesc) wait(mode int, isFile bool) error { | ||
if pd.closing { | ||
return errClosing(isFile) | ||
} | ||
return ErrTimeout | ||
} | ||
|
||
func (pd *pollDesc) waitRead(isFile bool) error { return pd.wait('r', isFile) } | ||
|
||
func (pd *pollDesc) waitWrite(isFile bool) error { return pd.wait('w', isFile) } | ||
|
||
func (*pollDesc) waitCanceled(mode int) {} | ||
|
||
func (*FD) SetDeadline(t time.Time) error { return nil } | ||
|
||
func (*FD) SetReadDeadline(t time.Time) error { return nil } | ||
|
||
func (*FD) SetWriteDeadline(t time.Time) error { return nil } | ||
|
||
// PollDescriptor returns the descriptor being used by the poller, | ||
// or ^uintptr(0) if there isn't one. This is only used for testing. | ||
func PollDescriptor() uintptr { | ||
return ^uintptr(0) | ||
} |