From: Geoff Norton Date: Wed, 3 Aug 2011 01:45:49 +0000 (-0400) Subject: Darwin/AMD64 can have 64-bit thread id's, so we need to ensure we cast properly to... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7a2d387896587de98df35a5998dd1b334949365b;p=gc Darwin/AMD64 can have 64-bit thread id's, so we need to ensure we cast properly to make sure the modulus has a valid result. Additionally add support for x86_THREAD_STATE64. --- diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index d1993d44..da49c0a4 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -371,6 +371,8 @@ void GC_print_callers GC_PROTO((struct callinfo info[NFRAMES])); # define GC_MACH_THREAD_STATE_FLAVOR PPC_THREAD_STATE # elif defined(I386) # define GC_MACH_THREAD_STATE_FLAVOR i386_THREAD_STATE +# elif defined(X86_64) +# define GC_MACH_THREAD_STATE_FLAVOR x86_THREAD_STATE64 # else # define GC_MACH_THREAD_STATE_FLAVOR MACHINE_THREAD_STATE # endif diff --git a/pthread_support.c b/pthread_support.c index 3e588ace..96e8a011 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -729,7 +729,7 @@ void nacl_shutdown_gc_thread() /* Caller holds allocation lock. */ GC_thread GC_new_thread(pthread_t id) { - int hv = ((word)id) % THREAD_TABLE_SZ; + int hv = ((unsigned long)id) % THREAD_TABLE_SZ; GC_thread result; static GC_bool first_thread_used = FALSE; @@ -760,7 +760,7 @@ GC_thread GC_new_thread(pthread_t id) /* Caller holds allocation lock. */ void GC_delete_thread(pthread_t id) { - int hv = ((word)id) % THREAD_TABLE_SZ; + int hv = ((unsigned long)id) % THREAD_TABLE_SZ; register GC_thread p = GC_threads[hv]; register GC_thread prev = 0; @@ -796,7 +796,7 @@ void GC_delete_thread(pthread_t id) /* This is OK, but we need a way to delete a specific one. */ void GC_delete_gc_thread(pthread_t id, GC_thread gc_id) { - int hv = ((word)id) % THREAD_TABLE_SZ; + int hv = ((unsigned long)id) % THREAD_TABLE_SZ; register GC_thread p = GC_threads[hv]; register GC_thread prev = 0; @@ -825,7 +825,7 @@ void GC_delete_gc_thread(pthread_t id, GC_thread gc_id) /* return the most recent one. */ GC_thread GC_lookup_thread(pthread_t id) { - int hv = ((word)id) % THREAD_TABLE_SZ; + int hv = ((unsigned long)id) % THREAD_TABLE_SZ; register GC_thread p = GC_threads[hv]; while (p != 0 && !pthread_equal(p -> id, id)) p = p -> next;