+2009-10-17 Ivan Maidanski <ivmai@mail.ru>
+
+ * backgraph.c (SET_OH_BG_PTR): Place outermost parenthesis
+ properly.
+ * darwin_stop_world.c: Replace "if DEBUG_THREADS" with
+ "ifdef DEBUG_THREADS".
+ * pthread_stop_world.c: Ditto.
+ * pthread_support.c: Ditto.
+ * include/gc_inline.h: Guard with GC_INLINE_H.
+
2009-10-17 Ivan Maidanski <ivmai@mail.ru>
* alloc.c (GC_copyright): Define as const.
#define GET_OH_BG_PTR(p) \
(ptr_t)REVEAL_POINTER(((oh *)(p)) -> oh_bg_ptr)
-#define SET_OH_BG_PTR(p,q) (((oh *)(p)) -> oh_bg_ptr) = HIDE_POINTER(q)
+#define SET_OH_BG_PTR(p,q) (((oh *)(p)) -> oh_bg_ptr = HIDE_POINTER(q))
/* Execute s once for each predecessor q of p in the points-to graph. */
/* s should be a bracketed statement. We declare q. */
hi = GC_stackbottom;
else
hi = p->stack_end;
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("Darwin: Stack for thread 0x%lx = [%lx,%lx)\n",
(unsigned long) p -> id, (unsigned long) lo,
(unsigned long) hi);
# error FIXME for non-x86 || ppc || arm architectures
# endif
}
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("Darwin: Stack for thread 0x%lx = [%p,%p)\n",
(unsigned long) thread, lo, hi);
# endif
for(i = 0; i < count; i++) {
thread_act_t thread = act_list[i];
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("Attempting to suspend thread %p\n", thread);
# endif
/* find the current thread in the old list */
}
continue;
}
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("Thread state for 0x%lx = %d\n", (unsigned long)thread,
info.run_state);
# endif
if (info.suspend_count)
continue;
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("Suspending 0x%lx\n", (unsigned long)thread);
# endif
/* Suspend the thread */
thread_act_array_t act_list, prev_list;
mach_msg_type_number_t listcount, prevcount;
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("Stopping the world from 0x%lx\n",
(unsigned long)mach_thread_self());
# endif
if (GC_parallel)
GC_release_mark_lock();
# endif
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("World stopped from 0x%lx\n", (unsigned long)my_thread);
# endif
struct thread_basic_info info;
mach_msg_type_number_t outCount = THREAD_INFO_MAX;
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("World starting\n");
# endif
for(j = 0; j < GC_mach_threads_count; j++) {
if (thread == GC_mach_threads[j].thread) {
if (GC_mach_threads[j].already_suspended) {
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("Not resuming already suspended thread %p\n", thread);
# endif
continue;
(thread_info_t)&info, &outCount);
if(kern_result != KERN_SUCCESS)
ABORT("thread_info failed");
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("Thread state for 0x%lx = %d\n", (unsigned long)thread,
info.run_state);
GC_printf("Resuming 0x%lx\n", (unsigned long)thread);
sizeof(thread_t) * listcount);
mach_port_deallocate(my_task, my_thread);
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("World started\n");
# endif
}
* modified is included with the above copyright notice.
*/
+#ifndef GC_INLINE_H
+#define GC_INLINE_H
+
/* WARNING: */
/* Note that for these routines, it is the clients responsibility to */
/* add the extra byte at the end to deal with one-past-the-end pointers.*/
(void)0 /* no initialization */); \
}
-
/* And once more for two word initialized objects: */
# define GC_CONS(result, first, second, tiny_fl) \
{ \
*(void **)result = (void *)(first)); \
((void **)(result))[1] = (void *)(second); \
}
+
+#endif /* !GC_INLINE_H */
#include <unistd.h>
#include "atomic_ops.h"
-#if DEBUG_THREADS
+#ifdef DEBUG_THREADS
#ifndef NSIG
# if defined(MAXSIG)
GC_printf("\n");
}
-#endif
+#endif /* DEBUG_THREADS */
/* Remove the signals that we want to allow in thread stopping */
/* handler from a set. */
/* out of it. In fact, it looks to me like an async-signal-safe */
/* cancellation point is inherently a problem, unless there is */
/* some way to disable cancellation in the handler. */
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("Suspending 0x%x\n", (unsigned)my_thread);
# endif
/* Simply dropping the sigsuspend call should be safe, but is unlikely */
/* to be efficient. */
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("Continuing 0x%x\n", (unsigned)my_thread);
# endif
RESTORE_CANCEL(cancel_state);
** will thus not interrupt the sigsuspend() above.
*/
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("In GC_restart_handler for 0x%x\n", (unsigned)pthread_self());
# endif
}
pthread_t me = pthread_self();
if (!GC_thr_initialized) GC_thr_init();
-# if DEBUG_THREADS
- GC_printf("Pushing stacks from thread 0x%x\n", (unsigned) me);
+# ifdef DEBUG_THREADS
+ GC_printf("Pushing stacks from thread 0x%x\n", (unsigned) me);
# endif
for (i = 0; i < THREAD_TABLE_SZ; i++) {
for (p = GC_threads[i]; p != 0; p = p -> next) {
hi = GC_stackbottom;
IF_IA64(bs_lo = BACKING_STORE_BASE;)
}
-# if DEBUG_THREADS
- GC_printf("Stack for thread 0x%x = [%p,%p)\n",
- (unsigned)(p -> id), lo, hi);
+# ifdef DEBUG_THREADS
+ GC_printf("Stack for thread 0x%x = [%p,%p)\n",
+ (unsigned)(p -> id), lo, hi);
# endif
if (0 == lo) ABORT("GC_push_all_stacks: sp not set!\n");
GC_push_all_stack_frames(lo, hi, p -> activation_frame);
# ifdef IA64
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("Reg stack for thread 0x%x = [%p,%p)\n",
(unsigned)p -> id, bs_lo, bs_hi);
# endif
/* There seems to be a very rare thread stopping problem. To help us */
/* debug that, we save the ids of the stopping thread. */
-#if DEBUG_THREADS
-pthread_t GC_stopping_thread;
-int GC_stopping_pid = 0;
+#ifdef DEBUG_THREADS
+ pthread_t GC_stopping_thread;
+ int GC_stopping_pid = 0;
#endif
/* We hold the allocation lock. Suspend all threads that might */
int result;
pthread_t my_thread = pthread_self();
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_stopping_thread = my_thread;
GC_stopping_pid = getpid();
# endif
if (p -> stop_info.last_stop_count == GC_stop_count) continue;
if (p -> thread_blocked) /* Will wait */ continue;
n_live_threads++;
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("Sending suspend signal to 0x%x\n",
(unsigned)(p -> id));
# endif
int code;
GC_ASSERT(I_HOLD_LOCK());
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("Stopping the world from 0x%x\n", (unsigned)pthread_self());
# endif
if (GC_parallel)
GC_release_mark_lock();
# endif
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("World stopped from 0x%x\n", (unsigned)pthread_self());
GC_stopping_thread = 0;
# endif
int code;
# endif
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("World starting\n");
# endif
if (p -> flags & FINISHED) continue;
if (p -> thread_blocked) continue;
n_live_threads++;
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("Sending restart signal to 0x%x\n",
(unsigned)(p -> id));
# endif
ABORT("sem_wait() for restart handler failed");
}
# endif
-# if DEBUG_THREADS
- GC_printf("World started\n");
+# ifdef DEBUG_THREADS
+ GC_printf("World started\n");
# endif
}
/*#define DEBUG_THREADS 1*/
-# include "private/pthread_support.h"
+#include "private/pthread_support.h"
# if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS)
my_mark_no = GC_mark_no;
}
# ifdef DEBUG_THREADS
- GC_printf("Starting mark helper for mark number %lu\n",
+ GC_printf("Starting mark helper for mark number %lu\n",
(unsigned long)my_mark_no);
# endif
GC_help_marker(my_mark_no);
numCpus = pm_sysinfo.idle_vp_count;
# ifdef DEBUG_THREADS
- GC_printf("Number of active CPUs in this system: %d\n", numCpus);
+ GC_printf("Number of active CPUs in this system: %d\n", numCpus);
# endif
return(numCpus);
}
}
STATIC void * GC_CALLBACK GC_inner_start_routine(struct GC_stack_base *sb,
- void * arg)
+ void * arg)
{
struct start_info * si = arg;
void * result;
/* OK to deallocate. */
pthread_cleanup_push(GC_thread_exit_proc, 0);
result = (*start)(start_arg);
-# if DEBUG_THREADS
+# ifdef DEBUG_THREADS
GC_printf("Finishing thread 0x%x\n", (unsigned)pthread_self());
# endif
me -> status = result;