From: Keith Seitz Date: Mon, 23 Apr 2007 21:10:09 +0000 (+0000) Subject: Add GC_is_thread_suspended API function X-Git-Tag: gc7_6_0~29^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d34d5b53d67b3ef6fa2d70a945e21f023cb9e3e7;p=gc 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 --- diff --git a/include/gc.h b/include/gc.h index d9f4e397..f8f764e1 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 f9e86c55..d8096332 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