summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2019-05-06 17:26:38 -0700
committerOri Bernstein <ori@eigenstate.org>2019-05-06 17:26:38 -0700
commitceed9b8853ab7b10e5a9e39704e712bfce53ce8a (patch)
treefd18c5d1160559ff746f6f1c9125bba7e244b166
parentc9086fb34858b7751c0a7b7407425596a41e0cfd (diff)
Sand edges down on GBIT64()/PBIT64() macros.
Now, you can safely use them in unbraced if statements, and with char*s.
-rw-r--r--sys/include/fcall.h23
1 files changed, 13 insertions, 10 deletions
diff --git a/sys/include/fcall.h b/sys/include/fcall.h
index 25a73636f..d68b405a0 100644
--- a/sys/include/fcall.h
+++ b/sys/include/fcall.h
@@ -61,17 +61,20 @@ struct Fcall
} 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