summaryrefslogtreecommitdiff
path: root/pthread_support.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-04-22 09:24:35 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-04-22 09:24:35 +0300
commit70ffca11f715b7fcc251ed1cfbcfb82b50176b62 (patch)
tree0c20d12e900fc77a939a540d52cb751d962ddf2b /pthread_support.c
parent655c1486b69ce514a726a59eb73012ebc3803469 (diff)
downloadbdwgc-70ffca11f715b7fcc251ed1cfbcfb82b50176b62.tar.gz
Eliminate 'GC_reset_finalizer_nested defined but not used' compiler warning
(fix of commit c14335e44) * include/private/gc_priv.h [THREADS] (GC_reset_finalizer_nested, GC_check_finalizer_nested): Do not declare if GC_NO_FINALIZATION. * include/private/pthread_support.h (GC_Thread_Rep.finalizer_skipped, GC_Thread_Rep.finalizer_nested): Do not declare field if GC_NO_FINALIZATION. * win32_threads.c (GC_Thread_Rep.finalizer_skipped, GC_Thread_Rep.finalizer_nested): Likewise. * pthread_support.c (GC_reset_finalizer_nested, GC_check_finalizer_nested): Do not define if GC_NO_FINALIZATION. * win32_threads.c (GC_reset_finalizer_nested, GC_check_finalizer_nested): Likewise. * win32_threads.c (GC_check_finalizer_nested): Remove comment copied from pthread_support.c.
Diffstat (limited to 'pthread_support.c')
-rw-r--r--pthread_support.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/pthread_support.c b/pthread_support.c
index 59b8e898..2ae5c208 100644
--- a/pthread_support.c
+++ b/pthread_support.c
@@ -720,32 +720,37 @@ GC_INNER GC_thread GC_lookup_thread(pthread_t id)
return(p);
}
-/* Called by GC_finalize() (in case of an allocation failure observed). */
-GC_INNER void GC_reset_finalizer_nested(void)
-{
- GC_thread me = GC_lookup_thread(pthread_self());
- me->finalizer_nested = 0;
-}
+#ifndef GC_NO_FINALIZATION
+ /* Called by GC_finalize() (in case of an allocation failure observed). */
+ GC_INNER void GC_reset_finalizer_nested(void)
+ {
+ GC_thread me = GC_lookup_thread(pthread_self());
-/* Checks and updates the thread-local level of finalizers recursion. */
-/* Returns NULL if GC_invoke_finalizers() should not be called by the */
-/* collector (to minimize the risk of a deep finalizers recursion), */
-/* otherwise returns a pointer to the thread-local finalizer_nested. */
-/* Called by GC_notify_or_invoke_finalizers() only (the lock is held). */
-GC_INNER unsigned char *GC_check_finalizer_nested(void)
-{
- GC_thread me = GC_lookup_thread(pthread_self());
- unsigned nesting_level = me->finalizer_nested;
- if (nesting_level) {
- /* We are inside another GC_invoke_finalizers(). */
- /* Skip some implicitly-called GC_invoke_finalizers() */
- /* depending on the nesting (recursion) level. */
- if (++me->finalizer_skipped < (1U << nesting_level)) return NULL;
- me->finalizer_skipped = 0;
+ me->finalizer_nested = 0;
}
- me->finalizer_nested = (unsigned char)(nesting_level + 1);
- return &me->finalizer_nested;
-}
+
+ /* Checks and updates the thread-local level of finalizers recursion. */
+ /* Returns NULL if GC_invoke_finalizers() should not be called by the */
+ /* collector (to minimize the risk of a deep finalizers recursion), */
+ /* otherwise returns a pointer to the thread-local finalizer_nested. */
+ /* Called by GC_notify_or_invoke_finalizers() only (the GC lock is */
+ /* held). */
+ GC_INNER unsigned char *GC_check_finalizer_nested(void)
+ {
+ GC_thread me = GC_lookup_thread(pthread_self());
+ unsigned nesting_level = me->finalizer_nested;
+
+ if (nesting_level) {
+ /* We are inside another GC_invoke_finalizers(). */
+ /* Skip some implicitly-called GC_invoke_finalizers() */
+ /* depending on the nesting (recursion) level. */
+ if (++me->finalizer_skipped < (1U << nesting_level)) return NULL;
+ me->finalizer_skipped = 0;
+ }
+ me->finalizer_nested = (unsigned char)(nesting_level + 1);
+ return &me->finalizer_nested;
+ }
+#endif /* !GC_NO_FINALIZATION */
#if defined(GC_ASSERTIONS) && defined(THREAD_LOCAL_ALLOC)
/* This is called from thread-local GC_malloc(). */