http urls monitor.

unsafe_link.go 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package reflect2
  2. import "unsafe"
  3. //go:linkname unsafe_New reflect.unsafe_New
  4. func unsafe_New(rtype unsafe.Pointer) unsafe.Pointer
  5. //go:linkname typedmemmove reflect.typedmemmove
  6. func typedmemmove(rtype unsafe.Pointer, dst, src unsafe.Pointer)
  7. //go:linkname unsafe_NewArray reflect.unsafe_NewArray
  8. func unsafe_NewArray(rtype unsafe.Pointer, length int) unsafe.Pointer
  9. // typedslicecopy copies a slice of elemType values from src to dst,
  10. // returning the number of elements copied.
  11. //go:linkname typedslicecopy reflect.typedslicecopy
  12. //go:noescape
  13. func typedslicecopy(elemType unsafe.Pointer, dst, src sliceHeader) int
  14. //go:linkname mapassign reflect.mapassign
  15. //go:noescape
  16. func mapassign(rtype unsafe.Pointer, m unsafe.Pointer, key, val unsafe.Pointer)
  17. //go:linkname mapaccess reflect.mapaccess
  18. //go:noescape
  19. func mapaccess(rtype unsafe.Pointer, m unsafe.Pointer, key unsafe.Pointer) (val unsafe.Pointer)
  20. // m escapes into the return value, but the caller of mapiterinit
  21. // doesn't let the return value escape.
  22. //go:noescape
  23. //go:linkname mapiterinit reflect.mapiterinit
  24. func mapiterinit(rtype unsafe.Pointer, m unsafe.Pointer) *hiter
  25. //go:noescape
  26. //go:linkname mapiternext reflect.mapiternext
  27. func mapiternext(it *hiter)
  28. //go:linkname ifaceE2I reflect.ifaceE2I
  29. func ifaceE2I(rtype unsafe.Pointer, src interface{}, dst unsafe.Pointer)
  30. // A hash iteration structure.
  31. // If you modify hiter, also change cmd/internal/gc/reflect.go to indicate
  32. // the layout of this structure.
  33. type hiter struct {
  34. key unsafe.Pointer // Must be in first position. Write nil to indicate iteration end (see cmd/internal/gc/range.go).
  35. value unsafe.Pointer // Must be in second position (see cmd/internal/gc/range.go).
  36. // rest fields are ignored
  37. }
  38. // add returns p+x.
  39. //
  40. // The whySafe string is ignored, so that the function still inlines
  41. // as efficiently as p+x, but all call sites should use the string to
  42. // record why the addition is safe, which is to say why the addition
  43. // does not cause x to advance to the very end of p's allocation
  44. // and therefore point incorrectly at the next block in memory.
  45. func add(p unsafe.Pointer, x uintptr, whySafe string) unsafe.Pointer {
  46. return unsafe.Pointer(uintptr(p) + x)
  47. }
  48. // arrayAt returns the i-th element of p,
  49. // an array whose elements are eltSize bytes wide.
  50. // The array pointed at by p must have at least i+1 elements:
  51. // it is invalid (but impossible to check here) to pass i >= len,
  52. // because then the result will point outside the array.
  53. // whySafe must explain why i < len. (Passing "i < len" is fine;
  54. // the benefit is to surface this assumption at the call site.)
  55. func arrayAt(p unsafe.Pointer, i int, eltSize uintptr, whySafe string) unsafe.Pointer {
  56. return add(p, uintptr(i)*eltSize, "i < len")
  57. }