summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-02-03 19:13:02 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-02-03 19:13:02 +0000
commit2721560ff6d931fb9321b6cb086fda3ee96245b8 (patch)
treea9b11b3eeb3d97c5d0edfc3b441c46df2d54c48b
parentef17b323e8be065ed9fbcd1ea863d72e63488fc0 (diff)
parent2b1bdd1079b035c1023db310f31fe52793c8cd9c (diff)
downloadextras-2721560ff6d931fb9321b6cb086fda3ee96245b8.tar.gz
Do init_profile_extras constructor tasks only once am: 2b1bdd1079
Change-Id: I4ed48c21a3c4e221a5151b7e63a8d027fab1467e
-rw-r--r--toolchain-extras/profile-extras.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/toolchain-extras/profile-extras.cpp b/toolchain-extras/profile-extras.cpp
index 2d685084..f999a6b2 100644
--- a/toolchain-extras/profile-extras.cpp
+++ b/toolchain-extras/profile-extras.cpp
@@ -67,6 +67,8 @@ void *property_watch_loop(__unused void *arg) {
}
}
+__attribute__((weak)) int init_profile_extras_once = 0;
+
// Initialize libprofile-extras:
// - Install a signal handler that triggers __gcov_flush on <GCOV_FLUSH_SIGNAL>.
// - Create a thread that calls __gcov_flush when <kCoveragePropName> sysprop
@@ -81,6 +83,10 @@ void *property_watch_loop(__unused void *arg) {
// We force the linker to include init_profile_extras() by passing
// '-uinit_profile_extras' to the linker (in build/soong).
__attribute__((constructor)) int init_profile_extras(void) {
+ if (init_profile_extras_once)
+ return 0;
+ init_profile_extras_once = 1;
+
sighandler_t ret1 = signal(GCOV_FLUSH_SIGNAL, gcov_signal_handler);
if (ret1 == SIG_ERR) {
return -1;