Skip to content

Commit 61debff

Browse files
committed
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 <[email protected]> Reviewed-by: Cherry Zhang <[email protected]> Run-TryBot: Joel Sing <[email protected]> TryBot-Result: Go Bot <[email protected]>
1 parent 9fed39d commit 61debff

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/runtime/proc.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,16 @@ func startTheWorldWithSema(emitTraceEvent bool) int64 {
12061206
return startTime
12071207
}
12081208

1209+
// usesLibcall indicates whether this runtime performs system calls
1210+
// via libcall.
1211+
func usesLibcall() bool {
1212+
switch GOOS {
1213+
case "aix", "darwin", "illumos", "ios", "solaris", "windows":
1214+
return true
1215+
}
1216+
return false
1217+
}
1218+
12091219
// mStackIsSystemAllocated indicates whether this runtime starts on a
12101220
// system-allocated stack.
12111221
func mStackIsSystemAllocated() bool {
@@ -4481,7 +4491,7 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) {
44814491
// Normal traceback is impossible or has failed.
44824492
// See if it falls into several common cases.
44834493
n = 0
4484-
if (GOOS == "windows" || GOOS == "solaris" || GOOS == "illumos" || GOOS == "darwin" || GOOS == "ios" || GOOS == "aix") && mp.libcallg != 0 && mp.libcallpc != 0 && mp.libcallsp != 0 {
4494+
if usesLibcall() && mp.libcallg != 0 && mp.libcallpc != 0 && mp.libcallsp != 0 {
44854495
// Libcall, i.e. runtime syscall on windows.
44864496
// Collect Go stack that leads to the call.
44874497
n = gentraceback(mp.libcallpc, mp.libcallsp, 0, mp.libcallg.ptr(), 0, &stk[0], len(stk), nil, nil, 0)

0 commit comments

Comments
 (0)