@@@ 64-bit kludging
[secnet] / u64.h
diff --git a/u64.h b/u64.h
index 0d35c55..25f4d0a 100644 (file)
--- a/u64.h
+++ b/u64.h
@@ -31,10 +31,13 @@ typedef uint64_t u64;
 # define u64hilo(hi, lo) ((u64) (((u64) (hi) << 32) + (lo)))
 # define u64init(hi, lo) u64hilo (hi, lo)
 # define u64lo(x) ((u64) (x))
+# define u64getlo(x) ((x)&0xffffffffu)
+# define u64gethi(x) (((u64) (x) >> 32) & 0xffffffffu)
 # define u64lt(x, y) ((x) < (y))
 # define u64and(x, y) ((x) & (y))
 # define u64or(x, y) ((x) | (y))
 # define u64xor(x, y) ((x) ^ (y))
+# define u64not(x) (~(x))
 # define u64plus(x, y) ((x) + (y))
 # define u64shl(x, n) ((x) << (n))
 # define u64shr(x, n) ((x) >> (n))
@@ -73,6 +76,10 @@ u64lo (uint32_t lo)
   return r;
 }
 
+/* Return the high and low halves of X. */
+# define u64getlo(x) ((x).lo)
+# define u64gethi(x) ((x).hi)
+
 /* Return X < Y.  */
 static inline int
 u64lt (u64 x, u64 y)
@@ -110,6 +117,16 @@ u64xor (u64 x, u64 y)
   return r;
 }
 
+/* Return ~X.  */
+static inline u64
+u64not (u64 x)
+{
+  u64 r;
+  r.hi = ~x.hi;
+  r.lo = ~x.lo;
+  return r;
+}
+
 /* Return X + Y.  */
 static inline u64
 u64plus (u64 x, u64 y)