glib/glib-private: Mark the dynamic LSAN checks as unlikely

It's not normal to run programs with leak sanitizer enabled, so let's
mark those checks as such, in case the compiler can optimize them
This commit is contained in:
Marco Trevisan (Treviño) 2024-05-10 01:51:22 +02:00
parent 0bb6841568
commit 1a72a697ad

View File

@ -100,7 +100,7 @@ g_leak_sanitizer_is_supported (void)
#if defined (_GLIB_ADDRESS_SANITIZER)
return TRUE;
#elif defined (HAS_DYNAMIC_ASAN_LOADING)
return __lsan_enable != NULL && __lsan_ignore_object != NULL;
return G_UNLIKELY (__lsan_enable != NULL && __lsan_ignore_object != NULL);
#else
return FALSE;
#endif
@ -122,7 +122,7 @@ g_ignore_leak (gconstpointer p)
if (p != NULL)
__lsan_ignore_object (p);
#elif defined (HAS_DYNAMIC_ASAN_LOADING)
if (p != NULL && __lsan_ignore_object != NULL)
if (G_LIKELY (p != NULL) && G_UNLIKELY (__lsan_ignore_object != NULL))
__lsan_ignore_object (p);
#endif
}
@ -166,7 +166,7 @@ g_begin_ignore_leaks (void)
#if defined (_GLIB_ADDRESS_SANITIZER)
__lsan_disable ();
#elif defined (HAS_DYNAMIC_ASAN_LOADING)
if (__lsan_disable != NULL)
if (G_UNLIKELY (__lsan_disable != NULL))
__lsan_disable ();
#endif
}
@ -183,7 +183,7 @@ g_end_ignore_leaks (void)
#if defined (_GLIB_ADDRESS_SANITIZER)
__lsan_enable ();
#elif defined (HAS_DYNAMIC_ASAN_LOADING)
if (__lsan_enable != NULL)
if (G_UNLIKELY (__lsan_enable != NULL))
__lsan_enable ();
#endif
}