Skip to content

Commit

Permalink
fix: remove go linkname (#406)
Browse files Browse the repository at this point in the history
  • Loading branch information
nrwiersma authored May 26, 2024
1 parent aff3955 commit 109ccda
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions noescape.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ import (
"unsafe"
)

//go:linkname noescape runtime.noescape
//go:noescape
func noescape(p unsafe.Pointer) unsafe.Pointer
// noescape hides a pointer from escape analysis. noescape is
// the identity function but escape analysis doesn't think the
// output depends on the input. noescape is inlined and currently
// compiles down to zero instructions.
// USE CAREFULLY!
//
// This function is taken from Go std lib:
// https://github.com/golang/go/blob/master/src/runtime/stubs.go#L178
//
//nolint:govet,staticcheck
//go:nosplit
func noescape(p unsafe.Pointer) unsafe.Pointer {
x := uintptr(p)
return unsafe.Pointer(x ^ 0)
}

0 comments on commit 109ccda

Please sign in to comment.