mirror of
https://github.com/golang/go.git
synced 2025-11-10 13:41:05 +00:00
runtime: factor out usesLibcall
Rather than inline lists of GOOS values, factor out the code that checks if a runtime makes system calls via libcall. Change-Id: Ib19d7e63a2b4b8314f1841c0ff26e1b3a16b4b22 Reviewed-on: https://go-review.googlesource.com/c/go/+/259239 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Zhang <cherryyz@google.com> Run-TryBot: Joel Sing <joel@sing.id.au> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
9fed39d281
commit
61debffd97
1 changed files with 11 additions and 1 deletions
|
|
@ -1206,6 +1206,16 @@ func startTheWorldWithSema(emitTraceEvent bool) int64 {
|
||||||
return startTime
|
return startTime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// usesLibcall indicates whether this runtime performs system calls
|
||||||
|
// via libcall.
|
||||||
|
func usesLibcall() bool {
|
||||||
|
switch GOOS {
|
||||||
|
case "aix", "darwin", "illumos", "ios", "solaris", "windows":
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// mStackIsSystemAllocated indicates whether this runtime starts on a
|
// mStackIsSystemAllocated indicates whether this runtime starts on a
|
||||||
// system-allocated stack.
|
// system-allocated stack.
|
||||||
func mStackIsSystemAllocated() bool {
|
func mStackIsSystemAllocated() bool {
|
||||||
|
|
@ -4481,7 +4491,7 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) {
|
||||||
// Normal traceback is impossible or has failed.
|
// Normal traceback is impossible or has failed.
|
||||||
// See if it falls into several common cases.
|
// See if it falls into several common cases.
|
||||||
n = 0
|
n = 0
|
||||||
if (GOOS == "windows" || GOOS == "solaris" || GOOS == "illumos" || GOOS == "darwin" || GOOS == "ios" || GOOS == "aix") && mp.libcallg != 0 && mp.libcallpc != 0 && mp.libcallsp != 0 {
|
if usesLibcall() && mp.libcallg != 0 && mp.libcallpc != 0 && mp.libcallsp != 0 {
|
||||||
// Libcall, i.e. runtime syscall on windows.
|
// Libcall, i.e. runtime syscall on windows.
|
||||||
// Collect Go stack that leads to the call.
|
// Collect Go stack that leads to the call.
|
||||||
n = gentraceback(mp.libcallpc, mp.libcallsp, 0, mp.libcallg.ptr(), 0, &stk[0], len(stk), nil, nil, 0)
|
n = gentraceback(mp.libcallpc, mp.libcallsp, 0, mp.libcallg.ptr(), 0, &stk[0], len(stk), nil, nil, 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue