Skip to content

Commit 1af81ab

Browse files
committed
[libarcher] Place classes in anonymous namespace
Place various classes/structs into anonymous namespaces and mark variables as static. As far as I understand, these are all implementation details and not intended to be exported -- only a small number of tsan hooks are supposed to be. Differential Revision: https://reviews.llvm.org/D136845
1 parent d41ecfa commit 1af81ab

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

openmp/tools/archer/ompt-tsan.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
static int runOnTsan;
5757
static int hasReductionCallback;
5858

59+
namespace {
5960
class ArcherFlags {
6061
public:
6162
#if (LLVM_VERSION) >= 40
@@ -132,14 +133,15 @@ class TsanFlags {
132133
}
133134
}
134135
};
136+
} // namespace
135137

136138
#if (LLVM_VERSION) >= 40
137139
extern "C" {
138140
int __attribute__((weak)) __archer_get_omp_status();
139141
void __attribute__((weak)) __tsan_flush_memory() {}
140142
}
141143
#endif
142-
ArcherFlags *archer_flags;
144+
static ArcherFlags *archer_flags;
143145

144146
#ifndef TsanHappensBefore
145147
// Thread Sanitizer is a tool that finds races in code.
@@ -232,6 +234,7 @@ static int pagesize{0};
232234

233235
// Data structure to provide a threadsafe pool of reusable objects.
234236
// DataPool<Type of objects>
237+
namespace {
235238
template <typename T> struct DataPool final {
236239
static __thread DataPool<T> *ThreadDataPool;
237240
std::mutex DPMutex{};
@@ -598,14 +601,15 @@ struct TaskData final : DataPoolEntry<TaskData> {
598601

599602
TaskData(DataPool<TaskData> *dp) : DataPoolEntry<TaskData>(dp) {}
600603
};
604+
} // namespace
601605

602606
static inline TaskData *ToTaskData(ompt_data_t *task_data) {
603607
return reinterpret_cast<TaskData *>(task_data->ptr);
604608
}
605609

606610
/// Store a mutex for each wait_id to resolve race condition with callbacks.
607-
std::unordered_map<ompt_wait_id_t, std::mutex> Locks;
608-
std::mutex LocksMutex;
611+
static std::unordered_map<ompt_wait_id_t, std::mutex> Locks;
612+
static std::mutex LocksMutex;
609613

610614
static void ompt_tsan_thread_begin(ompt_thread_t thread_type,
611615
ompt_data_t *thread_data) {

0 commit comments

Comments
 (0)