100 tasks from the HWE arm-linux code-gen pool (outside the lk/man/pth range given to batch 22), each with at least one independent contract-edge defect and plain public docs. Claude reviewed 100/100 USABLE against current digests; no ID or source overlap with main or batch 22. Difficulty is unmeasured. progress.md records the wrap-up: all Codex sessions and Qwen schedulers stopped for the user's rollout, Qwen results so far (57 HARD of 373), and what is left on each batch branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
99 lines
2.8 KiB
C++
99 lines
2.8 KiB
C++
#include "internal.hpp"
|
|
#include <array>
|
|
namespace inline_record { namespace detail {
|
|
namespace {
|
|
std::uint8_t part32(std::uint32_t number, std::size_t position)
|
|
{
|
|
const std::size_t shift = position * 8;
|
|
const std::uint32_t shifted = number >> shift;
|
|
return static_cast<std::uint8_t>(shifted & 255u);
|
|
}
|
|
std::uint8_t part16(std::uint16_t number, std::size_t position)
|
|
{
|
|
const std::size_t shift = position * 8;
|
|
const std::uint32_t shifted = static_cast<std::uint32_t>(number) >> shift;
|
|
return static_cast<std::uint8_t>(shifted & 255u);
|
|
}
|
|
}
|
|
Record::Record(std::uint32_t token, std::uint16_t tag, std::size_t n)
|
|
: token_(token), tag_(tag), items_(n, 0), checksum_(0)
|
|
{
|
|
}
|
|
std::uint32_t Record::token() const
|
|
{
|
|
return token_;
|
|
}
|
|
std::uint16_t Record::tag() const
|
|
{
|
|
return tag_;
|
|
}
|
|
std::size_t Record::count() const
|
|
{
|
|
return items_.size();
|
|
}
|
|
std::size_t Record::size() const
|
|
{
|
|
return 16 + items_.size() * 4;
|
|
}
|
|
std::uint32_t Record::checksum() const
|
|
{
|
|
return checksum_;
|
|
}
|
|
std::int32_t Record::get(std::size_t index) const
|
|
{
|
|
return items_[index];
|
|
}
|
|
void Record::set(std::size_t index, std::int32_t value)
|
|
{
|
|
const std::uint32_t previous = static_cast<std::uint32_t>(items_[index]);
|
|
const std::uint32_t replacement = static_cast<std::uint32_t>(value);
|
|
checksum_ -= previous;
|
|
checksum_ += replacement;
|
|
items_[index] = value;
|
|
}
|
|
std::uint8_t Record::byte(std::size_t offset) const
|
|
{
|
|
static const std::array<std::uint8_t, 4> magic = {{82, 69, 67, 49}};
|
|
if (offset < 4) {
|
|
return magic[offset];
|
|
}
|
|
if (offset < 8) {
|
|
return part32(token_, offset - 4);
|
|
}
|
|
if (offset < 10) {
|
|
return part16(tag_, offset - 8);
|
|
}
|
|
if (offset < 12) {
|
|
const std::uint16_t length = static_cast<std::uint16_t>(items_.size());
|
|
return part16(length, offset - 10);
|
|
}
|
|
if (offset < 16) {
|
|
return part32(checksum_, offset - 12);
|
|
}
|
|
const std::size_t relative = offset - 16;
|
|
const std::size_t index = relative / 4;
|
|
const std::size_t lane = relative % 4;
|
|
const std::uint32_t value = static_cast<std::uint32_t>(items_[index]);
|
|
return part32(value, lane);
|
|
}
|
|
void Record::fill(std::size_t start, std::size_t count, std::int32_t value)
|
|
{
|
|
const std::size_t stop = start + count;
|
|
for (std::size_t index = start; index < stop; ++index) {
|
|
set(index, value);
|
|
}
|
|
}
|
|
void Record::copy_from(const Record& source, std::size_t from,
|
|
std::size_t to, std::size_t count)
|
|
{
|
|
std::vector<std::int32_t> saved;
|
|
saved.reserve(count);
|
|
for (std::size_t index = 0; index < count; ++index) {
|
|
saved.push_back(source.get(from + index));
|
|
}
|
|
for (std::size_t index = 0; index < saved.size(); ++index) {
|
|
set(to + index, saved[index]);
|
|
}
|
|
}
|
|
}}
|