summaryrefslogtreecommitdiff
path: root/win32_threads.c
diff options
context:
space:
mode:
authorivmai <ivmai>2010-03-05 15:26:16 +0100
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:53 +0200
commitc7047ca9e961af21c6a520a0765d1226ab510377 (patch)
tree059fad9889091d68a5e75ff3f7dc11759d80f3d2 /win32_threads.c
parentb53f714c2d40de8edbfb635e554f027276d66d20 (diff)
2010-03-05 Ivan Maidanski <ivmai@mail.ru>
* alloc.c (GC_set_stop_func, GC_get_stop_func): Add DCL_LOCK_STATE. * finalize.c (GC_notify_or_invoke_finalizers): Ditto. * gc_dlopen.c (disable_gc_for_dlopen): Ditto. * gcj_mlc.c (maybe_finalize, GC_debug_gcj_malloc): Ditto. * mark.c (GC_print_trace): Ditto. * misc.c (GC_set_warn_proc, GC_get_warn_proc, GC_enable, GC_disable, GC_new_free_list, GC_new_kind, GC_new_proc, GC_set_oom_fn, GC_get_oom_fn, GC_set_finalizer_notifier, GC_get_finalizer_notifier): Ditto. * os_dep.c (GC_get_stack_base, GC_print_callers): Ditto. * pthread_support.c (GC_is_thread_tsd_valid, GC_wait_for_gc_completion, GC_init_parallel, GC_do_blocking_inner, GC_call_with_gc_active, GC_unregister_my_thread, pthread_join, pthread_detach, GC_register_my_thread, GC_inner_start_routine, pthread_create): Ditto. * reclaim.c (GC_print_all_errors): Ditto. * win32_threads.c (GC_is_thread_tsd_valid, GC_register_my_thread, GC_unregister_my_thread, GC_do_blocking_inner, GC_call_with_gc_active, GC_lookup_pthread, GC_pthread_join, GC_pthread_start_inner, GC_thread_exit_proc, GC_pthread_detach, GC_init_parallel): Ditto.
Diffstat (limited to 'win32_threads.c')
-rw-r--r--win32_threads.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/win32_threads.c b/win32_threads.c
index 1c13e69..9e852fa 100644
--- a/win32_threads.c
+++ b/win32_threads.c
@@ -571,6 +571,8 @@ GC_INNER unsigned *GC_check_finalizer_nested(void)
GC_bool GC_is_thread_tsd_valid(void *tsd)
{
char *me;
+ DCL_LOCK_STATE;
+
LOCK();
me = (char *)GC_lookup_thread_inner(GetCurrentThreadId());
UNLOCK();
@@ -706,6 +708,7 @@ GC_API void GC_CALL GC_allow_register_threads(void)
GC_API int GC_CALL GC_register_my_thread(const struct GC_stack_base *sb)
{
DWORD t = GetCurrentThreadId();
+ DCL_LOCK_STATE;
if (GC_need_to_lock == FALSE)
ABORT("Threads explicit registering is not previously enabled");
@@ -725,6 +728,8 @@ GC_API int GC_CALL GC_register_my_thread(const struct GC_stack_base *sb)
GC_API int GC_CALL GC_unregister_my_thread(void)
{
DWORD t = GetCurrentThreadId();
+ DCL_LOCK_STATE;
+
/* FIXME: is GC_wait_for_gc_completion(FALSE) needed here? */
if (GC_win32_dll_threads) {
# if defined(THREAD_LOCAL_ALLOC)
@@ -757,6 +762,8 @@ GC_INNER void GC_do_blocking_inner(ptr_t data, void * context)
struct blocking_data * d = (struct blocking_data *) data;
DWORD t = GetCurrentThreadId();
GC_thread me;
+ DCL_LOCK_STATE;
+
LOCK();
me = GC_lookup_thread_inner(t);
GC_ASSERT(me -> thread_blocked_sp == NULL);
@@ -781,6 +788,8 @@ GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn,
{
struct GC_traced_stack_sect_s stacksect;
GC_thread me;
+ DCL_LOCK_STATE;
+
LOCK(); /* This will block if the world is stopped. */
me = GC_lookup_thread_inner(GetCurrentThreadId());
@@ -871,6 +880,7 @@ GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn,
word hv_guess = THREAD_TABLE_INDEX(GET_PTHREAD_MAP_CACHE(id));
int hv;
GC_thread p;
+ DCL_LOCK_STATE;
LOCK();
for (p = GC_threads[hv_guess]; 0 != p; p = p -> tm.next) {
@@ -2342,6 +2352,8 @@ GC_INNER void GC_thr_init(void)
# endif
if (!GC_win32_dll_threads) {
+ DCL_LOCK_STATE;
+
LOCK();
GC_delete_gc_thread(joinee);
UNLOCK();
@@ -2415,6 +2427,7 @@ GC_INNER void GC_thr_init(void)
DWORD thread_id = GetCurrentThreadId();
pthread_t pthread_id = pthread_self();
GC_thread me;
+ DCL_LOCK_STATE;
# if DEBUG_CYGWIN_THREADS
GC_printf("thread 0x%x(0x%x) starting...\n",(int)pthread_id,
@@ -2468,6 +2481,7 @@ GC_INNER void GC_thr_init(void)
STATIC void GC_thread_exit_proc(void *arg)
{
GC_thread me = (GC_thread)arg;
+ DCL_LOCK_STATE;
GC_ASSERT(!GC_win32_dll_threads);
# if DEBUG_CYGWIN_THREADS
@@ -2507,6 +2521,7 @@ GC_INNER void GC_thr_init(void)
{
int result;
GC_thread thread_gc_id;
+ DCL_LOCK_STATE;
if (!parallel_initialized) GC_init_parallel();
LOCK();
@@ -2612,6 +2627,10 @@ GC_INNER void GC_thr_init(void)
/* Must be called before a second thread is created. */
GC_INNER void GC_init_parallel(void)
{
+# if defined(THREAD_LOCAL_ALLOC)
+ DCL_LOCK_STATE;
+# endif
+
if (parallel_initialized) return;
parallel_initialized = TRUE;
/* GC_init() calls us back, so set flag first. */