mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 19:20:35 +01:00
shared: add NM_MORE_ASSERT_ONCE() macro
This commit is contained in:
parent
d9d51dd42d
commit
14461e7217
1 changed files with 18 additions and 0 deletions
|
|
@ -1023,6 +1023,24 @@ nm_str_realloc (char *str)
|
|||
#define nm_assert_not_reached() G_STMT_START { ; } G_STMT_END
|
||||
#endif
|
||||
|
||||
/* Usage:
|
||||
*
|
||||
* if (NM_MORE_ASSERT_ONCE (5)) { extra_check (); }
|
||||
*
|
||||
* This will only run the check once, and only if NM_MORE_ASSERT is >= than
|
||||
* more_assert_level.
|
||||
*/
|
||||
#define NM_MORE_ASSERT_ONCE(more_assert_level) \
|
||||
( (NM_MORE_ASSERTS >= (more_assert_level)) \
|
||||
&& ({ \
|
||||
static volatile int _assert_once = 0; \
|
||||
\
|
||||
G_STATIC_ASSERT_EXPR ((more_assert_level) >= 0); \
|
||||
\
|
||||
G_UNLIKELY ( _assert_once == 0 \
|
||||
&& g_atomic_int_compare_and_exchange (&_assert_once, 0, 1)); \
|
||||
}))
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define NM_GOBJECT_PROPERTIES_DEFINE_BASE(...) \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue