ref: d2936d94c507b49826d5a94180df81da8a8ba07b
parent: 9aee1700a59d85b30fdde643af3efcafc3399c0e
author: Ori Bernstein <ori@eigenstate.org>
date: Mon May 6 13:26:38 EDT 2019
Sand edges down on GBIT64()/PBIT64() macros. Now, you can safely use them in unbraced if statements, and with char*s.
--- a/sys/include/fcall.h
+++ b/sys/include/fcall.h
@@ -61,17 +61,20 @@
} Fcall;
-#define GBIT8(p) ((p)[0])
-#define GBIT16(p) ((p)[0]|((p)[1]<<8))
-#define GBIT32(p) ((p)[0]|((p)[1]<<8)|((p)[2]<<16)|((p)[3]<<24))
-#define GBIT64(p) ((u32int)((p)[0]|((p)[1]<<8)|((p)[2]<<16)|((p)[3]<<24)) |\
- ((vlong)((p)[4]|((p)[5]<<8)|((p)[6]<<16)|((p)[7]<<24)) << 32))
+#define GBIT8(p) (((uchar*)(p))[0])
+#define GBIT16(p) (((uchar*)(p))[0]|(((uchar*)(p))[1]<<8))
+#define GBIT32(p) (((uchar*)(p))[0]|(((uchar*)(p))[1]<<8)|\
+ (((uchar*)(p))[2]<<16)|(((uchar*)(p))[3]<<24))
+#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 PBIT16(p,v) (p)[0]=(v);(p)[1]=(v)>>8
-#define PBIT32(p,v) (p)[0]=(v);(p)[1]=(v)>>8;(p)[2]=(v)>>16;(p)[3]=(v)>>24
-#define PBIT64(p,v) (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
+#define PBIT8(p,v) do{(p)[0]=(v);}while(0)+#define PBIT16(p,v) do{(p)[0]=(v);(p)[1]=(v)>>8;}while(0)+#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) 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;}while(0)
#define BIT8SZ 1
#define BIT16SZ 2
--
⑨