mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
test: Enable ResetCoverageCounters beyond Linux
Non-Linux linkers require a fallback implementation for when coverage is not enabled. The fallbacks are marked weak to have lower precedence than built-in implementations when available, removing ambiguity from the linker.
This commit is contained in:
parent
199d47d962
commit
54e6eacc1f
1 changed files with 10 additions and 11 deletions
|
@ -4,19 +4,18 @@
|
|||
|
||||
#include <test/util/coverage.h>
|
||||
|
||||
#if defined(__clang__) && defined(__linux__)
|
||||
extern "C" void __llvm_profile_reset_counters(void) __attribute__((weak));
|
||||
extern "C" void __gcov_reset(void) __attribute__((weak));
|
||||
#if defined(__clang__)
|
||||
extern "C" __attribute__((weak)) void __llvm_profile_reset_counters(void);
|
||||
extern "C" __attribute__((weak)) void __gcov_reset(void);
|
||||
|
||||
void ResetCoverageCounters()
|
||||
{
|
||||
if (__llvm_profile_reset_counters) {
|
||||
__llvm_profile_reset_counters();
|
||||
}
|
||||
// Fallback implementations
|
||||
extern "C" __attribute__((weak)) void __llvm_profile_reset_counters(void) {}
|
||||
extern "C" __attribute__((weak)) void __gcov_reset(void) {}
|
||||
|
||||
if (__gcov_reset) {
|
||||
__gcov_reset();
|
||||
}
|
||||
void ResetCoverageCounters() {
|
||||
// These will call the real ones if available, or our dummies if not
|
||||
__llvm_profile_reset_counters();
|
||||
__gcov_reset();
|
||||
}
|
||||
#else
|
||||
void ResetCoverageCounters() {}
|
||||
|
|
Loading…
Add table
Reference in a new issue