diff options
| author | Russ Cox <rsc@golang.org> | 2024-05-17 12:07:15 -0400 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-05-23 02:32:19 +0000 |
| commit | ff2070d9398aff1c44691a90761eb35ea3cd4601 (patch) | |
| tree | 77cb849fc27f0348ca652dd162ae3fbf9346ee33 /src/internal/coverage | |
| parent | fd1363240ac22583125d43d8e15f130f02a7659b (diff) | |
| download | go-ff2070d9398aff1c44691a90761eb35ea3cd4601.tar.xz | |
runtime: move exit hooks into internal/runtime/exithook
This removes a //go:linkname usage in the coverage implementation.
For #67401.
Change-Id: I0602172c7e372a84465160dbf46d9fa371582fff
Reviewed-on: https://go-review.googlesource.com/c/go/+/586259
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/internal/coverage')
| -rw-r--r-- | src/internal/coverage/cfile/hooks.go | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/internal/coverage/cfile/hooks.go b/src/internal/coverage/cfile/hooks.go index 003d6ca1e5..3821d1e91e 100644 --- a/src/internal/coverage/cfile/hooks.go +++ b/src/internal/coverage/cfile/hooks.go @@ -4,7 +4,7 @@ package cfile -import _ "unsafe" +import "internal/runtime/exithook" // InitHook is invoked from the main package "init" routine in // programs built with "-cover". This function is intended to be @@ -29,14 +29,10 @@ func InitHook(istest bool) { // Note: hooks are run in reverse registration order, so // register the counter data hook before the meta-data hook // (in the case where two hooks are needed). - runOnNonZeroExit := true - runtime_addExitHook(emitCounterData, runOnNonZeroExit) + exithook.Add(exithook.Hook{F: emitCounterData, RunOnFailure: true}) if istest { - runtime_addExitHook(emitMetaData, runOnNonZeroExit) + exithook.Add(exithook.Hook{F: emitMetaData, RunOnFailure: true}) } else { emitMetaData() } } - -//go:linkname runtime_addExitHook runtime.addExitHook -func runtime_addExitHook(f func(), runOnNonZeroExit bool) |
