github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/net/internal/socket/sys_linux_386.go (about)

     1  // Copyright 2017 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package socket
     6  
     7  import (
     8  	"syscall"
     9  	"unsafe"
    10  )
    11  
    12  const (
    13  	sysRECVMMSG = 0x13
    14  	sysSENDMMSG = 0x14
    15  )
    16  
    17  func socketcall(call, a0, a1, a2, a3, a4, a5 uintptr) (uintptr, syscall.Errno)
    18  func rawsocketcall(call, a0, a1, a2, a3, a4, a5 uintptr) (uintptr, syscall.Errno)
    19  
    20  func recvmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
    21  	n, errno := socketcall(sysRECVMMSG, s, uintptr(unsafe.Pointer(&hs[0])), uintptr(len(hs)), uintptr(flags), 0, 0)
    22  	return int(n), errnoErr(errno)
    23  }
    24  
    25  func sendmmsg(s uintptr, hs []mmsghdr, flags int) (int, error) {
    26  	n, errno := socketcall(sysSENDMMSG, s, uintptr(unsafe.Pointer(&hs[0])), uintptr(len(hs)), uintptr(flags), 0, 0)
    27  	return int(n), errnoErr(errno)
    28  }