github.com/iceber/iouring-go@v0.0.0-20230403020409-002cfd2e2a90/utils.go (about) 1 // +build linux 2 3 package iouring 4 5 import ( 6 "syscall" 7 "unsafe" 8 ) 9 10 var zero uintptr 11 12 func bytes2iovec(bs [][]byte) []syscall.Iovec { 13 iovecs := make([]syscall.Iovec, len(bs)) 14 for i, b := range bs { 15 iovecs[i].SetLen(len(b)) 16 if len(b) > 0 { 17 iovecs[i].Base = &b[0] 18 } else { 19 iovecs[i].Base = (*byte)(unsafe.Pointer(&zero)) 20 } 21 } 22 return iovecs 23 } 24 25 //go:linkname sockaddr syscall.Sockaddr.sockaddr 26 func sockaddr(addr syscall.Sockaddr) (unsafe.Pointer, uint32, error) 27 28 //go:linkname anyToSockaddr syscall.anyToSockaddr 29 func anyToSockaddr(rsa *syscall.RawSockaddrAny) (syscall.Sockaddr, error)