/* * A simple container for two 64-bit numbers */ #ifndef BLK128_H #define BLK128_H 1 #include BEGIN_C_DECLS #define blk128_set(x, h, l) \ do { \ uint64_t thi = (h); \ uint64_t tlo = (l); \ (x)->hi = thi; \ (x)->lo = tlo; \ } while(0) #define blk128_zero(x) blk128_set(x, 0, 0) #define blk128_cp(x, y) blk128_set(x, (y)->hi, (y)->lo) #define blk128_is_zero(x) (!((x)->hi || (x)->lo)) /** * Compare two 128-bit numbers */ int blk128_cmp(blk128_t *x, blk128_t *y); /* * Add two 128-bit blocks together, placing the result in rop. * * It is assumed that op1 >= op2 */ void blk128_add(blk128_t *rop, blk128_t *op1, blk128_t *op2); /** * Add 3 to x */ void blk128_inc3(blk128_t *x); /* * Subtract two 128-bit blocks, placing the result in rop. It is assumed op1 <= * op2. */ void blk128_sub(blk128_t *rop, blk128_t *op1, blk128_t *op2); /** * Sub 3 from x */ void blk128_dec3(blk128_t *x); /* * Increment a 128-bit block */ void blk128_inc(blk128_t *x); /** * Multiply two 128-bit numbers, storing the result in a 256-bit block. */ void blk128_mul(blk256_t *rop, blk128_t *x, blk128_t *y); /** * Convert 128-bit number to double */ double blk128_as_double(blk128_t *op); END_C_DECLS #endif /* BLK128_H */