Refactor checks to improve codegen.

This commit is contained in:
Matthew Parkinson
2021-03-17 18:41:56 +00:00
committed by Matthew Parkinson
parent 0983f1837b
commit ed615eade9
4 changed files with 73 additions and 89 deletions

View File

@@ -8,6 +8,22 @@ namespace snmalloc
// calling the API correctly.
#if !defined(NDEBUG) && !defined(CHECK_CLIENT)
# define CHECK_CLIENT
#endif
SNMALLOC_FAST_PATH void check_client_impl(bool test, const char* const str)
{
#ifdef CHECK_CLIENT
if (unlikely(!test))
error(str);
#else
UNUSED(test);
UNUSED(str);
#endif
}
#ifdef CHECK_CLIENT
# define check_client(test, str) check_client_impl(test, str)
#else
# define check_client(test, str)
#endif
// 0 intermediate bits results in power of 2 small allocs. 1 intermediate