1#![deny(rustdoc::broken_intra_doc_links)]
5#![allow(unused_imports)]
6
7pub use ff_uint_derive::*;
8
9#[cfg(feature = "rand_support")]
10use rand_core::RngCore;
11
12pub mod traits;
13
14pub use self::arith_impl::*;
15
16mod arith_impl {
17 #[inline(always)]
20 pub fn sbb(a: u64, b: u64, borrow: &mut u64) -> u64 {
21 let tmp = (1u128 << 64) + u128::from(a) - u128::from(b) - u128::from(*borrow);
22
23 *borrow = if tmp >> 64 == 0 { 1 } else { 0 };
24
25 tmp as u64
26 }
27
28 #[inline(always)]
31 pub fn adc(a: u64, b: u64, carry: &mut u64) -> u64 {
32 let tmp = u128::from(a) + u128::from(b) + u128::from(*carry);
33
34 *carry = (tmp >> 64) as u64;
35
36 tmp as u64
37 }
38
39 #[inline(always)]
42 pub fn mac_with_carry(a: u64, b: u64, c: u64, carry: &mut u64) -> u64 {
43 let tmp = (u128::from(a)) + u128::from(b) * u128::from(c) + u128::from(*carry);
44
45 *carry = (tmp >> 64) as u64;
46
47 tmp as u64
48 }
49}