Sand edges down on GBIT64()/PBIT64() macros.

Now, you can safely use them in unbraced if statements, and
with char*s.
This commit is contained in:
Ori Bernstein 2019-05-06 17:26:38 -07:00
parent c9086fb348
commit ceed9b8853

View file

@ -61,17 +61,20 @@ struct Fcall
} Fcall; } Fcall;
#define GBIT8(p) ((p)[0]) #define GBIT8(p) (((uchar*)(p))[0])
#define GBIT16(p) ((p)[0]|((p)[1]<<8)) #define GBIT16(p) (((uchar*)(p))[0]|(((uchar*)(p))[1]<<8))
#define GBIT32(p) ((p)[0]|((p)[1]<<8)|((p)[2]<<16)|((p)[3]<<24)) #define GBIT32(p) (((uchar*)(p))[0]|(((uchar*)(p))[1]<<8)|\
#define GBIT64(p) ((u32int)((p)[0]|((p)[1]<<8)|((p)[2]<<16)|((p)[3]<<24)) |\ (((uchar*)(p))[2]<<16)|(((uchar*)(p))[3]<<24))
((vlong)((p)[4]|((p)[5]<<8)|((p)[6]<<16)|((p)[7]<<24)) << 32)) #define GBIT64(p) ((u32int)(((uchar*)(p))[0]|(((uchar*)(p))[1]<<8)|\
(((uchar*)(p))[2]<<16)|(((uchar*)(p))[3]<<24)) |\
((uvlong)(((uchar*)(p))[4]|(((uchar*)(p))[5]<<8)|\
(((uchar*)(p))[6]<<16)|(((uchar*)(p))[7]<<24)) << 32))
#define PBIT8(p,v) (p)[0]=(v) #define PBIT8(p,v) do{(p)[0]=(v);}while(0)
#define PBIT16(p,v) (p)[0]=(v);(p)[1]=(v)>>8 #define PBIT16(p,v) do{(p)[0]=(v);(p)[1]=(v)>>8;}while(0)
#define PBIT32(p,v) (p)[0]=(v);(p)[1]=(v)>>8;(p)[2]=(v)>>16;(p)[3]=(v)>>24 #define PBIT32(p,v) do{(p)[0]=(v);(p)[1]=(v)>>8;(p)[2]=(v)>>16;(p)[3]=(v)>>24;}while(0)
#define PBIT64(p,v) (p)[0]=(v);(p)[1]=(v)>>8;(p)[2]=(v)>>16;(p)[3]=(v)>>24;\ #define PBIT64(p,v) do{(p)[0]=(v);(p)[1]=(v)>>8;(p)[2]=(v)>>16;(p)[3]=(v)>>24;\
(p)[4]=(v)>>32;(p)[5]=(v)>>40;(p)[6]=(v)>>48;(p)[7]=(v)>>56 (p)[4]=(v)>>32;(p)[5]=(v)>>40;(p)[6]=(v)>>48;(p)[7]=(v)>>56;}while(0)
#define BIT8SZ 1 #define BIT8SZ 1
#define BIT16SZ 2 #define BIT16SZ 2