Bitcoin Core 28.99.0
P2P Digital Currency
Classes | Functions
int_utils.h File Reference
#include <stdint.h>
#include <stdlib.h>
#include <limits>
#include <algorithm>
#include <type_traits>
Include dependency graph for int_utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  BitWriter
 
class  BitReader
 
class  BitsInt< I, BITS >
 
struct  LFSR< F, MOD >
 Class which implements a stateless LFSR for generic moduli. More...
 
struct  GFMulHelper< I, N, L, F, 0 >
 
struct  GFMulHelper< I, N, L, F, K >
 Helper class for carryless multiplications. More...
 

Functions

template<int bits>
static constexpr uint64_t Rot (uint64_t x)
 
static void SipHashRound (uint64_t &v0, uint64_t &v1, uint64_t &v2, uint64_t &v3)
 
uint64_t SipHash (uint64_t k0, uint64_t k1, uint64_t data)
 
template<int BITS, typename I >
constexpr I Mask ()
 Return a value of type I with its bits lowest bits set (bits must be > 0). More...
 
template<typename I >
static int CountBits (I val, int max)
 Compute the smallest power of two that is larger than val. More...
 
template<typename I , int N, typename L , typename F >
constexpr I GFMul (const I &a, const I &b)
 Compute the carry-less multiplication of a and b, with N bits, using L as LFSR type. More...
 
template<typename I , typename F , int BITS, uint32_t MOD>
InvExtGCD (I x)
 Compute the inverse of x using an extgcd algorithm. More...
 
template<typename I , typename F , int BITS, I(*)(I, I) MUL, I(*)(I) SQR, I(*)(I) SQR2, I(*)(I) SQR4, I(*)(I) SQR8, I(*)(I) SQR16>
InvLadder (I x1)
 Compute the inverse of x1 using an exponentiation ladder. More...
 

Function Documentation

◆ CountBits()

template<typename I >
static int CountBits ( val,
int  max 
)
inlinestatic

Compute the smallest power of two that is larger than val.

Definition at line 146 of file int_utils.h.

◆ GFMul()

template<typename I , int N, typename L , typename F >
constexpr I GFMul ( const I &  a,
const I &  b 
)
inlineconstexpr

Compute the carry-less multiplication of a and b, with N bits, using L as LFSR type.

Definition at line 250 of file int_utils.h.

Here is the call graph for this function:

◆ InvExtGCD()

template<typename I , typename F , int BITS, uint32_t MOD>
I InvExtGCD ( x)
inline

Compute the inverse of x using an extgcd algorithm.

Definition at line 254 of file int_utils.h.

◆ InvLadder()

template<typename I , typename F , int BITS, I(*)(I, I) MUL, I(*)(I) SQR, I(*)(I) SQR2, I(*)(I) SQR4, I(*)(I) SQR8, I(*)(I) SQR16>
I InvLadder ( x1)
inline

Compute the inverse of x1 using an exponentiation ladder.

The MUL argument is a multiplication function, SQR is a squaring function, and the SQRi arguments compute x**(2**i).

Definition at line 280 of file int_utils.h.

◆ Mask()

template<int BITS, typename I >
constexpr I Mask ( )
inlineconstexpr

Return a value of type I with its bits lowest bits set (bits must be > 0).

Definition at line 142 of file int_utils.h.

◆ Rot()

template<int bits>
static constexpr uint64_t Rot ( uint64_t  x)
inlinestaticconstexpr

Definition at line 24 of file int_utils.h.

◆ SipHash()

uint64_t SipHash ( uint64_t  k0,
uint64_t  k1,
uint64_t  data 
)
inline

Definition at line 35 of file int_utils.h.

Here is the call graph for this function:

◆ SipHashRound()

static void SipHashRound ( uint64_t &  v0,
uint64_t &  v1,
uint64_t &  v2,
uint64_t &  v3 
)
inlinestatic

Definition at line 26 of file int_utils.h.

Here is the caller graph for this function: