lib:util: Use (PULL|PUSH)_BE_(U16|U32|U64) for R*VAL*
authorAndreas Schneider <asn@samba.org>
Thu, 20 Dec 2018 10:24:29 +0000 (11:24 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 21 Feb 2020 02:09:33 +0000 (02:09 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/util/byteorder.h

index 6defa585b1387bb470dc96f9c884359ce7427b56..1330e82f5c8d9adc7d7f06a379f43ea7a5279cec 100644 (file)
@@ -107,9 +107,9 @@ it also defines lots of intermediate macros, just ignore those :-)
 #define SIVALS(buf,pos,val) PUSH_LE_U32(buf, pos, val)
 
 /* 64 bit macros */
-#define BVAL(p, ofs) (IVAL(p,ofs) | (((uint64_t)IVAL(p,(ofs)+4)) << 32))
+#define BVAL(p, ofs) PULL_LE_U64(p, ofs)
 #define BVALS(p, ofs) ((int64_t)BVAL(p,ofs))
-#define SBVAL(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,((uint64_t)(v))>>32))
+#define SBVAL(p, ofs, v) PUSH_LE_U64(p, ofs, v)
 #define SBVALS(p, ofs, v) (SBVAL(p,ofs,(uint64_t)v))
 
 /* now the reverse routines - these are used in nmb packets (mostly) */
@@ -117,17 +117,17 @@ it also defines lots of intermediate macros, just ignore those :-)
 #define IREV(x) ((SREV(x)<<16) | (SREV((x)>>16)))
 #define BREV(x) ((IREV((uint64_t)x)<<32) | (IREV(((uint64_t)x)>>32)))
 
-#define RSVAL(buf,pos) SREV(SVAL(buf,pos))
-#define RSVALS(buf,pos) SREV(SVALS(buf,pos))
-#define RIVAL(buf,pos) IREV(IVAL(buf,pos))
-#define RIVALS(buf,pos) IREV(IVALS(buf,pos))
-#define RBVAL(buf,pos) BREV(BVAL(buf,pos))
-#define RBVALS(buf,pos) BREV(BVALS(buf,pos))
-#define RSSVAL(buf,pos,val) SSVAL(buf,pos,SREV(val))
-#define RSSVALS(buf,pos,val) SSVALS(buf,pos,SREV(val))
-#define RSIVAL(buf,pos,val) SIVAL(buf,pos,IREV(val))
-#define RSIVALS(buf,pos,val) SIVALS(buf,pos,IREV(val))
-#define RSBVAL(buf,pos,val) SBVAL(buf,pos,BREV(val))
-#define RSBVALS(buf,pos,val) SBVALS(buf,pos,BREV(val))
+#define RSVAL(buf,pos) (uint32_t)PULL_BE_U16(buf, pos)
+#define RSVALS(buf,pos) PULL_BE_U16(buf, pos)
+#define RIVAL(buf,pos) PULL_BE_U32(buf, pos)
+#define RIVALS(buf,pos) PULL_BE_U32(buf, pos)
+#define RBVAL(buf,pos) PULL_BE_U64(buf, pos)
+#define RBVALS(buf,pos) PULL_BE_U64(buf, pos)
+#define RSSVAL(buf,pos,val) PUSH_BE_U16(buf, pos, val)
+#define RSSVALS(buf,pos,val) PUSH_BE_U16(buf, pos, val)
+#define RSIVAL(buf,pos,val) PUSH_BE_U32(buf, pos, val)
+#define RSIVALS(buf,pos,val) PUSH_BE_U32(buf, pos, val)
+#define RSBVAL(buf,pos,val) PUSH_BE_U64(buf, pos, val)
+#define RSBVALS(buf,pos,val) PUSH_BE_U64(buf, pos, val)
 
 #endif /* _BYTEORDER_H */