Annotate noexcept and constexpr with HEDLEY, and add interval containment, ChaCha, and the dyadic range tables.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Ryan Henry 2026-09-24 20:44:07 -06:00
parent 875f09fec1
commit 0d8a5a8131
97 changed files with 9212 additions and 1159 deletions

View file

@ -9,6 +9,8 @@
#ifndef LIBDPF_INCLUDE_GROTTO_HEXFLOAT_HPP__
#define LIBDPF_INCLUDE_GROTTO_HEXFLOAT_HPP__
#include "hedley/hedley.h"
#include <algorithm>
#include <cctype>
#include <cmath>
@ -109,6 +111,7 @@ constexpr bool is_hexfloat_fixedpoint = false;
template <unsigned FractionalBits, typename Integral>
constexpr bool is_hexfloat_fixedpoint<fixedpoint<FractionalBits, Integral>> = true;
HEDLEY_NO_THROW
constexpr void mask_low_bits(std::uint64_t * limbs, unsigned width) noexcept
{
if (width >= 256u)
@ -132,11 +135,13 @@ constexpr void mask_low_bits(std::uint64_t * limbs, unsigned width) noexcept
}
}
HEDLEY_NO_THROW
constexpr bool bit_is_set(const std::uint64_t * limbs, unsigned bit) noexcept
{
return ((limbs[bit / 64u] >> (bit % 64u)) & 1u) != 0u;
}
HEDLEY_NO_THROW
constexpr void negate_low_bits(std::uint64_t * limbs, unsigned width) noexcept
{
for (unsigned i = 0; i < 4u; ++i)
@ -154,6 +159,7 @@ constexpr void negate_low_bits(std::uint64_t * limbs, unsigned width) noexcept
}
template <typename T>
HEDLEY_NO_THROW
constexpr void store_integer_bits(const T & value, std::uint64_t out[4]) noexcept
{
out[0] = out[1] = out[2] = out[3] = 0;
@ -183,6 +189,7 @@ constexpr void store_integer_bits(const T & value, std::uint64_t out[4]) noexcep
}
template <typename T>
HEDLEY_NO_THROW
constexpr T load_integer_bits(const std::uint64_t * limbs) noexcept
{
if constexpr (std::is_same_v<T, uint256_t>)
@ -205,6 +212,7 @@ constexpr T load_integer_bits(const std::uint64_t * limbs) noexcept
}
}
HEDLEY_NO_THROW
inline int highest_bit(const std::uint64_t * limbs) noexcept
{
for (int i = 3; i >= 0; --i)
@ -268,6 +276,7 @@ std::string format_hexfloat(const T & value, int fractional_bits)
return std::string(negative ? "-" : "+") + "0x1." + fraction + "p" + expbuf;
}
HEDLEY_NO_THROW
inline int hex_value(char c) noexcept
{
if (c >= '0' && c <= '9') return c - '0';