(Apply commit
9b40e5d from 'mono_libgc' branch)
* include/gc.h (GC_thread_is_registered): Declare new API function
(only if GC_THREADS).
* pthread_support.c (GC_thread_is_registered): New API function
implementation.
* win32_threads.c (GC_thread_is_registered): Likewise.
/* A manually registered thread requires manual unregistering. */
GC_API int GC_CALL GC_register_my_thread(const struct GC_stack_base *);
+ /* Return TRUE if and only if the calling thread is registered with */
+ /* the garbage collector. */
+ GC_API int GC_CALL GC_thread_is_registered(void);
+
/* Unregister the current thread. Only an explicitly registered */
/* thread (i.e. for which GC_register_my_thread() returns GC_SUCCESS) */
/* is allowed (and required) to call this function. (As a special */
}
#endif /* GC_ASSERTIONS && THREAD_LOCAL_ALLOC */
+GC_API int GC_CALL GC_thread_is_registered(void)
+{
+ void *ptr;
+
+ LOCK();
+ ptr = (void *)GC_lookup_thread(pthread_self());
+ UNLOCK();
+
+ return ptr ? 1 : 0;
+}
+
#ifdef HANDLE_FORK
/* Remove all entries from the GC_threads table, except the */
/* one for the current thread. We need to do this in the child */
}
#endif /* GC_ASSERTIONS && THREAD_LOCAL_ALLOC */
+GC_API int GC_CALL GC_thread_is_registered(void)
+{
+ /* FIXME: Works only if registered by DllMain */
+ return 1;
+}
+
/* Make sure thread descriptor t is not protected by the VDB */
/* implementation. */
/* Used to prevent write faults when the world is (partially) stopped, */