summaryrefslogtreecommitdiff
path: root/byteorder.h
diff options
context:
space:
mode:
Diffstat (limited to 'byteorder.h')
-rw-r--r--byteorder.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/byteorder.h b/byteorder.h
index 831644fe..22e807ab 100644
--- a/byteorder.h
+++ b/byteorder.h
@@ -38,9 +38,11 @@
#define PVAL(buf,pos) (UVAL(buf,pos)|UVAL(buf,(pos)+1)<<8)
#define IVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+2)<<16)
+#define IVAL64(buf,pos) (IVAL(buf,pos)|(int64)IVAL(buf,(pos)+4)<<32)
#define SSVALX(buf,pos,val) (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8)
#define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))
-#define SIVAL(buf,pos,val) SIVALX((buf),(pos),((uint32)(val)))
+#define SIVAL(buf,pos,val) SIVALX(buf,pos,(uint32)(val))
+#define SIVAL64(buf,pos,val) (SIVAL(buf,pos,val),SIVAL(buf,(pos)+4,(val)>>32))
#define IVALu(buf,pos) IVAL(buf,pos)
#define SIVALu(buf,pos,val) SIVAL(buf,pos,val)
@@ -95,6 +97,28 @@ SIVAL(char *buf, int pos, uint32 val)
SIVALu((uchar*)buf, pos, val);
}
+static inline int64
+IVAL64(const char *buf, int pos)
+{
+ union {
+ const char *b;
+ const int64 *num;
+ } u;
+ u.b = buf + pos;
+ return *u.num;
+}
+
+static inline void
+SIVAL64(char *buf, int pos, int64 val)
+{
+ union {
+ char *b;
+ int64 *num;
+ } u;
+ u.b = buf + pos;
+ *u.num = val;
+}
+
# endif /* !AVOID_BYTEORDER_INLINE */
#endif /* !CAREFUL_ALIGNMENT */