Improve static assertion macro.

This commit is contained in:
Mike Pall 2011-02-07 21:44:01 +01:00
parent 51e8fe9cf0
commit 0a50356b6f
2 changed files with 7 additions and 1 deletions

View File

@ -239,7 +239,12 @@ static LJ_AINLINE uint32_t lj_fls(uint32_t x)
/* Static assertions. */
#define LJ_ASSERT_NAME2(name, line) name ## line
#define LJ_ASSERT_NAME(line) LJ_ASSERT_NAME2(lj_assert_, line)
#ifdef __COUNTER__
#define LJ_STATIC_ASSERT(cond) \
extern void LJ_ASSERT_NAME(__COUNTER__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1])
#else
#define LJ_STATIC_ASSERT(cond) \
extern void LJ_ASSERT_NAME(__LINE__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1])
#endif
#endif

View File

@ -591,7 +591,6 @@ typedef union IRIns {
check_exp((ir)->o == IR_KNUM || (ir)->o == IR_KINT64, mref((ir)->ptr,cTValue))
#define ir_kptr(ir) \
check_exp((ir)->o == IR_KPTR || (ir)->o == IR_KKPTR, mref((ir)->ptr, void))
LJ_STATIC_ASSERT((int)IRT_GUARD == (int)IRM_W);
/* A store or any other op with a non-weak guard has a side-effect. */
static LJ_AINLINE int ir_sideeff(IRIns *ir)
@ -599,4 +598,6 @@ static LJ_AINLINE int ir_sideeff(IRIns *ir)
return (((ir->t.irt | ~IRT_GUARD) & lj_ir_mode[ir->o]) >= IRM_S);
}
LJ_STATIC_ASSERT((int)IRT_GUARD == (int)IRM_W);
#endif