mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[experiment] add alternative wasm sqlite3 implementation available via build-tag (#2863)
This allows for building GoToSocial with [SQLite transpiled to WASM](https://github.com/ncruces/go-sqlite3) and accessed through [Wazero](https://wazero.io/).
This commit is contained in:
49
vendor/github.com/tetratelabs/wazero/internal/sysfs/sock_unix.go
generated
vendored
Normal file
49
vendor/github.com/tetratelabs/wazero/internal/sysfs/sock_unix.go
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
//go:build (linux || darwin) && !tinygo
|
||||
|
||||
package sysfs
|
||||
|
||||
import (
|
||||
"net"
|
||||
"syscall"
|
||||
|
||||
"github.com/tetratelabs/wazero/experimental/sys"
|
||||
"github.com/tetratelabs/wazero/internal/fsapi"
|
||||
socketapi "github.com/tetratelabs/wazero/internal/sock"
|
||||
)
|
||||
|
||||
// MSG_PEEK is the constant syscall.MSG_PEEK
|
||||
const MSG_PEEK = syscall.MSG_PEEK
|
||||
|
||||
func newTCPListenerFile(tl *net.TCPListener) socketapi.TCPSock {
|
||||
return newDefaultTCPListenerFile(tl)
|
||||
}
|
||||
|
||||
func _pollSock(conn syscall.Conn, flag fsapi.Pflag, timeoutMillis int32) (bool, sys.Errno) {
|
||||
n, errno := syscallConnControl(conn, func(fd uintptr) (int, sys.Errno) {
|
||||
if ready, errno := poll(fd, fsapi.POLLIN, 0); !ready || errno != 0 {
|
||||
return -1, errno
|
||||
} else {
|
||||
return 0, errno
|
||||
}
|
||||
})
|
||||
return n >= 0, errno
|
||||
}
|
||||
|
||||
func setNonblockSocket(fd uintptr, enabled bool) sys.Errno {
|
||||
return sys.UnwrapOSError(setNonblock(fd, enabled))
|
||||
}
|
||||
|
||||
func readSocket(fd uintptr, buf []byte) (int, sys.Errno) {
|
||||
n, err := syscall.Read(int(fd), buf)
|
||||
return n, sys.UnwrapOSError(err)
|
||||
}
|
||||
|
||||
func writeSocket(fd uintptr, buf []byte) (int, sys.Errno) {
|
||||
n, err := syscall.Write(int(fd), buf)
|
||||
return n, sys.UnwrapOSError(err)
|
||||
}
|
||||
|
||||
func recvfrom(fd uintptr, buf []byte, flags int32) (n int, errno sys.Errno) {
|
||||
n, _, err := syscall.Recvfrom(int(fd), buf, int(flags))
|
||||
return n, sys.UnwrapOSError(err)
|
||||
}
|
Reference in New Issue
Block a user