Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: rebase work of PR#4273 #4442

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 27 additions & 31 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,44 +1,40 @@
[submodule "lib/nrfx"]
path = lib/nrfx
url = https://github.com/NordicSemiconductor/nrfx.git
path = lib/nrfx
url = https://github.com/NordicSemiconductor/nrfx.git
[submodule "lib/CMSIS"]
path = lib/CMSIS
url = https://github.com/ARM-software/CMSIS.git
path = lib/CMSIS
url = https://github.com/ARM-software/CMSIS.git
[submodule "lib/avr"]
path = lib/avr
url = https://github.com/avr-rust/avr-mcu.git
path = lib/avr
url = https://github.com/avr-rust/avr-mcu.git
[submodule "lib/cmsis-svd"]
path = lib/cmsis-svd
url = https://github.com/cmsis-svd/cmsis-svd-data.git
branch = main
path = lib/cmsis-svd
url = https://github.com/cmsis-svd/cmsis-svd-data.git
branch = main
[submodule "lib/wasi-libc"]
path = lib/wasi-libc
url = https://github.com/WebAssembly/wasi-libc
path = lib/wasi-libc
url = https://github.com/WebAssembly/wasi-libc
[submodule "lib/picolibc"]
path = lib/picolibc
url = https://github.com/keith-packard/picolibc.git
path = lib/picolibc
url = https://github.com/keith-packard/picolibc.git
[submodule "lib/stm32-svd"]
path = lib/stm32-svd
url = https://github.com/tinygo-org/stm32-svd
path = lib/stm32-svd
url = https://github.com/tinygo-org/stm32-svd
[submodule "lib/musl"]
path = lib/musl
url = git://git.musl-libc.org/musl
path = lib/musl
url = git://git.musl-libc.org/musl
[submodule "lib/binaryen"]
path = lib/binaryen
url = https://github.com/WebAssembly/binaryen.git
path = lib/binaryen
url = https://github.com/WebAssembly/binaryen.git
[submodule "lib/mingw-w64"]
path = lib/mingw-w64
url = https://github.com/mingw-w64/mingw-w64.git
path = lib/mingw-w64
url = https://github.com/mingw-w64/mingw-w64.git
[submodule "lib/macos-minimal-sdk"]
path = lib/macos-minimal-sdk
url = https://github.com/aykevl/macos-minimal-sdk.git
path = lib/macos-minimal-sdk
url = https://github.com/aykevl/macos-minimal-sdk.git
[submodule "lib/renesas-svd"]
path = lib/renesas-svd
url = https://github.com/tinygo-org/renesas-svd.git
[submodule "src/net"]
path = src/net
url = https://github.com/tinygo-org/net.git
branch = dev
path = lib/renesas-svd
url = https://github.com/tinygo-org/renesas-svd.git
[submodule "lib/wasi-cli"]
path = lib/wasi-cli
url = https://github.com/WebAssembly/wasi-cli
path = lib/wasi-cli
url = https://github.com/WebAssembly/wasi-cli
17 changes: 8 additions & 9 deletions loader/goroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ func pathsToOverride(goMinor int, needsSyscallPackage bool) map[string]bool {
"": true,
"crypto/": true,
"crypto/rand/": false,
"crypto/tls/": false,
"device/": false,
"examples/": false,
"internal/": true,
Expand All @@ -245,14 +244,14 @@ func pathsToOverride(goMinor int, needsSyscallPackage bool) map[string]bool {
"internal/task/": false,
"internal/wasi/": false,
"machine/": false,
"net/": true,
"net/http/": false,
"os/": true,
"reflect/": false,
"runtime/": false,
"sync/": true,
"testing/": true,
"unique/": false,
// "net/": true,
// "net/http/": false,
"os/": true,
"reflect/": false,
"runtime/": false,
"sync/": true,
"testing/": true,
"unique/": false,
}

if goMinor >= 19 {
Expand Down
16 changes: 0 additions & 16 deletions src/crypto/tls/ticket.go

This file was deleted.

30 changes: 30 additions & 0 deletions src/runtime/netpoll.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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.

//go:build unix || (js && wasm) || wasip1 || windows

package runtime

// Network poller descriptor.
//
// No heap pointers.
type pollDesc struct {
}

//go:linkname poll_runtime_pollReset internal/poll.runtime_pollReset
func poll_runtime_pollReset(pd *pollDesc, mode int) int {
println("poll_runtime_pollReset not implemented", pd, mode)
return -1
}

//go:linkname poll_runtime_pollWait internal/poll.runtime_pollWait
func poll_runtime_pollWait(pd *pollDesc, mode int) int {
println("poll_runtime_pollWait not implemented", pd, mode)
return -1
}

//go:linkname poll_runtime_pollSetDeadline internal/poll.runtime_pollSetDeadline
func poll_runtime_pollSetDeadline(pd *pollDesc, d int64, mode int) {
println("poll_runtime_pollSetDeadline not implemented", pd, d, mode)
}
7 changes: 5 additions & 2 deletions src/runtime/poll.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ package runtime

//go:linkname poll_runtime_pollServerInit internal/poll.runtime_pollServerInit
func poll_runtime_pollServerInit() {
panic("todo: runtime_pollServerInit")
// TODO the "net" pkg calls this, so panic() isn't an option. Right
// now, just ignore the call.
}

//go:linkname poll_runtime_pollOpen internal/poll.runtime_pollOpen
func poll_runtime_pollOpen(fd uintptr) (uintptr, int) {
panic("todo: runtime_pollOpen")
// TODO the "net" pkg calls this, so panic() isn't an option. Right
// now, just ignore the call.
return 0, 0
}

//go:linkname poll_runtime_pollClose internal/poll.runtime_pollClose
Expand Down
11 changes: 11 additions & 0 deletions src/runtime/proc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package runtime

// Called from syscall package before Exec.
//
//go:linkname syscall_runtime_BeforeExec syscall.runtime_BeforeExec
func syscall_runtime_BeforeExec() {}

// Called from syscall package after Exec.
//
//go:linkname syscall_runtime_AfterExec syscall.runtime_AfterExec
func syscall_runtime_AfterExec() {}
6 changes: 4 additions & 2 deletions src/runtime/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ package runtime

//go:linkname semacquire internal/poll.runtime_Semacquire
func semacquire(sema *uint32) {
panic("todo: semacquire")
// TODO the "net" pkg calls this, so panic() isn't an option. Right
// now, just ignore the call.
}

//go:linkname semrelease internal/poll.runtime_Semrelease
func semrelease(sema *uint32) {
panic("todo: semrelease")
// TODO the "net" pkg calls this, so panic() isn't an option. Right
// now, just ignore the call.
}
31 changes: 31 additions & 0 deletions src/syscall/env_tinygo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//go:build tinygo

package syscall

func Unsetenv(key string) error {
println("syscall.Unsetenv not implemented", key)
return EOPNOTSUPP
}

func Getenv(key string) (value string, found bool) {
println("syscall.Getenv not implemented", key)
return value, false
}

func Setenv(key, value string) error {
println("syscall.Setenv not implemented", key, value)
return EOPNOTSUPP
}

func Clearenv() {
println("syscall.Clearenv not implemented")
}

func runtime_envs() []string

func Environ() []string {
env := runtime_envs()
envCopy := make([]string, len(env))
copy(envCopy, env)
return envCopy
}
39 changes: 39 additions & 0 deletions src/syscall/exec_tinygo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//go:build tinygo

package syscall

// This is the original ForkLock:
//
// var ForkLock sync.RWMutex
//
// This requires importing sync, but importing sync causes an import loop:
//
// package tinygo.org/x/drivers/examples/net/tcpclient
// imports bytes
// imports io
// imports sync
// imports internal/task
// imports runtime/interrupt
// imports device/arm
// imports syscall
// imports sync: import cycle not allowed
//
// So for now, make our own stubbed-out ForkLock that doesn't use sync..

type forklock struct{}

func (f forklock) RLock() {}
func (f forklock) RUnlock() {}

var ForkLock forklock

func CloseOnExec(fd int) {
system.CloseOnExec(fd)
}

func SetNonblock(fd int, nonblocking bool) (err error) {
return system.SetNonblock(fd, nonblocking)
}

type SysProcAttr struct {
}
47 changes: 47 additions & 0 deletions src/syscall/fs_tinygo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//go:build tinygo

package syscall

func Seek(fd int, offset int64, whence int) (int64, error) {
println("syscall.Seek not implemented", fd, offset, whence)
return 0, ENOSYS
}

func Close(fd int) error {
return system.Close(fd)
}

func Fsync(fd int) error {
println("syscall.Fsync not implemented", fd)
return ENOSYS
}

func Fchmod(fd int, mode uint32) error {
println("syscall.Fchmod not implemented", fd, mode)
return ENOSYS
}

func Fchown(fd int, uid, gid int) error {
println("syscall.Fchown not implemented", fd, uid, gid)
return ENOSYS
}

func Ftruncate(fd int, length int64) error {
println("syscall.Ftruncate not implemented", fd, length)
return ENOSYS
}

func Fstat(fd int, st *Stat_t) error {
println("syscall.Fstat not implemented", fd, st)
return ENOSYS
}

func Dup(fd int) (int, error) {
println("syscall.Dup not implemented", fd)
return 0, ENOSYS
}

func Fchdir(fd int) error {
println("syscall.Fchdir not implemented", fd)
return ENOSYS
}
18 changes: 18 additions & 0 deletions src/syscall/net_tinygo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//go:build tinygo

package syscall

func Listen(fd int, backlog int) error {
println("syscall.Listen not implemented", fd, backlog)
return ENOSYS
}

func Accept(fd int) (int, Sockaddr, error) {
println("syscall.Accept not implemented", fd)
return 0, nil, ENOSYS
}

func Shutdown(fd int, how int) error {
println("syscall.Shutdown", fd, how)
return ENOSYS
}
52 changes: 52 additions & 0 deletions src/syscall/netlink_tinygo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//go:build tinygo

package syscall

// This is (mostly) a copy of src/syscall/netlink_linux.go. netlink_linux.go
// imports "sync", but that causes an import cycle:
//
// package tinygo.org/x/drivers/examples/net/tcpclient
// imports bytes
// imports io
// imports sync
// imports internal/task
// imports runtime/interrupt
// imports device/arm
// imports syscall
// imports sync: import cycle not allowed
//
// So until we can solve the import cycle, stub out things.

// NetlinkMessage represents a netlink message.
type NetlinkMessage struct {
Header NlMsghdr
Data []byte
}

// NetlinkRouteAttr represents a netlink route attribute.
type NetlinkRouteAttr struct {
Attr RtAttr
Value []byte
}

// NetlinkRIB returns routing information base, as known as RIB, which
// consists of network facility information, states and parameters.
func NetlinkRIB(proto, family int) ([]byte, error) {
println("syscall.NetlinkRIB not implemented", proto, family)
return []byte{}, EOPNOTSUPP
}

// ParseNetlinkMessage parses b as an array of netlink messages and
// returns the slice containing the NetlinkMessage structures.
func ParseNetlinkMessage(b []byte) ([]NetlinkMessage, error) {
println("syscall.ParseNetlinkMessage not implemented", b)
return []NetlinkMessage{}, EOPNOTSUPP
}

// ParseNetlinkRouteAttr parses m's payload as an array of netlink
// route attributes and returns the slice containing the
// NetlinkRouteAttr structures.
func ParseNetlinkRouteAttr(m *NetlinkMessage) ([]NetlinkRouteAttr, error) {
println("syscall.ParseNetlinkRouteAttr not implemented", m)
return []NetlinkRouteAttr{}, EOPNOTSUPP
}
Loading
Loading