]> Zhao Yanbai Git Server - minix.git/commitdiff
neg64() makes a 64bit integer negative
authorTomas Hruby <tom@minix3.org>
Thu, 23 Sep 2010 14:42:26 +0000 (14:42 +0000)
committerTomas Hruby <tom@minix3.org>
Thu, 23 Sep 2010 14:42:26 +0000 (14:42 +0000)
- neg64(a) == -a

- although we only support 64 bit unsigned arithmetics sometimes it's good to
  have a 2-complement negative number

include/minix/u64.h

index 910d77c283d4c629f55d7619343159af2569e796..4eef3fec2a6a9c449227113229699529a3c548df 100644 (file)
@@ -43,4 +43,10 @@ u64_t not64(u64_t a);
 #define is_zero64(i)   ((i).lo == 0 && (i).hi == 0)
 #define make_zero64(i) do { (i).lo = (i).hi = 0; } while(0)
 
+#define neg64(i)       do {                            \
+                               (i).lo = ~(i).lo;       \
+                               (i).hi = ~(i).hi;       \
+                               (i) = add64u((i), 1);   \
+                       } while(0)
+
 #endif /* _MINIX__U64_H */