github.com/apernet/sing-tun@v0.2.6-0.20240323130332-b9f6511036ad/internal/clashtcpip/tcpip_arm64.go (about)

     1  package clashtcpip
     2  
     3  import (
     4  	"unsafe"
     5  
     6  	"golang.org/x/sys/cpu"
     7  )
     8  
     9  //go:noescape
    10  func sumAsmNeon(data unsafe.Pointer, length uintptr) uintptr
    11  
    12  func SumNeon(data []byte) uint32 {
    13  	if len(data) == 0 {
    14  		return 0
    15  	}
    16  
    17  	return uint32(sumAsmNeon(unsafe.Pointer(&data[0]), uintptr(len(data))))
    18  }
    19  
    20  func init() {
    21  	if cpu.ARM64.HasASIMD {
    22  		SumFnc = SumNeon
    23  	}
    24  }