The check_bsf() macro uses assert(mutex_trylock(&bsf_lock)) and assumes bsf_lock is locked afterwards. This breaks when compiling with NOASSERTS="yes". Also: macro to function transition.