*phi = (p->flags & MAIN_THREAD) != 0 ? GC_stackbottom : p->stack_end;
# endif
# ifdef DEBUG_THREADS
- GC_log_printf("Darwin: Stack for thread 0x%lx = [%p,%p)\n",
- (unsigned long)thread, lo, *phi);
+ GC_log_printf("Darwin: Stack for thread %p = [%p,%p)\n",
+ (void *)thread, lo, *phi);
# endif
return lo;
}
# endif
# ifdef DEBUG_THREADS
- GC_log_printf("Attempting to suspend thread 0x%lx\n",
- (unsigned long)thread);
+ GC_log_printf("Attempting to suspend thread %p\n", (void *)thread);
# endif
/* find the current thread in the old list */
found = FALSE;
continue;
}
# ifdef DEBUG_THREADS
- GC_log_printf("Thread state for 0x%lx = %d\n", (unsigned long)thread,
- info.run_state);
+ GC_log_printf("Thread state for %p = %d\n", (void *)thread, info.run_state);
# endif
if (info.suspend_count != 0) {
/* thread is already suspended. */
}
# ifdef DEBUG_THREADS
- GC_log_printf("Suspending 0x%lx\n", (unsigned long)thread);
+ GC_log_printf("Suspending %p\n", (void *)thread);
# endif
kern_result = thread_suspend(thread);
if (kern_result != KERN_SUCCESS) {
kern_return_t kern_result;
# ifdef DEBUG_THREADS
- GC_log_printf("Stopping the world from thread 0x%lx\n",
- (unsigned long)my_thread);
+ GC_log_printf("Stopping the world from thread %p\n", (void *)my_thread);
# endif
# ifdef PARALLEL_MARK
if (GC_parallel) {
# endif
# ifdef DEBUG_THREADS
- GC_log_printf("World stopped from 0x%lx\n", (unsigned long)my_thread);
+ GC_log_printf("World stopped from %p\n", (void *)my_thread);
# endif
mach_port_deallocate(my_task, my_thread);
}
ABORT("thread_info failed");
# endif
# ifdef DEBUG_THREADS
- GC_log_printf("Resuming thread 0x%lx with state %d\n",
- (unsigned long)thread, info.run_state);
+ GC_log_printf("Resuming thread %p with state %d\n", (void *)thread,
+ info.run_state);
# endif
/* Resume the thread */
kern_result = thread_resume(thread);
/* The thread is found in GC_mach_threads. */
if (GC_mach_threads[j].already_suspended) {
# ifdef DEBUG_THREADS
- GC_log_printf("Not resuming already suspended thread 0x%lx\n",
- (unsigned long)thread);
+ GC_log_printf("Not resuming already suspended thread %p\n",
+ (void *)thread);
# endif
} else {
GC_thread_resume(thread);
#if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS)
-#include <inttypes.h>
#include <pthread.h>
#include <sched.h>
# endif
result = (*start)(start_arg);
# ifdef DEBUG_THREADS
- GC_log_printf("Finishing thread 0x%"PRIxMAX"\n", (uintmax_t)pthread_self());
+ GC_log_printf("Finishing thread %p\n", (void *)pthread_self());
# endif
me -> status = result;
# ifndef NACL
/* cancellation point is inherently a problem, unless there is */
/* some way to disable cancellation in the handler. */
# ifdef DEBUG_THREADS
- GC_log_printf("Suspending 0x%x\n", (unsigned)self);
+ GC_log_printf("Suspending %p\n", (void *)self);
# endif
me = GC_lookup_thread(self);
/* unlikely to be efficient. */
# ifdef DEBUG_THREADS
- GC_log_printf("Continuing 0x%x\n", (unsigned)self);
+ GC_log_printf("Continuing %p\n", (void *)self);
# endif
RESTORE_CANCEL(cancel_state);
}
*/
# ifdef DEBUG_THREADS
- GC_log_printf("In GC_restart_handler for 0x%x\n",
- (unsigned)pthread_self());
+ GC_log_printf("In GC_restart_handler for %p\n", (void *)pthread_self());
# endif
}
if (!GC_thr_initialized) GC_thr_init();
# ifdef DEBUG_THREADS
- GC_log_printf("Pushing stacks from thread 0x%x\n", (unsigned)self);
+ GC_log_printf("Pushing stacks from thread %p\n", (void *)self);
# endif
for (i = 0; i < THREAD_TABLE_SZ; i++) {
for (p = GC_threads[i]; p != 0; p = p -> next) {
IF_IA64(bs_lo = BACKING_STORE_BASE;)
}
# ifdef DEBUG_THREADS
- GC_log_printf("Stack for thread 0x%x = [%p,%p)\n",
- (unsigned)(p -> id), lo, hi);
+ GC_log_printf("Stack for thread %p = [%p,%p)\n",
+ (void *)p->id, lo, hi);
# endif
if (0 == lo) ABORT("GC_push_all_stacks: sp not set!");
GC_push_all_stack_sections(lo, hi, p -> traced_stack_sect);
# endif
# ifdef IA64
# ifdef DEBUG_THREADS
- GC_log_printf("Reg stack for thread 0x%x = [%p,%p)\n",
- (unsigned)p -> id, bs_lo, bs_hi);
+ GC_log_printf("Reg stack for thread %p = [%p,%p)\n",
+ (void *)p->id, bs_lo, bs_hi);
# endif
/* FIXME: This (if p->id==self) may add an unbounded number of */
/* entries, and hence overflow the mark stack, which is bad. */
n_live_threads++;
# endif
# ifdef DEBUG_THREADS
- GC_log_printf("Sending suspend signal to 0x%x\n",
- (unsigned)(p -> id));
+ GC_log_printf("Sending suspend signal to %p\n", (void *)p->id);
# endif
# ifdef GC_OPENBSD_THREADS
# endif
GC_ASSERT(I_HOLD_LOCK());
# ifdef DEBUG_THREADS
- GC_log_printf("Stopping the world from 0x%x\n", (unsigned)pthread_self());
+ GC_log_printf("Stopping the world from %p\n", (void *)pthread_self());
# endif
/* Make sure all free list construction has stopped before we start. */
GC_release_mark_lock();
# endif
# ifdef DEBUG_THREADS
- GC_log_printf("World stopped from 0x%x\n", (unsigned)pthread_self());
+ GC_log_printf("World stopped from %p\n", (void *)pthread_self());
GC_stopping_thread = 0;
# endif
}
n_live_threads++;
# endif
# ifdef DEBUG_THREADS
- GC_log_printf("Sending restart signal to 0x%x\n",
- (unsigned)(p -> id));
+ GC_log_printf("Sending restart signal to %p\n", (void *)p->id);
# endif
# ifdef GC_OPENBSD_THREADS
#if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS)
# include <stdlib.h>
-# include <inttypes.h>
# include <pthread.h>
# include <sched.h>
# include <time.h>
# endif
}
-STATIC int GC_count_threads(void)
-{
+#ifdef DEBUG_THREADS
+ STATIC int GC_count_threads(void)
+ {
int i;
int count = 0;
GC_ASSERT(I_HOLD_LOCK());
}
}
return count;
-}
+ }
+#endif /* DEBUG_THREADS */
/* It may not be safe to allocate when we register the first thread. */
static struct GC_Thread_Rep first_thread;
GC_thread result;
static GC_bool first_thread_used = FALSE;
# ifdef DEBUG_THREADS
- GC_log_printf("Creating thread %#"PRIxMAX".\n", (uintmax_t)id);
+ GC_log_printf("Creating thread %p\n", (void *)id);
# endif
GC_ASSERT(I_HOLD_LOCK());
register GC_thread prev = 0;
# ifdef DEBUG_THREADS
- GC_log_printf("Deleting thread 0x%"PRIxMAX". n_threads = %d.\n",
- (uintmax_t)id, GC_count_threads());
+ GC_log_printf("Deleting thread %p, n_threads = %d\n",
+ (void *)id, GC_count_threads());
# endif
# ifdef NACL
GC_INTERNAL_FREE(p);
# ifdef DEBUG_THREADS
- GC_log_printf("Deleted gc-thread 0x%"PRIxMAX". n_threads = %d.\n",
- (uintmax_t)id, GC_count_threads());
+ GC_log_printf("Deleted thread %p, n_threads = %d\n",
+ (void *)id, GC_count_threads());
# endif
}
STATIC void GC_unregister_my_thread_inner(GC_thread me)
{
# ifdef DEBUG_THREADS
- GC_log_printf("Unregistering thread 0x%"PRIxMAX" -> %p. n_threads = %d.\n",
- (uintmax_t)me->id, me, GC_count_threads());
+ GC_log_printf(
+ "Unregistering thread %p, gc_thread = %p, n_threads = %d\n",
+ (void *)me->id, me, GC_count_threads());
# endif
GC_ASSERT(!(me -> flags & FINISHED));
# if defined(THREAD_LOCAL_ALLOC)
GC_API int GC_CALL GC_unregister_my_thread(void)
{
pthread_t self = pthread_self();
- GC_thread gc_self;
+ GC_thread me;
IF_CANCEL(int cancel_state;)
DCL_LOCK_STATE;
/* Wait for any GC that may be marking from our stack to */
/* complete before we remove this thread. */
GC_wait_for_gc_completion(FALSE);
- gc_self = GC_lookup_thread(self);
+ me = GC_lookup_thread(self);
# ifdef DEBUG_THREADS
- GC_log_printf("Called GC_unregister_my_thread on %#"PRIxMAX" -> %p.\n",
- (uintmax_t)self, GC_lookup_thread(self));
+ GC_log_printf(
+ "Called GC_unregister_my_thread on %p, gc_thread = %p\n",
+ (void *)self, me);
# endif
- GC_ASSERT(gc_self->id == self);
- GC_unregister_my_thread_inner(gc_self);
+ GC_ASSERT(me->id == self);
+ GC_unregister_my_thread_inner(me);
RESTORE_CANCEL(cancel_state);
UNLOCK();
return GC_SUCCESS;
GC_INNER void GC_thread_exit_proc(void *arg)
{
# ifdef DEBUG_THREADS
- GC_log_printf("Called GC_thread_exit_proc on %#"PRIxMAX" -> %p.\n",
- ((GC_thread)arg)->id, arg);
+ GC_log_printf("Called GC_thread_exit_proc on %p, gc_thread = %p\n",
+ (void *)((GC_thread)arg)->id, arg);
# endif
IF_CANCEL(int cancel_state;)
DCL_LOCK_STATE;
DCL_LOCK_STATE;
# ifdef DEBUG_THREADS
- GC_log_printf("Starting thread 0x%"PRIxMAX", pid = %ld, sp = %p\n",
- (uintmax_t)self, (long)getpid(), &arg);
+ GC_log_printf("Starting thread %p, pid = %ld, sp = %p\n",
+ (void *)self, (long)getpid(), &arg);
# endif
LOCK();
me = GC_register_my_thread_inner(sb, self);
si -> flags = my_flags;
UNLOCK();
# ifdef DEBUG_THREADS
- GC_log_printf("About to start new thread from thread 0x%x\n",
- (unsigned)pthread_self());
+ GC_log_printf("About to start new thread from thread %p\n",
+ (void *)pthread_self());
# endif
GC_need_to_lock = TRUE;
result = REAL_FUNC(pthread_create)(new_thread, attr, GC_start_routine, si);
-# ifdef DEBUG_THREADS
- GC_log_printf("Started thread 0x%x\n", (unsigned)(*new_thread));
-# endif
/* Wait until child has been added to the thread table. */
/* This also ensures that we hold onto si until the child is done */
/* with it. Thus it doesn't matter whether it is otherwise */
/* visible to the collector. */
if (0 == result) {
IF_CANCEL(int cancel_state;)
+
+# ifdef DEBUG_THREADS
+ if (new_thread)
+ GC_log_printf("Started thread %p\n", (void *)(*new_thread));
+# endif
DISABLE_CANCEL(cancel_state);
/* pthread_create is not a cancellation point. */
while (0 != sem_wait(&(si -> registered))) {