diff options
author | Mike Pall <mike> | 2011-02-07 21:44:01 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2011-02-07 21:44:01 +0100 |
commit | 0a50356b6f7d256af36fbf564b73c5721681cb56 (patch) | |
tree | 8fa2810358cb9b4b97fbab925098ce0255127dbe | |
parent | 51e8fe9cf0738706dbcaae51774faffebfa389f0 (diff) | |
download | luajit-0a50356b6f7d256af36fbf564b73c5721681cb56.tar.gz luajit-0a50356b6f7d256af36fbf564b73c5721681cb56.tar.bz2 luajit-0a50356b6f7d256af36fbf564b73c5721681cb56.zip |
Improve static assertion macro.
-rw-r--r-- | src/lj_def.h | 5 | ||||
-rw-r--r-- | src/lj_ir.h | 3 |
2 files changed, 7 insertions, 1 deletions
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) | |||
239 | /* Static assertions. */ | 239 | /* Static assertions. */ |
240 | #define LJ_ASSERT_NAME2(name, line) name ## line | 240 | #define LJ_ASSERT_NAME2(name, line) name ## line |
241 | #define LJ_ASSERT_NAME(line) LJ_ASSERT_NAME2(lj_assert_, line) | 241 | #define LJ_ASSERT_NAME(line) LJ_ASSERT_NAME2(lj_assert_, line) |
242 | #ifdef __COUNTER__ | ||
243 | #define LJ_STATIC_ASSERT(cond) \ | ||
244 | extern void LJ_ASSERT_NAME(__COUNTER__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1]) | ||
245 | #else | ||
242 | #define LJ_STATIC_ASSERT(cond) \ | 246 | #define LJ_STATIC_ASSERT(cond) \ |
243 | extern void LJ_ASSERT_NAME(__LINE__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1]) | 247 | extern void LJ_ASSERT_NAME(__LINE__)(int STATIC_ASSERTION_FAILED[(cond)?1:-1]) |
248 | #endif | ||
244 | 249 | ||
245 | #endif | 250 | #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 { | |||
591 | check_exp((ir)->o == IR_KNUM || (ir)->o == IR_KINT64, mref((ir)->ptr,cTValue)) | 591 | check_exp((ir)->o == IR_KNUM || (ir)->o == IR_KINT64, mref((ir)->ptr,cTValue)) |
592 | #define ir_kptr(ir) \ | 592 | #define ir_kptr(ir) \ |
593 | check_exp((ir)->o == IR_KPTR || (ir)->o == IR_KKPTR, mref((ir)->ptr, void)) | 593 | check_exp((ir)->o == IR_KPTR || (ir)->o == IR_KKPTR, mref((ir)->ptr, void)) |
594 | LJ_STATIC_ASSERT((int)IRT_GUARD == (int)IRM_W); | ||
595 | 594 | ||
596 | /* A store or any other op with a non-weak guard has a side-effect. */ | 595 | /* A store or any other op with a non-weak guard has a side-effect. */ |
597 | static LJ_AINLINE int ir_sideeff(IRIns *ir) | 596 | static LJ_AINLINE int ir_sideeff(IRIns *ir) |
@@ -599,4 +598,6 @@ static LJ_AINLINE int ir_sideeff(IRIns *ir) | |||
599 | return (((ir->t.irt | ~IRT_GUARD) & lj_ir_mode[ir->o]) >= IRM_S); | 598 | return (((ir->t.irt | ~IRT_GUARD) & lj_ir_mode[ir->o]) >= IRM_S); |
600 | } | 599 | } |
601 | 600 | ||
601 | LJ_STATIC_ASSERT((int)IRT_GUARD == (int)IRM_W); | ||
602 | |||
602 | #endif | 603 | #endif |