Debian Codegraph @

internal/sysfs/sock_unix.go

raw symbols SCIP
1 //go:build linux || darwin
2
3 package sysfs
4
5 import (
6 "net"
7 "syscall"
8
9 "github.com/tetratelabs/wazero/experimental/sys"
10 socketapi "github.com/tetratelabs/wazero/internal/sock"
11 )
12
13 // MSG_PEEK is the constant syscall.MSG_PEEK
14 const MSG_PEEK = syscall.MSG_PEEK
15
16 func newTCPListenerFile(tl *net.TCPListener) socketapi.TCPSock {
17 return newDefaultTCPListenerFile(tl)
18 }
19
20 func _pollSock(conn syscall.Conn, flag sys.Pflag, timeoutMillis int32) (bool, sys.Errno) {
21 n, errno := syscallConnControl(conn, func(fd uintptr) (int, sys.Errno) {
22 if ready, errno := poll(fd, sys.POLLIN, 0); !ready || errno != 0 {
23 return -1, errno
24 } else {
25 return 0, errno
26 }
27 })
28 return n >= 0, errno
29 }
30
31 func setNonblockSocket(fd uintptr, enabled bool) sys.Errno {
32 return sys.UnwrapOSError(setNonblock(fd, enabled))
33 }
34
35 func readSocket(fd uintptr, buf []byte) (int, sys.Errno) {
36 n, err := syscall.Read(int(fd), buf)
37 return n, sys.UnwrapOSError(err)
38 }
39
40 func writeSocket(fd uintptr, buf []byte) (int, sys.Errno) {
41 n, err := syscall.Write(int(fd), buf)
42 return n, sys.UnwrapOSError(err)
43 }
44
45 func recvfrom(fd uintptr, buf []byte, flags int32) (n int, errno sys.Errno) {
46 n, _, err := syscall.Recvfrom(int(fd), buf, int(flags))
47 return n, sys.UnwrapOSError(err)
48 }