--> Macro replaced by USE_COMPILER_TLS
# endif
+#ifndef USE_COMPILER_TLS
# if (defined(GC_DGUX386_THREADS) || defined(GC_OSF1_THREADS) || \
defined(GC_DARWIN_THREADS) || defined(GC_AIX_THREADS)) || \
defined(GC_NETBSD_THREADS) && !defined(USE_PTHREAD_SPECIFIC) || \
+ defined(GC_FREEBSD_THREADS) && !defined(USE_PTHREAD_SPECIFIC) || \
defined(GC_OPENBSD_THREADS)
# define USE_PTHREAD_SPECIFIC
# endif
+#endif
# if defined(GC_DGUX386_THREADS) && !defined(_POSIX4A_DRAFT10_SOURCE)
# define _POSIX4A_DRAFT10_SOURCE 1
void GC_init_parallel();
+static pthread_t main_pthread_self;
+static void *main_stack, *main_altstack;
+static int main_stack_size, main_altstack_size;
+
# if defined(THREAD_LOCAL_ALLOC) && !defined(DBG_HDRS_ALL)
/* We don't really support thread-local allocation with DBG_HDRS_ALL */
extern __thread int nacl_thread_idx;
extern __thread GC_thread nacl_gc_thread_self;
+extern void nacl_pre_syscall_hook();
+extern void nacl_post_syscall_hook();
+extern void nacl_register_gc_hooks(void (*pre)(), void (*post)());
+
void nacl_initialize_gc_thread()
{
int i;
+ nacl_register_gc_hooks(nacl_pre_syscall_hook, nacl_post_syscall_hook);
pthread_mutex_lock(&nacl_thread_alloc_lock);
if (!nacl_thread_parking_inited)
{
return ptr ? 1 : 0;
}
+void GC_register_altstack (void *stack, int stack_size, void *altstack, int altstack_size)
+{
+ GC_thread thread;
+
+ LOCK();
+ thread = (void *)GC_lookup_thread(pthread_self());
+ if (thread) {
+ thread->stack = stack;
+ thread->stack_size = stack_size;
+ thread->altstack = altstack;
+ thread->altstack_size = altstack_size;
+ } else {
+ /*
+ * This happens if we are called before GC_thr_init ().
+ */
+ main_pthread_self = pthread_self ();
+ main_stack = stack;
+ main_stack_size = stack_size;
+ main_altstack = altstack;
+ main_altstack_size = altstack_size;
+ }
+ UNLOCK();
+}
+
#ifdef HANDLE_FORK
/* Remove all entries from the GC_threads table, except the */
/* one for the current thread. We need to do this in the child */
gc_thread_vtable->thread_created (pthread_self (), &t->stop_info.stack_ptr);
# endif
#endif
+ if (pthread_self () == main_pthread_self) {
+ t->stack = main_stack;
+ t->stack_size = main_stack_size;
+ t->altstack = main_altstack;
+ t->altstack_size = main_altstack_size;
+ }
GC_stop_init();