static sigset_t suspend_handler_mask;
+#define THREAD_RESTARTED 0x1
+
STATIC volatile AO_t GC_stop_count = 0;
- /* Incremented by two at the beginning of */
- /* GC_stop_world (the lowest bit is always 0). */
+ /* Incremented by two (not to alter */
+ /* THREAD_RESTARTED bit) at the beginning of */
+ /* GC_stop_world. */
STATIC volatile AO_t GC_world_is_stopped = FALSE;
/* FALSE ==> it is safe for threads to restart, */
# ifdef DEBUG_THREADS
GC_log_printf("Suspending %p\n", (void *)self);
# endif
- GC_ASSERT(((word)my_stop_count & 1) == 0);
+ GC_ASSERT(((word)my_stop_count & THREAD_RESTARTED) == 0);
me = GC_lookup_thread_async(self);
}
# endif
- if (((word)me->stop_info.last_stop_count & ~(word)0x1)
+ if (((word)me->stop_info.last_stop_count & ~(word)THREAD_RESTARTED)
== (word)my_stop_count) {
/* Duplicate signal. OK if we are retrying. */
if (!GC_retry_signals) {
if (GC_retry_signals)
# endif
{
- /* Set the flag (the lowest bit of last_stop_count) that the */
- /* thread has been restarted. */
+ /* Set the flag that the thread has been restarted. */
AO_store_release(&me->stop_info.last_stop_count,
- (AO_t)((word)my_stop_count | 1));
+ (AO_t)((word)my_stop_count | THREAD_RESTARTED));
}
}
RESTORE_CANCEL(cancel_state);
# if defined(GC_OPENBSD_UTHREADS) || defined(NACL)
(void)GC_suspend_all();
# else
- AO_store(&GC_stop_count, (AO_t)((word)GC_stop_count + 2));
+ AO_store(&GC_stop_count,
+ (AO_t)((word)GC_stop_count + (THREAD_RESTARTED+1)));
/* Only concurrent reads are possible. */
if (GC_manual_vdb) {
GC_acquire_dirty_lock();
# ifdef GC_ENABLE_SUSPEND_THREAD
if (p -> suspended_ext) continue;
# endif
- if (GC_retry_signals && AO_load(&p->stop_info.last_stop_count)
- == (AO_t)((word)GC_stop_count | 1))
+ if (GC_retry_signals
+ && AO_load(&p->stop_info.last_stop_count)
+ == (AO_t)((word)GC_stop_count | THREAD_RESTARTED))
continue; /* The thread has been restarted. */
n_live_threads++;
# endif