From: Mark Wooding Date: Thu, 26 Sep 2019 03:45:18 +0000 (+0100) Subject: u64.h: Provide u64get{lo,hi} and u64not X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=a0233934facf7f10036f92840de1891e11122627;p=secnet.git u64.h: Provide u64get{lo,hi} and u64not These are for the benefit of fake-mLib-bits.h. Signed-off-by: Ian Jackson --- diff --git a/u64.h b/u64.h index 0d35c55..25f4d0a 100644 --- 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)