Skip to content

Commit

Permalink
Use THREAD_EQUAL consistently to compare pthread_t values
Browse files Browse the repository at this point in the history
(code refactoring)

* pthread_stop_world.c [GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread):
Use THREAD_EQUAL() to compare pthread_t values.
* pthread_support.c (GC_unregister_my_thread): Likewise.
* specific.c [USE_CUSTOM_SPECIFIC] (GC_remove_specific_after_fork,
GC_slow_getspecific): Likewise.
  • Loading branch information
ivmai committed Apr 19, 2018
1 parent 64c232a commit 2abae9a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pthread_stop_world.c
Expand Up @@ -547,7 +547,7 @@ STATIC void GC_restart_handler(int sig)
/* Set the flag making the change visible to the signal handler. */
AO_store_release(&t->suspended_ext, TRUE);

if ((pthread_t)thread == pthread_self()) {
if (THREAD_EQUAL((pthread_t)thread, pthread_self())) {
UNLOCK();
/* It is safe as "t" cannot become invalid here (no race with */
/* GC_unregister_my_thread). */
Expand Down
2 changes: 1 addition & 1 deletion pthread_support.c
Expand Up @@ -1503,7 +1503,7 @@ GC_API int GC_CALL GC_unregister_my_thread(void)
"Called GC_unregister_my_thread on %p, gc_thread = %p\n",
(void *)self, (void *)me);
# endif
GC_ASSERT(me->id == self);
GC_ASSERT(THREAD_EQUAL(me->id, self));
GC_unregister_my_thread_inner(me);
RESTORE_CANCEL(cancel_state);
UNLOCK();
Expand Down
4 changes: 2 additions & 2 deletions specific.c
Expand Up @@ -91,7 +91,7 @@ GC_INNER void GC_remove_specific_after_fork(tsd * key, pthread_t t)
# endif
pthread_mutex_lock(&(key -> lock));
entry = *link;
while (entry != NULL && entry -> thread != t) {
while (entry != NULL && !THREAD_EQUAL(entry->thread, t)) {
link = &(entry -> next);
entry = *link;
}
Expand Down Expand Up @@ -132,7 +132,7 @@ GC_INNER void * GC_slow_getspecific(tsd * key, word qtid,
tse *entry = key->hash[hash_val].p;

GC_ASSERT(qtid != INVALID_QTID);
while (entry != NULL && entry -> thread != self) {
while (entry != NULL && !THREAD_EQUAL(entry->thread, self)) {
entry = entry -> next;
}
if (entry == NULL) return NULL;
Expand Down

0 comments on commit 2abae9a

Please sign in to comment.