Changeset View
Changeset View
Standalone View
Standalone View
src/secp256k1/src/int128_struct_impl.h
| Show First 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | static SECP256K1_INLINE void secp256k1_i128_from_i64(secp256k1_int128 *r, int64_t a) { | ||||
| r->hi = (uint64_t)(a >> 63); | r->hi = (uint64_t)(a >> 63); | ||||
| r->lo = (uint64_t)a; | r->lo = (uint64_t)a; | ||||
| } | } | ||||
| static SECP256K1_INLINE int secp256k1_i128_eq_var(const secp256k1_int128 *a, const secp256k1_int128 *b) { | static SECP256K1_INLINE int secp256k1_i128_eq_var(const secp256k1_int128 *a, const secp256k1_int128 *b) { | ||||
| return a->hi == b->hi && a->lo == b->lo; | return a->hi == b->hi && a->lo == b->lo; | ||||
| } | } | ||||
| static SECP256K1_INLINE int secp256k1_i128_check_pow2(const secp256k1_int128 *r, unsigned int n) { | static SECP256K1_INLINE int secp256k1_i128_check_pow2(const secp256k1_int128 *r, unsigned int n, int sign) { | ||||
| VERIFY_CHECK(n < 127); | VERIFY_CHECK(n < 127); | ||||
| return n >= 64 ? r->hi == (uint64_t)1 << (n - 64) && r->lo == 0 | VERIFY_CHECK(sign == 1 || sign == -1); | ||||
| : r->hi == 0 && r->lo == (uint64_t)1 << n; | return n >= 64 ? r->hi == (uint64_t)sign << (n - 64) && r->lo == 0 | ||||
| : r->hi == (uint64_t)((sign - 1) >> 1) && r->lo == (uint64_t)sign << n; | |||||
| } | } | ||||
| #endif | #endif | ||||