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

@ -11,6 +11,7 @@
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <stdexcept>
#include "hedley/hedley.h"
#include "simde/simde/x86/avx2.h"
@ -49,11 +50,15 @@ HEDLEY_PRAGMA(GCC diagnostic ignored "-Wignored-attributes")
HEDLEY_PRAGMA(GCC diagnostic pop)
}
HEDLEY_NO_THROW
HEDLEY_ALWAYS_INLINE
static void eval(block_type seed, block_type * HEDLEY_RESTRICT output,
psnip_uint32_t count, psnip_uint32_t pos = 0) noexcept
psnip_uint32_t count, psnip_uint32_t pos = 0)
{
if (count > 1 &&
pos > static_cast<psnip_uint32_t>(~static_cast<psnip_uint32_t>(0)) - (count - 1u))
{
throw std::invalid_argument("prg lane index is out of range");
}
for (psnip_uint32_t i = 0; i < count; ++i)
{
output[i] = eval(seed, pos + i);
@ -62,6 +67,7 @@ HEDLEY_PRAGMA(GCC diagnostic pop)
HEDLEY_NO_THROW
HEDLEY_ALWAYS_INLINE
HEDLEY_NON_NULL(1, 2, 3)
static void eval01_x4(const block_type * HEDLEY_RESTRICT seeds,
block_type * HEDLEY_RESTRICT left,
block_type * HEDLEY_RESTRICT right) noexcept
@ -76,6 +82,7 @@ HEDLEY_PRAGMA(GCC diagnostic pop)
HEDLEY_NO_THROW
HEDLEY_ALWAYS_INLINE
HEDLEY_NON_NULL(1, 2)
static void eval_x4(const block_type * HEDLEY_RESTRICT seeds,
block_type * HEDLEY_RESTRICT output, psnip_uint32_t pos = 0) noexcept
{
@ -87,6 +94,7 @@ HEDLEY_PRAGMA(GCC diagnostic pop)
HEDLEY_NO_THROW
HEDLEY_ALWAYS_INLINE
HEDLEY_NON_NULL(1, 2)
static void eval_x8(const block_type * HEDLEY_RESTRICT seeds,
block_type * HEDLEY_RESTRICT output, psnip_uint32_t pos = 0) noexcept
{
@ -98,9 +106,11 @@ HEDLEY_PRAGMA(GCC diagnostic pop)
/// Raw-bit subtractive share of `T` for party `Party` (see `prg.hpp`).
template <typename T, std::size_t Party>
HEDLEY_NO_THROW
static auto expand(block_type seed, psnip_uint32_t pos = 0) noexcept;
private:
HEDLEY_NO_THROW
static lowmc::block to_block(block_type x) noexcept
{
std::uint64_t lane[2];
@ -114,6 +124,7 @@ HEDLEY_PRAGMA(GCC diagnostic pop)
return b;
}
HEDLEY_NO_THROW
static block_type from_block(const lowmc::block & b) noexcept
{
std::uint64_t lane[2] = {0, 0};
@ -127,6 +138,7 @@ HEDLEY_PRAGMA(GCC diagnostic pop)
return x;
}
HEDLEY_NO_THROW
static block_type permute(block_type x) noexcept
{
static lowmc::LowMC cipher;