github.com/karrick/go@v0.0.0-20170817181416-d5b0ec858b37/src/runtime/proflabel.go (about)

     1  // Copyright 2017 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package runtime
     6  
     7  import "unsafe"
     8  
     9  var labelSync uintptr
    10  
    11  //go:linkname runtime_setProfLabel runtime/pprof.runtime_setProfLabel
    12  func runtime_setProfLabel(labels unsafe.Pointer) {
    13  	// Introduce race edge for read-back via profile.
    14  	// This would more properly use &getg().labels as the sync address,
    15  	// but we do the read in a signal handler and can't call the race runtime then.
    16  	if raceenabled {
    17  		racerelease(unsafe.Pointer(&labelSync))
    18  	}
    19  	getg().labels = labels
    20  }
    21  
    22  //go:linkname runtime_getProfLabel runtime/pprof.runtime_getProfLabel
    23  func runtime_getProfLabel() unsafe.Pointer {
    24  	return getg().labels
    25  }