github.com/database64128/shadowsocks-go@v1.10.2-0.20240315062903-143a773533f1/conn/syscall_mmsg.go (about) 1 //go:build linux || netbsd 2 3 package conn 4 5 import ( 6 "syscall" 7 "unsafe" 8 9 "golang.org/x/sys/unix" 10 ) 11 12 func mmsgSyscall(trap uintptr, fd int, msgvec []Mmsghdr, flags int) (int, syscall.Errno) { 13 r0, _, e1 := unix.Syscall6(trap, uintptr(fd), uintptr(unsafe.Pointer(unsafe.SliceData(msgvec))), uintptr(len(msgvec)), uintptr(flags), 0, 0) 14 if e1 != 0 { 15 return 0, e1 16 } 17 return int(r0), 0 18 } 19 20 func recvmmsg(fd int, msgvec []Mmsghdr, flags int) (int, syscall.Errno) { 21 return mmsgSyscall(SYS_RECVMMSG, fd, msgvec, flags) 22 } 23 24 func sendmmsg(fd int, msgvec []Mmsghdr, flags int) (int, syscall.Errno) { 25 return mmsgSyscall(unix.SYS_SENDMMSG, fd, msgvec, flags) 26 }