iwyu, doc: Document `IWYU pragma: export` for `<threadsafety.h>`
What changed, and why it matters
This is a code cleanup change only. It tells the Include What You Use (IWYU) tool that the project's main synchronization header (`sync.h`) re-exports another header (`threadsafety.h`), so other files don't need to include both. No program behavior changes, no security fix.
No security action needed. Treat as normal maintenance/refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit adds // IWYU pragma: export comments on the <threadsafety.h> includes inside src/sync.h and src/util/stdmutex.h, and removes direct <threadsafety.h> includes from files that already include <sync.h> (or <util/stdmutex.h>). It also adds a short explanatory comment to both headers. This is purely a build-hygiene/documentation change; it does not alter compiled code, macros, or runtime semantics.
Changed components
src/sync.hsrc/util/stdmutex.hsrc/index/base.hsrc/net_processing.hsrc/node/chainstate.cppsrc/node/kernel_notifications.hsrc/policy/fees/block_policy_estimator.hsrc/policy/rbf.hsrc/private_broadcast.hsrc/rpc/blockchain.hsrc/scheduler.hsrc/test/fuzz/util/net.hsrc/util/threadinterrupt.hInspect captured patch +7 / −11
diff --git a/src/index/base.h b/src/index/base.h
index d8fd8566..63f60be0 100644
--- a/src/index/base.h
+++ b/src/index/base.h
@@ -9,7 +9,7 @@
#include <dbwrapper.h>
#include <interfaces/chain.h>
#include <kernel/cs_main.h>
-#include <threadsafety.h>
+#include <sync.h>
#include <uint256.h>
#include <util/fs.h>
#include <util/threadinterrupt.h>
diff --git a/src/net_processing.h b/src/net_processing.h
index 63398523..d2050d8f 100644
--- a/src/net_processing.h
+++ b/src/net_processing.h
@@ -11,7 +11,6 @@
#include <node/txorphanage.h>
#include <private_broadcast.h>
#include <protocol.h>
-#include <threadsafety.h>
#include <uint256.h>
#include <util/expected.h>
#include <validationinterface.h>
diff --git a/src/node/chainstate.cpp b/src/node/chainstate.cpp
index ff3de298..0738c00a 100644
--- a/src/node/chainstate.cpp
+++ b/src/node/chainstate.cpp
@@ -11,7 +11,6 @@
#include <kernel/caches.h>
#include <node/blockstorage.h>
#include <sync.h>
-#include <threadsafety.h>
#include <tinyformat.h>
#include <txdb.h>
#include <uint256.h>
diff --git a/src/node/kernel_notifications.h b/src/node/kernel_notifications.h
index b90248bf..b152e7a4 100644
--- a/src/node/kernel_notifications.h
+++ b/src/node/kernel_notifications.h
@@ -8,7 +8,6 @@
#include <kernel/notifications_interface.h>
#include <sync.h>
-#include <threadsafety.h>
#include <uint256.h>
#include <atomic>
diff --git a/src/policy/fees/block_policy_estimator.h b/src/policy/fees/block_policy_estimator.h
index 026bf1eb..f015bd5b 100644
--- a/src/policy/fees/block_policy_estimator.h
+++ b/src/policy/fees/block_policy_estimator.h
@@ -9,7 +9,6 @@
#include <policy/feerate.h>
#include <random.h>
#include <sync.h>
-#include <threadsafety.h>
#include <uint256.h>
#include <util/fs.h>
#include <validationinterface.h>
diff --git a/src/policy/rbf.h b/src/policy/rbf.h
index ad8a2dbf..0ba646ca 100644
--- a/src/policy/rbf.h
+++ b/src/policy/rbf.h
@@ -7,7 +7,7 @@
#include <consensus/amount.h>
#include <primitives/transaction.h>
-#include <threadsafety.h>
+#include <sync.h>
#include <txmempool.h>
#include <util/feefrac.h>
diff --git a/src/private_broadcast.h b/src/private_broadcast.h
index 28634424..fec61907 100644
--- a/src/private_broadcast.h
+++ b/src/private_broadcast.h
@@ -9,7 +9,6 @@
#include <primitives/transaction.h>
#include <primitives/transaction_identifier.h>
#include <sync.h>
-#include <threadsafety.h>
#include <util/time.h>
#include <optional>
diff --git a/src/rpc/blockchain.h b/src/rpc/blockchain.h
index efb06ac2..53f6a804 100644
--- a/src/rpc/blockchain.h
+++ b/src/rpc/blockchain.h
@@ -9,7 +9,6 @@
#include <core_io.h>
#include <streams.h>
#include <sync.h>
-#include <threadsafety.h>
#include <util/fs.h>
#include <validation.h>
diff --git a/src/scheduler.h b/src/scheduler.h
index 79b8afd2..5d4affb0 100644
--- a/src/scheduler.h
+++ b/src/scheduler.h
@@ -7,7 +7,6 @@
#include <attributes.h>
#include <sync.h>
-#include <threadsafety.h>
#include <util/task_runner.h>
#include <chrono>
diff --git a/src/sync.h b/src/sync.h
index 00fdaae9..123184d4 100644
--- a/src/sync.h
+++ b/src/sync.h
@@ -6,6 +6,8 @@
#ifndef BITCOIN_SYNC_H
#define BITCOIN_SYNC_H
+// This header declares threading primitives compatible with Clang
+// Thread Safety Analysis and provides appropriate annotation macros.
#include <threadsafety.h> // IWYU pragma: export
#include <util/macros.h>
diff --git a/src/test/fuzz/util/net.h b/src/test/fuzz/util/net.h
index 862153ab..36393811 100644
--- a/src/test/fuzz/util/net.h
+++ b/src/test/fuzz/util/net.h
@@ -13,10 +13,10 @@
#include <node/connection_types.h>
#include <node/eviction.h>
#include <protocol.h>
+#include <sync.h>
#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/util.h>
#include <test/util/net.h>
-#include <threadsafety.h>
#include <util/asmap.h>
#include <util/sock.h>
diff --git a/src/util/stdmutex.h b/src/util/stdmutex.h
index 4c3c0cec..7a3e3039 100644
--- a/src/util/stdmutex.h
+++ b/src/util/stdmutex.h
@@ -6,6 +6,8 @@
#ifndef BITCOIN_UTIL_STDMUTEX_H
#define BITCOIN_UTIL_STDMUTEX_H
+// This header declares threading primitives compatible with Clang
+// Thread Safety Analysis and provides appropriate annotation macros.
#include <threadsafety.h> // IWYU pragma: export
#include <mutex>
diff --git a/src/util/threadinterrupt.h b/src/util/threadinterrupt.h
index 84ced927..9cac330e 100644
--- a/src/util/threadinterrupt.h
+++ b/src/util/threadinterrupt.h
@@ -6,7 +6,6 @@
#define BITCOIN_UTIL_THREADINTERRUPT_H
#include <sync.h>
-#include <threadsafety.h>
#include <atomic>
#include <chrono>
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.