The following variant should be faster than the usual g_assert() because the generated code is smaller which allows better optimization and is more cache-friendly.
Look at the generated code for functions which use assertion checks to see the difference.
Taking advantage of it may require using -momit-leaf-frame-pointer or -fomit-frame-pointer for GCC and an appropriate -march option is also recommended.
Go to the source code of this file.
Data Structures | |
| struct | assertion_data |
Defines | |
| #define | RUNTIME_ASSERT(expr) fast_assert(expr, #expr) |
| #define | RUNTIME_UNREACHABLE() fast_assert_not_reached() |
| #define | fast_assert(expr, expr_string) |
| #define | fast_assert_not_reached() |
| #define | return_unless(expr) return_unless_intern((expr), #expr) |
| #define | return_unless_intern(expr, expr_string) |
| #define | return_value_unless(expr, val) return_value_unless_intern((expr), #expr, val) |
| #define | return_value_unless_intern(expr, expr_string, val) |
Typedefs | |
| typedef assertion_data | assertion_data |
Functions | |
| void G_GNUC_NORETURN | REGPARM (1) assertion_failure(const assertion_data *const data) |
|
|
Value: G_STMT_START { \
if (G_UNLIKELY(!(expr))) { \
static const struct assertion_data assertion_data_ = { \
__FILE__, expr_string, __LINE__ \
}; \
assertion_failure(&assertion_data_); \
} \
} G_STMT_END
|
|
|
Value: G_STMT_START { \
static const struct assertion_data assertion_data_ = { \
__FILE__, NULL, __LINE__ \
}; \
assertion_failure(&assertion_data_); \
} G_STMT_END
|
|
|
|
|
|
Value: G_STMT_START { \
if (G_UNLIKELY(!(expr))) { \
static const struct assertion_data assertion_data_ = { \
__FILE__, expr_string, __LINE__ \
}; \
assertion_warning(&assertion_data_); \
return; \
} \
} G_STMT_END
|
|
|
|
|
|
Value: G_STMT_START { \
if (G_UNLIKELY(!(expr))) { \
static const struct assertion_data assertion_data_ = { \
__FILE__, expr_string, __LINE__ \
}; \
assertion_warning(&assertion_data_); \
return (val); \
} \
} G_STMT_END
|
|
|
|
|
|
|
|
|
|
|
|
|
1.3.9.1