From ef9217e7bd9c854e4f8d2d79ff8aec550130cbc4 Mon Sep 17 00:00:00 2001 From: Richard Musiol Date: Sun, 4 Mar 2018 12:18:32 +0100 Subject: net: add js/wasm architecture This commit adds the js/wasm architecture to the net package. The net package is not supported by js/wasm, but a simple fake networking is available so tests of other packages that require basic TCP sockets can pass. The tests of the net package itself are mostly disabled. Updates #18892 Change-Id: Id287200c39f0a3e23d20ef17260ca15ccdcca032 Reviewed-on: https://go-review.googlesource.com/109995 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/runtime/netpoll.go | 2 +- src/runtime/netpoll_fake.go | 32 ++++++++++++++++++++++++++++++++ src/runtime/netpoll_nacl.go | 30 ------------------------------ 3 files changed, 33 insertions(+), 31 deletions(-) create mode 100644 src/runtime/netpoll_fake.go delete mode 100644 src/runtime/netpoll_nacl.go (limited to 'src/runtime') diff --git a/src/runtime/netpoll.go b/src/runtime/netpoll.go index efcd2b855c..c8fb95d3aa 100644 --- a/src/runtime/netpoll.go +++ b/src/runtime/netpoll.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows +// +build darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris windows package runtime diff --git a/src/runtime/netpoll_fake.go b/src/runtime/netpoll_fake.go new file mode 100644 index 0000000000..aab18dc846 --- /dev/null +++ b/src/runtime/netpoll_fake.go @@ -0,0 +1,32 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Fake network poller for NaCl and wasm/js. +// Should never be used, because NaCl and wasm/js network connections do not honor "SetNonblock". + +// +build nacl js,wasm + +package runtime + +func netpollinit() { +} + +func netpolldescriptor() uintptr { + return ^uintptr(0) +} + +func netpollopen(fd uintptr, pd *pollDesc) int32 { + return 0 +} + +func netpollclose(fd uintptr) int32 { + return 0 +} + +func netpollarm(pd *pollDesc, mode int) { +} + +func netpoll(block bool) *g { + return nil +} diff --git a/src/runtime/netpoll_nacl.go b/src/runtime/netpoll_nacl.go deleted file mode 100644 index dc5a55ec84..0000000000 --- a/src/runtime/netpoll_nacl.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Fake network poller for NaCl. -// Should never be used, because NaCl network connections do not honor "SetNonblock". - -package runtime - -func netpollinit() { -} - -func netpolldescriptor() uintptr { - return ^uintptr(0) -} - -func netpollopen(fd uintptr, pd *pollDesc) int32 { - return 0 -} - -func netpollclose(fd uintptr) int32 { - return 0 -} - -func netpollarm(pd *pollDesc, mode int) { -} - -func netpoll(block bool) *g { - return nil -} -- cgit v1.3