2016-03-01 15:57:46 -07:00
|
|
|
// Copyright 2014 The Go Authors. All rights reserved.
|
2014-11-11 15:05:37 -07:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package runtime
|
|
|
|
|
|
|
|
import "unsafe"
|
|
|
|
|
|
|
|
//go:cgo_export_static main
|
|
|
|
|
|
|
|
// Filled in by runtime/cgo when linked into binary.
|
|
|
|
|
|
|
|
//go:linkname _cgo_init _cgo_init
|
|
|
|
//go:linkname _cgo_thread_start _cgo_thread_start
|
2015-03-25 18:50:35 -06:00
|
|
|
//go:linkname _cgo_sys_thread_create _cgo_sys_thread_create
|
|
|
|
//go:linkname _cgo_notify_runtime_init_done _cgo_notify_runtime_init_done
|
2015-12-11 18:16:48 -07:00
|
|
|
//go:linkname _cgo_callers _cgo_callers
|
2016-04-27 15:18:29 -06:00
|
|
|
//go:linkname _cgo_set_context_function _cgo_set_context_function
|
2017-01-19 14:09:10 -07:00
|
|
|
//go:linkname _cgo_yield _cgo_yield
|
2014-11-11 15:05:37 -07:00
|
|
|
|
|
|
|
var (
|
2015-03-25 18:50:35 -06:00
|
|
|
_cgo_init unsafe.Pointer
|
|
|
|
_cgo_thread_start unsafe.Pointer
|
|
|
|
_cgo_sys_thread_create unsafe.Pointer
|
|
|
|
_cgo_notify_runtime_init_done unsafe.Pointer
|
2015-12-11 18:16:48 -07:00
|
|
|
_cgo_callers unsafe.Pointer
|
2016-04-27 15:18:29 -06:00
|
|
|
_cgo_set_context_function unsafe.Pointer
|
2017-01-19 14:09:10 -07:00
|
|
|
_cgo_yield unsafe.Pointer
|
2014-11-11 15:05:37 -07:00
|
|
|
)
|
2015-03-25 05:10:45 -06:00
|
|
|
|
|
|
|
// iscgo is set to true by the runtime/cgo package
|
|
|
|
var iscgo bool
|
|
|
|
|
|
|
|
// cgoHasExtraM is set on startup when an extra M is created for cgo.
|
|
|
|
// The extra M must be created before any C/C++ code calls cgocallback.
|
|
|
|
var cgoHasExtraM bool
|
2015-06-07 20:14:04 -06:00
|
|
|
|
|
|
|
// cgoUse is called by cgo-generated code (using go:linkname to get at
|
|
|
|
// an unexported name). The calls serve two purposes:
|
|
|
|
// 1) they are opaque to escape analysis, so the argument is considered to
|
|
|
|
// escape to the heap.
|
|
|
|
// 2) they keep the argument alive until the call site; the call is emitted after
|
|
|
|
// the end of the (presumed) use of the argument by C.
|
|
|
|
// cgoUse should not actually be called (see cgoAlwaysFalse).
|
|
|
|
func cgoUse(interface{}) { throw("cgoUse should not be called") }
|
|
|
|
|
|
|
|
// cgoAlwaysFalse is a boolean value that is always false.
|
|
|
|
// The cgo-generated code says if cgoAlwaysFalse { cgoUse(p) }.
|
|
|
|
// The compiler cannot see that cgoAlwaysFalse is always false,
|
|
|
|
// so it emits the test and keeps the call, giving the desired
|
|
|
|
// escape analysis result. The test is cheaper than the call.
|
|
|
|
var cgoAlwaysFalse bool
|
2017-03-23 20:47:56 -06:00
|
|
|
|
|
|
|
var cgo_yield = &_cgo_yield
|