1// Copyright 2022 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
5package runtime
6
7import (
8	"internal/coverage/rtcov"
9	"unsafe"
10)
11
12//go:linkname coverage_getCovCounterList internal/coverage/cfile.getCovCounterList
13func coverage_getCovCounterList() []rtcov.CovCounterBlob {
14	res := []rtcov.CovCounterBlob{}
15	u32sz := unsafe.Sizeof(uint32(0))
16	for datap := &firstmoduledata; datap != nil; datap = datap.next {
17		if datap.covctrs == datap.ecovctrs {
18			continue
19		}
20		res = append(res, rtcov.CovCounterBlob{
21			Counters: (*uint32)(unsafe.Pointer(datap.covctrs)),
22			Len:      uint64((datap.ecovctrs - datap.covctrs) / u32sz),
23		})
24	}
25	return res
26}
27