mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
Improve static assertion macro.
This commit is contained in:
parent
51e8fe9cf0
commit
0a50356b6f
@ -239,7 +239,12 @@ static LJ_AINLINE uint32_t lj_fls(uint32_t x)
|
|||||||
/* Static assertions. */
|
/* Static assertions. */
|
||||||
#define LJ_ASSERT_NAME2(name, line) name ## line
|
#define LJ_ASSERT_NAME2(name, line) name ## line
|
||||||
#define LJ_ASSERT_NAME(line) LJ_ASSERT_NAME2(lj_assert_, 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) \
|
#define LJ_STATIC_ASSERT(cond) \
|
||||||
extern void LJ_ASSERT_NAME(__LINE__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1])
|
extern void LJ_ASSERT_NAME(__LINE__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1])
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -591,7 +591,6 @@ typedef union IRIns {
|
|||||||
check_exp((ir)->o == IR_KNUM || (ir)->o == IR_KINT64, mref((ir)->ptr,cTValue))
|
check_exp((ir)->o == IR_KNUM || (ir)->o == IR_KINT64, mref((ir)->ptr,cTValue))
|
||||||
#define ir_kptr(ir) \
|
#define ir_kptr(ir) \
|
||||||
check_exp((ir)->o == IR_KPTR || (ir)->o == IR_KKPTR, mref((ir)->ptr, void))
|
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. */
|
/* A store or any other op with a non-weak guard has a side-effect. */
|
||||||
static LJ_AINLINE int ir_sideeff(IRIns *ir)
|
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);
|
return (((ir->t.irt | ~IRT_GUARD) & lj_ir_mode[ir->o]) >= IRM_S);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LJ_STATIC_ASSERT((int)IRT_GUARD == (int)IRM_W);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user