summaryrefslogtreecommitdiff
path: root/win32_threads.c
diff options
context:
space:
mode:
authorivmai <ivmai>2010-10-05 09:07:06 +0200
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:55 +0200
commit34867e9d2269c71f9753f7ce472904f9c4528a28 (patch)
treecbbe4beac7d1083cfcddf204324f43eeae6020cf /win32_threads.c
parent0563224f6bb7401823f126f82aeb6ef95765d4b3 (diff)
2010-10-05 Ivan Maidanski <ivmai@mail.ru>
* finalize.c (GC_check_finalizer_nested): Change return type to char pointer (instead of int pointer); use explicit cast for GC_finalizer_nested assignment. * pthread_support.c (GC_check_finalizer_nested): Ditto. * win32_threads.c (GC_check_finalizer_nested): Ditto. * finalize.c (GC_finalizer_nested): Change type to unsigned char. * finalize.c (GC_notify_or_invoke_finalizers): Change type of "pnested" local variable to char pointer. * pthread_support.c (GC_do_blocking_inner, GC_call_with_gc_active): Use explicit cast for "thread_blocked" field assignment. * win32_threads.c (GC_lookup_pthread): Use explicit cast for "suspended" field assignment. * win32_threads.c (GC_Thread_Rep): Use short type for finalizer_skipped; use char type for finalizer_nested and flags fields and reorder some fields (to minimize GC_Thread_Rep structure size). * include/private/pthread_support.h (GC_Thread_Rep): Ditto. * win32_threads.c (GC_Thread_Rep): Use char type for suspended field (instead of GC_bool). * include/private/pthread_support.h (GC_Thread_Rep): Use char type for thread_blocked field (instead of short).
Diffstat (limited to 'win32_threads.c')
-rw-r--r--win32_threads.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/win32_threads.c b/win32_threads.c
index f3a4830..40f3915 100644
--- a/win32_threads.c
+++ b/win32_threads.c
@@ -224,24 +224,26 @@ struct GC_Thread_Rep {
/* GC_call_with_gc_active() of this */
/* thread. May be NULL. */
- unsigned finalizer_nested;
- unsigned finalizer_skipped; /* Used by GC_check_finalizer_nested() */
+ unsigned short finalizer_skipped;
+ unsigned char finalizer_nested;
+ /* Used by GC_check_finalizer_nested() */
/* to minimize the level of recursion */
/* when a client finalizer allocates */
/* memory (initially both are 0). */
- GC_bool suspended;
+ unsigned char suspended; /* really of GC_bool type */
# ifdef GC_PTHREADS
- void *status; /* hold exit value until join in case it's a pointer */
- pthread_t pthread_id;
- short flags; /* Protected by GC lock. */
+ unsigned char flags; /* Protected by GC lock. */
# define FINISHED 1 /* Thread has exited. */
# define DETACHED 2 /* Thread is intended to be detached. */
# define KNOWN_FINISHED(t) (((t) -> flags) & FINISHED)
+ pthread_t pthread_id;
+ void *status; /* hold exit value until join in case it's a pointer */
# else
# define KNOWN_FINISHED(t) 0
# endif
+
# ifdef THREAD_LOCAL_ALLOC
struct thread_local_freelists tlfs;
# endif
@@ -551,7 +553,7 @@ GC_INNER void GC_reset_finalizer_nested(void)
/* otherwise returns a pointer to the thread-local finalizer_nested. */
/* Called by GC_notify_or_invoke_finalizers() only (the lock is held). */
/* GC_check_finalizer_nested() is the same as in pthread_support.c. */
-GC_INNER unsigned *GC_check_finalizer_nested(void)
+GC_INNER unsigned char *GC_check_finalizer_nested(void)
{
GC_thread me = GC_lookup_thread_inner(GetCurrentThreadId());
unsigned nesting_level = me->finalizer_nested;
@@ -562,7 +564,7 @@ GC_INNER unsigned *GC_check_finalizer_nested(void)
if (++me->finalizer_skipped < (1U << nesting_level)) return NULL;
me->finalizer_skipped = 0;
}
- me->finalizer_nested = nesting_level + 1;
+ me->finalizer_nested = (unsigned char)(nesting_level + 1);
return &me->finalizer_nested;
}
@@ -974,7 +976,7 @@ STATIC void GC_suspend(GC_thread t)
if (SuspendThread(t -> handle) == (DWORD)-1)
ABORT("SuspendThread failed");
# endif /* !MSWINCE */
- t -> suspended = TRUE;
+ t -> suspended = (unsigned char)TRUE;
# if defined(MPROTECT_VDB)
AO_CLEAR(&GC_fault_handler_lock);
# endif