5#ifndef BITCOIN_CRYPTO_COMMON_H
6#define BITCOIN_CRYPTO_COMMON_H
8#if defined(HAVE_CONFIG_H)
9#include <config/bitcoin-config.h>
19 memcpy((
char *)&x, ptr, 2);
25 memcpy((
char *)&x, ptr, 4);
31 memcpy((
char *)&x, ptr, 8);
37 memcpy(ptr, (
char *)&v, 2);
42 memcpy(ptr, (
char *)&v, 4);
47 memcpy(ptr, (
char *)&v, 8);
52 memcpy((
char *)&x, ptr, 2);
58 memcpy((
char *)&x, ptr, 4);
64 memcpy((
char *)&x, ptr, 8);
70 memcpy(ptr, (
char *)&v, 4);
75 memcpy(ptr, (
char *)&v, 8);
83#if HAVE_DECL___BUILTIN_CLZL
84 if (
sizeof(
unsigned long) >=
sizeof(
uint64_t)) {
88#if HAVE_DECL___BUILTIN_CLZLL
89 if (
sizeof(
unsigned long long) >=
sizeof(
uint64_t)) {
static void WriteLE16(uint8_t *ptr, uint16_t x)
static void WriteLE32(uint8_t *ptr, uint32_t x)
static void WriteBE64(uint8_t *ptr, uint64_t x)
static void WriteBE32(uint8_t *ptr, uint32_t x)
static uint64_t ReadLE64(const uint8_t *ptr)
static uint16_t ReadBE16(const uint8_t *ptr)
static uint32_t ReadBE32(const uint8_t *ptr)
static uint16_t ReadLE16(const uint8_t *ptr)
static uint64_t ReadBE64(const uint8_t *ptr)
static uint64_t CountBits(uint64_t x)
Return the smallest number n such that (x >> n) == 0 (or 64 if the highest bit in x is set.
static uint32_t ReadLE32(const uint8_t *ptr)
static void WriteLE64(uint8_t *ptr, uint64_t x)
uint16_t be16toh(uint16_t big_endian_16bits)
uint32_t le32toh(uint32_t little_endian_32bits)
uint32_t htobe32(uint32_t host_32bits)
uint16_t le16toh(uint16_t little_endian_16bits)
uint64_t htobe64(uint64_t host_64bits)
uint64_t be64toh(uint64_t big_endian_64bits)
uint32_t be32toh(uint32_t big_endian_32bits)
uint64_t htole64(uint64_t host_64bits)
uint32_t htole32(uint32_t host_32bits)
uint16_t htole16(uint16_t host_16bits)
uint64_t le64toh(uint64_t little_endian_64bits)
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...