github.com/min1324/cmap@v1.0.3-0.20220418125848-74e72bbe3be4/hash.go (about)

     1  package cmap
     2  
     3  import "unsafe"
     4  
     5  func chash(i interface{}) uintptr {
     6  	return nilinterhash(noescape(unsafe.Pointer(&i)), 0xdeadbeef)
     7  }
     8  
     9  // in runtime/alg.go
    10  //
    11  //go:linkname nilinterhash runtime.nilinterhash
    12  func nilinterhash(p unsafe.Pointer, h uintptr) uintptr
    13  
    14  //go:nocheckptr
    15  //go:nosplit
    16  func noescape(p unsafe.Pointer) unsafe.Pointer {
    17  	x := uintptr(p)
    18  	return unsafe.Pointer(x ^ 0)
    19  }