github.com/go-darwin/sys@v0.0.0-20220510002607-68fd01f054ca/escape.go (about)

     1  // Copyright 2021 The Go Darwin Authors
     2  // SPDX-License-Identifier: BSD-3-Clause
     3  
     4  //go:build darwin && gc
     5  // +build darwin,gc
     6  
     7  package sys
     8  
     9  import (
    10  	"unsafe"
    11  )
    12  
    13  // Noescape hides a pointer from escape analysis.
    14  //
    15  // Noescape is the identity function but escape analysis doesn't think the
    16  // output depends on the input.
    17  //
    18  // Noescape is inlined and currently compiles down to zero instructions.
    19  //
    20  //go:nocheckptr
    21  //go:nosplit
    22  func Noescape(p unsafe.Pointer) unsafe.Pointer {
    23  	x := uintptr(p)
    24  	return unsafe.Pointer(x ^ 0)
    25  }