1818namespace __sanitizer {
1919
2020ThreadContextBase::ThreadContextBase (u32 tid)
21- : tid(tid), unique_id(0 ), reuse_count(), os_id(0 ), user_id(0 ),
22- status (ThreadStatusInvalid), detached(false ),
23- thread_type(ThreadType::Regular), parent_tid(0 ), next(0 ) {
21+ : tid(tid),
22+ unique_id (0 ),
23+ reuse_count(),
24+ os_id(0 ),
25+ user_id(0 ),
26+ status(ThreadStatusInvalid),
27+ detached(false ),
28+ thread_type(ThreadType::Regular),
29+ parent_tid(0 ),
30+ next(0 ) {
2431 name[0 ] = ' \0 ' ;
2532 atomic_store (&thread_destroyed, 0 , memory_order_release);
2633}
@@ -39,8 +46,7 @@ void ThreadContextBase::SetName(const char *new_name) {
3946}
4047
4148void ThreadContextBase::SetDead () {
42- CHECK (status == ThreadStatusRunning ||
43- status == ThreadStatusFinished);
49+ CHECK (status == ThreadStatusRunning || status == ThreadStatusFinished);
4450 status = ThreadStatusDead;
4551 user_id = 0 ;
4652 OnDead ();
@@ -68,7 +74,8 @@ void ThreadContextBase::SetFinished() {
6874 // for a thread that never actually started. In that case the thread
6975 // should go to ThreadStatusFinished regardless of whether it was created
7076 // as detached.
71- if (!detached || status == ThreadStatusCreated) status = ThreadStatusFinished;
77+ if (!detached || status == ThreadStatusCreated)
78+ status = ThreadStatusFinished;
7279 OnFinished ();
7380}
7481
@@ -124,8 +131,10 @@ void ThreadRegistry::GetNumberOfThreads(uptr *total, uptr *running,
124131 ThreadRegistryLock l (this );
125132 if (total)
126133 *total = threads_.size ();
127- if (running) *running = running_threads_;
128- if (alive) *alive = alive_threads_;
134+ if (running)
135+ *running = running_threads_;
136+ if (alive)
137+ *alive = alive_threads_;
129138}
130139
131140uptr ThreadRegistry::GetMaxAliveThreads () {
@@ -150,8 +159,10 @@ u32 ThreadRegistry::CreateThread(uptr user_id, bool detached, u32 parent_tid,
150159 Report (" %s: Thread limit (%u threads) exceeded. Dying.\n " ,
151160 SanitizerToolName, max_threads_);
152161#else
153- Printf (" race: limit on %u simultaneously alive goroutines is exceeded,"
154- " dying\n " , max_threads_);
162+ Printf (
163+ " race: limit on %u simultaneously alive goroutines is exceeded,"
164+ " dying\n " ,
165+ max_threads_);
155166#endif
156167 Die ();
157168 }
@@ -170,8 +181,7 @@ u32 ThreadRegistry::CreateThread(uptr user_id, bool detached, u32 parent_tid,
170181 // positives later (e.g. if we join a wrong thread).
171182 CHECK (live_.try_emplace (user_id, tid).second );
172183 }
173- tctx->SetCreated (user_id, total_threads_++, detached,
174- parent_tid, arg);
184+ tctx->SetCreated (user_id, total_threads_++, detached, parent_tid, arg);
175185 return tid;
176186}
177187
@@ -196,8 +206,8 @@ u32 ThreadRegistry::FindThread(FindThreadCallback cb, void *arg) {
196206 return kInvalidTid ;
197207}
198208
199- ThreadContextBase *
200- ThreadRegistry::FindThreadContextLocked ( FindThreadCallback cb, void *arg) {
209+ ThreadContextBase *ThreadRegistry::FindThreadContextLocked (
210+ FindThreadCallback cb, void *arg) {
201211 CheckLocked ();
202212 for (u32 tid = 0 ; tid < threads_.size (); tid++) {
203213 ThreadContextBase *tctx = threads_[tid];
@@ -210,7 +220,7 @@ ThreadRegistry::FindThreadContextLocked(FindThreadCallback cb, void *arg) {
210220static bool FindThreadContextByOsIdCallback (ThreadContextBase *tctx,
211221 void *arg) {
212222 return (tctx->os_id == (uptr)arg && tctx->status != ThreadStatusInvalid &&
213- tctx->status != ThreadStatusDead);
223+ tctx->status != ThreadStatusDead);
214224}
215225
216226ThreadContextBase *ThreadRegistry::FindThreadContextByOsIDLocked (tid_t os_id) {
0 commit comments