From 0a50356b6f7d256af36fbf564b73c5721681cb56 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Mon, 7 Feb 2011 21:44:01 +0100 Subject: Improve static assertion macro. --- src/lj_def.h | 5 +++++ src/lj_ir.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lj_def.h b/src/lj_def.h index 57946647..ac457cf5 100644 --- a/src/lj_def.h +++ b/src/lj_def.h @@ -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 diff --git a/src/lj_ir.h b/src/lj_ir.h index 532d7a9e..ae533939 100644 --- a/src/lj_ir.h +++ b/src/lj_ir.h @@ -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 -- cgit v1.2.3-55-g6feb