From d34d5b53d67b3ef6fa2d70a945e21f023cb9e3e7 Mon Sep 17 00:00:00 2001 From: Keith Seitz Date: Mon, 23 Apr 2007 21:10:09 +0000 Subject: [PATCH] Add GC_is_thread_suspended API function (Cherry-picked commit 30c2f0e from 'gcc_boehmgc' branch.) * include/gc.h (GC_is_thread_suspended): Declare. * pthread_stop_world.c (GC_is_thread_suspended): New function. Conflicts: * ChangeLog * include/gc.h * pthread_stop_world.c --- include/gc.h | 1 + pthread_stop_world.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/include/gc.h b/include/gc.h index d9f4e39..f8f764e 100644 --- a/include/gc.h +++ b/include/gc.h @@ -1921,6 +1921,7 @@ GC_API void GC_CALL GC_win32_free_heap(void); && !defined(GC_WIN32_THREADS) && !defined(GC_DARWIN_THREADS) GC_API void GC_suspend_thread(pthread_t); GC_API void GC_resume_thread(pthread_t); +GC_API int GC_is_thread_suspended(pthread_t); #endif #ifdef __cplusplus diff --git a/pthread_stop_world.c b/pthread_stop_world.c index f9e86c5..d809633 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -412,6 +412,14 @@ void GC_resume_thread(pthread_t thread) { t -> flags &= ~SUSPENDED_EXT; } +int GC_is_thread_suspended(pthread_t thread) { + GC_thread t = GC_lookup_thread(thread); + if (t == NULL) + ABORT("querying suspension state of unknown thread"); + + return (t -> flags & SUSPENDED_EXT); +} + #endif /* !GC_OPENBSD_UTHREADS && !NACL */ #ifdef IA64 -- 2.7.4