diff options
author | Mike Pall <mike> | 2011-03-10 02:13:43 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2011-03-10 02:13:43 +0100 |
commit | 889368e921a11e2abb3769e2c1f395174e83112d (patch) | |
tree | a0280bec2142380ce13b1afc2d8e17fcd65e29e9 /src/lj_bc.h | |
parent | bfce3c1127fd57fe0c935c92bcf45b4737041edd (diff) | |
download | luajit2-889368e921a11e2abb3769e2c1f395174e83112d.tar.gz |
Get rid of the remaining silly cast macros from Lua.
Diffstat (limited to 'src/lj_bc.h')
-rw-r--r-- | src/lj_bc.h | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/lj_bc.h b/src/lj_bc.h index 9dffe0c0..97e4d926 100644 --- a/src/lj_bc.h +++ b/src/lj_bc.h @@ -31,30 +31,29 @@ #define NO_JMP (~(BCPos)0) /* Macros to get instruction fields. */ -#define bc_op(i) (cast(BCOp, (i)&0xff)) -#define bc_a(i) (cast(BCReg, ((i)>>8)&0xff)) -#define bc_b(i) (cast(BCReg, (i)>>24)) -#define bc_c(i) (cast(BCReg, ((i)>>16)&0xff)) -#define bc_d(i) (cast(BCReg, (i)>>16)) +#define bc_op(i) ((BCOp)((i)&0xff)) +#define bc_a(i) ((BCReg)(((i)>>8)&0xff)) +#define bc_b(i) ((BCReg)((i)>>24)) +#define bc_c(i) ((BCReg)(((i)>>16)&0xff)) +#define bc_d(i) ((BCReg)((i)>>16)) #define bc_j(i) ((ptrdiff_t)bc_d(i)-BCBIAS_J) /* Macros to set instruction fields. */ #define setbc_byte(p, x, ofs) \ - ((uint8_t *)(p))[LJ_ENDIAN_SELECT(ofs, 3-ofs)] = cast_byte(x) + ((uint8_t *)(p))[LJ_ENDIAN_SELECT(ofs, 3-ofs)] = (uint8_t)(x) #define setbc_op(p, x) setbc_byte(p, (x), 0) #define setbc_a(p, x) setbc_byte(p, (x), 1) #define setbc_b(p, x) setbc_byte(p, (x), 3) #define setbc_c(p, x) setbc_byte(p, (x), 2) #define setbc_d(p, x) \ - ((uint16_t *)(p))[LJ_ENDIAN_SELECT(1, 0)] = cast(uint16_t, (x)) + ((uint16_t *)(p))[LJ_ENDIAN_SELECT(1, 0)] = (uint16_t)(x) #define setbc_j(p, x) setbc_d(p, (BCPos)((int32_t)(x)+BCBIAS_J)) /* Macros to compose instructions. */ #define BCINS_ABC(o, a, b, c) \ - (cast(BCIns, o)|(cast(BCIns, a)<<8)|\ - (cast(BCIns, b)<<24)|(cast(BCIns, c)<<16)) + (((BCIns)(o))|((BCIns)(a)<<8)|((BCIns)(b)<<24)|((BCIns)(c)<<16)) #define BCINS_AD(o, a, d) \ - (cast(BCIns, o)|(cast(BCIns, a)<<8)|(cast(BCIns, d)<<16)) + (((BCIns)(o))|((BCIns)(a)<<8)|((BCIns)(d)<<16)) #define BCINS_AJ(o, a, j) BCINS_AD(o, a, (BCPos)((int32_t)(j)+BCBIAS_J)) /* Bytecode instruction definition. Order matters, see below. @@ -240,12 +239,12 @@ typedef enum { } BCMode; #define BCM___ BCMnone -#define bcmode_a(op) (cast(BCMode, lj_bc_mode[op] & 7)) -#define bcmode_b(op) (cast(BCMode, (lj_bc_mode[op]>>3) & 15)) -#define bcmode_c(op) (cast(BCMode, (lj_bc_mode[op]>>7) & 15)) +#define bcmode_a(op) ((BCMode)(lj_bc_mode[op] & 7)) +#define bcmode_b(op) ((BCMode)((lj_bc_mode[op]>>3) & 15)) +#define bcmode_c(op) ((BCMode)((lj_bc_mode[op]>>7) & 15)) #define bcmode_d(op) bcmode_c(op) #define bcmode_hasd(op) ((lj_bc_mode[op] & (15<<3)) == (BCMnone<<3)) -#define bcmode_mm(op) (cast(MMS, lj_bc_mode[op]>>11)) +#define bcmode_mm(op) ((MMS)(lj_bc_mode[op]>>11)) #define BCMODE(name, ma, mb, mc, mm) \ (BCM##ma|(BCM##mb<<3)|(BCM##mc<<7)|(MM_##mm<<11)), |