Debian Codegraph @

internal/sysfs/sock_unsupported.go

raw symbols SCIP
1 //go:build !(linux || darwin || windows)
2
3 package sysfs
4
5 import (
6 "net"
7 "syscall"
8
9 experimentalsys "github.com/tetratelabs/wazero/experimental/sys"
10 socketapi "github.com/tetratelabs/wazero/internal/sock"
11 )
12
13 // MSG_PEEK is a filler value.
14 const MSG_PEEK = 0x2
15
16 func newTCPListenerFile(tl *net.TCPListener) socketapi.TCPSock {
17 return &unsupportedSockFile{}
18 }
19
20 type unsupportedSockFile struct {
21 baseSockFile
22 }
23
24 // Accept implements the same method as documented on socketapi.TCPSock
25 func (f *unsupportedSockFile) Accept() (socketapi.TCPConn, experimentalsys.Errno) {
26 return nil, experimentalsys.ENOSYS
27 }
28
29 func _pollSock(conn syscall.Conn, flag experimentalsys.Pflag, timeoutMillis int32) (bool, experimentalsys.Errno) {
30 return false, experimentalsys.ENOTSUP
31 }
32
33 func setNonblockSocket(fd uintptr, enabled bool) experimentalsys.Errno {
34 return experimentalsys.ENOTSUP
35 }
36
37 func readSocket(fd uintptr, buf []byte) (int, experimentalsys.Errno) {
38 return -1, experimentalsys.ENOTSUP
39 }
40
41 func writeSocket(fd uintptr, buf []byte) (int, experimentalsys.Errno) {
42 return -1, experimentalsys.ENOTSUP
43 }
44
45 func recvfrom(fd uintptr, buf []byte, flags int32) (n int, errno experimentalsys.Errno) {
46 return -1, experimentalsys.ENOTSUP
47 }
48
49 // syscallConnControl extracts a syscall.RawConn from the given syscall.Conn and applies
50 // the given fn to a file descriptor, returning an integer or a nonzero syscall.Errno on failure.
51 //
52 // syscallConnControl streamlines the pattern of extracting the syscall.Rawconn,
53 // invoking its syscall.RawConn.Control method, then handling properly the errors that may occur
54 // within fn or returned by syscall.RawConn.Control itself.
55 func syscallConnControl(conn syscall.Conn, fn func(fd uintptr) (int, experimentalsys.Errno)) (n int, errno experimentalsys.Errno) {
56 return -1, experimentalsys.ENOTSUP
57 }
58
59 // Accept implements the same method as documented on socketapi.TCPSock
60 func (f *tcpListenerFile) Accept() (socketapi.TCPConn, experimentalsys.Errno) {
61 return nil, experimentalsys.ENOSYS
62 }
63
64 // Shutdown implements the same method as documented on experimentalsys.Conn
65 func (f *tcpConnFile) Shutdown(how int) experimentalsys.Errno {
66 // FIXME: can userland shutdown listeners?
67 var err error
68 switch how {
69 case socketapi.SHUT_RD:
70 err = f.tc.Close()
71 case socketapi.SHUT_WR:
72 err = f.tc.Close()
73 case socketapi.SHUT_RDWR:
74 return f.close()
75 default:
76 return experimentalsys.EINVAL
77 }
78 return experimentalsys.UnwrapOSError(err)
79 }