-
Notifications
You must be signed in to change notification settings - Fork 967
net: enable native golang linux networking #4498
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
base: dev
Are you sure you want to change the base?
Changes from 1 commit
baf7e4f
329fef6
3c34bbd
facd62e
90532f1
8224b0e
82f1b96
46394c1
42348c8
a695ab6
a39597c
2e04cc2
da0f694
c16ff80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Signed-off-by: leongross <leon.gross@9elements.com>
- Loading branch information
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2024 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. | ||
|
||
package runtime | ||
|
||
// For debugging purposes this is used for all target architectures, but this is only valid for linux systems. | ||
// TODO: add linux specific build tags | ||
type pollDesc struct { | ||
runtimeCtx uintptr | ||
} | ||
|
||
func (pd *pollDesc) wait(mode int, isFile bool) error { | ||
return nil | ||
} | ||
|
||
const ( | ||
pollNoError = 0 // no error | ||
pollErrClosing = 1 // descriptor is closed | ||
pollErrTimeout = 2 // I/O timeout | ||
pollErrNotPollable = 3 // general error polling descriptor | ||
) | ||
|
||
//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 pollNoError | ||
} | ||
|
||
//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 pollNoError | ||
} | ||
|
||
//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) | ||
} | ||
|
||
//go:linkname poll_runtime_pollOpen internal/poll.runtime_pollOpen | ||
func poll_runtime_pollOpen(fd uintptr) (*pollDesc, int) { | ||
println("poll_runtime_pollOpen not implemented", fd) | ||
return &pollDesc{runtimeCtx: 0x13371337}, pollNoError | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2024 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. | ||
|
||
8000 //go:build (js && wasm) || wasip1 || windows | ||
|
||
package runtime | ||
|
||
// Network poller descriptor. | ||
// | ||
// No heap pointers. | ||
// For linux to call create Fds with a pollDesc, it needs a ctxRuntime pointer, so use the original pollDesc struct. | ||
// On linux we have a heap. | ||
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 | ||
leongross marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
//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) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,20 +4,21 @@ package runtime | |
|
||
//go:linkname poll_runtime_pollServerInit internal/poll.runtime_pollServerInit | ||
func poll_runtime_pollServerInit() { | ||
panic("todo: runtime_pollServerInit") | ||
// fmt.Printf("poll_runtime_pollServerInit not implemented, skipping panic\n") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you put in debugging code, please remove it before sending in a PR. It makes the diff bigger and more work to review. |
||
} | ||
|
||
//go:linkname poll_runtime_pollOpen internal/poll.runtime_pollOpen | ||
func poll_runtime_pollOpen(fd uintptr) (uintptr, int) { | ||
panic("todo: runtime_pollOpen") | ||
} | ||
// //go:linkname poll_runtime_pollOpen internal/poll.runtime_pollOpen | ||
// func poll_runtime_pollOpen(fd uintptr) (uintptr, int) { | ||
// // fmt.Printf("poll_runtime_pollOpen not implemented, skipping panic\n") | ||
// return 0, 0 | ||
// } | ||
|
||
//go:linkname poll_runtime_pollClose internal/poll.runtime_pollClose | ||
func poll_runtime_pollClose(ctx uintptr) { | ||
// fmt.Printf("poll_runtime_pollClose not implemented, skipping panic\n") | ||
} | ||
|
||
//go:linkname poll_runtime_pollUnblock internal/poll.runtime_pollUnblock | ||
func poll_runtime_pollUnblock(ctx uintptr) { | ||
panic("todo: runtime_pollUnblock") | ||
// fmt.Printf("poll_runtime_pollUnblock not implemented, skipping panic\n") | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//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{} |
Uh oh!
There was an error while loading. Please reload this page.