aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/modern-go/reflect2/unsafe_link.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/modern-go/reflect2/unsafe_link.go')
-rw-r--r--vendor/github.com/modern-go/reflect2/unsafe_link.go76
1 files changed, 76 insertions, 0 deletions
diff --git a/vendor/github.com/modern-go/reflect2/unsafe_link.go b/vendor/github.com/modern-go/reflect2/unsafe_link.go
new file mode 100644
index 0000000..b49f614
--- /dev/null
+++ b/vendor/github.com/modern-go/reflect2/unsafe_link.go
@@ -0,0 +1,76 @@
1package reflect2
2
3import "unsafe"
4
5//go:linkname unsafe_New reflect.unsafe_New
6func unsafe_New(rtype unsafe.Pointer) unsafe.Pointer
7
8//go:linkname typedmemmove reflect.typedmemmove
9func typedmemmove(rtype unsafe.Pointer, dst, src unsafe.Pointer)
10
11//go:linkname unsafe_NewArray reflect.unsafe_NewArray
12func unsafe_NewArray(rtype unsafe.Pointer, length int) unsafe.Pointer
13
14// typedslicecopy copies a slice of elemType values from src to dst,
15// returning the number of elements copied.
16//go:linkname typedslicecopy reflect.typedslicecopy
17//go:noescape
18func typedslicecopy(elemType unsafe.Pointer, dst, src sliceHeader) int
19
20//go:linkname mapassign reflect.mapassign
21//go:noescape
22func mapassign(rtype unsafe.Pointer, m unsafe.Pointer, key unsafe.Pointer, val unsafe.Pointer)
23
24//go:linkname mapaccess reflect.mapaccess
25//go:noescape
26func mapaccess(rtype unsafe.Pointer, m unsafe.Pointer, key unsafe.Pointer) (val unsafe.Pointer)
27
28//go:noescape
29//go:linkname mapiternext reflect.mapiternext
30func mapiternext(it *hiter)
31
32//go:linkname ifaceE2I reflect.ifaceE2I
33func ifaceE2I(rtype unsafe.Pointer, src interface{}, dst unsafe.Pointer)
34
35// A hash iteration structure.
36// If you modify hiter, also change cmd/internal/gc/reflect.go to indicate
37// the layout of this structure.
38type hiter struct {
39 key unsafe.Pointer
40 value unsafe.Pointer
41 t unsafe.Pointer
42 h unsafe.Pointer
43 buckets unsafe.Pointer
44 bptr unsafe.Pointer
45 overflow *[]unsafe.Pointer
46 oldoverflow *[]unsafe.Pointer
47 startBucket uintptr
48 offset uint8
49 wrapped bool
50 B uint8
51 i uint8
52 bucket uintptr
53 checkBucket uintptr
54}
55
56// add returns p+x.
57//
58// The whySafe string is ignored, so that the function still inlines
59// as efficiently as p+x, but all call sites should use the string to
60// record why the addition is safe, which is to say why the addition
61// does not cause x to advance to the very end of p's allocation
62// and therefore point incorrectly at the next block in memory.
63func add(p unsafe.Pointer, x uintptr, whySafe string) unsafe.Pointer {
64 return unsafe.Pointer(uintptr(p) + x)
65}
66
67// arrayAt returns the i-th element of p,
68// an array whose elements are eltSize bytes wide.
69// The array pointed at by p must have at least i+1 elements:
70// it is invalid (but impossible to check here) to pass i >= len,
71// because then the result will point outside the array.
72// whySafe must explain why i < len. (Passing "i < len" is fine;
73// the benefit is to surface this assumption at the call site.)
74func arrayAt(p unsafe.Pointer, i int, eltSize uintptr, whySafe string) unsafe.Pointer {
75 return add(p, uintptr(i)*eltSize, "i < len")
76}