github.com/jxskiss/gopkg@v0.17.3/internal/linkname/go_118.go (about)

     1  //go:build go1.18
     2  // +build go1.18
     3  
     4  package linkname
     5  
     6  import (
     7  	"reflect"
     8  	"unsafe"
     9  )
    10  
    11  func init() {
    12  	mapIterTyp := reflect.TypeOf(reflect.MapIter{})
    13  	hiterField, ok := mapIterTyp.FieldByName("hiter")
    14  	if !ok {
    15  		panic("reflect.MapIter field iter not found")
    16  	}
    17  	hiterType = toRType(hiterField.Type)
    18  }
    19  
    20  var hiterType unsafe.Pointer // *reflect.rtype
    21  
    22  func Reflect_mapiterinit(rtype unsafe.Pointer, m unsafe.Pointer) unsafe.Pointer {
    23  	hiter := Reflect_unsafe_New(hiterType)
    24  	reflect_mapiterinit(rtype, m, hiter)
    25  	return hiter
    26  }
    27  
    28  // reflect_mapiterinit .
    29  // m escapes into the return value, but the caller of Reflect_mapiterinit
    30  // doesn't let the return value escape.
    31  //go:noescape
    32  //go:linkname reflect_mapiterinit reflect.mapiterinit
    33  func reflect_mapiterinit(rtype unsafe.Pointer, m unsafe.Pointer, hiter unsafe.Pointer)