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>
98 lines
2.8 KiB
C++
98 lines
2.8 KiB
C++
#include "internal.hpp"
|
|
namespace inline_record { namespace detail {
|
|
Record::Record(std::uint32_t token, std::uint16_t tag, std::size_t n)
|
|
: wire_(16 + 4 * n, 0)
|
|
{
|
|
wire_[0] = 82;
|
|
wire_[1] = 69;
|
|
wire_[2] = 67;
|
|
wire_[3] = 49;
|
|
write32(4, token);
|
|
wire_[8] = static_cast<std::uint8_t>(tag % 256);
|
|
wire_[9] = static_cast<std::uint8_t>(tag / 256);
|
|
wire_[10] = static_cast<std::uint8_t>(n);
|
|
wire_[11] = 0;
|
|
}
|
|
std::uint32_t Record::read32(std::size_t offset) const
|
|
{
|
|
std::uint32_t result = 0;
|
|
std::uint32_t factor = 1;
|
|
for (std::size_t lane = 0; lane < 4; ++lane) {
|
|
result += static_cast<std::uint32_t>(wire_[offset + lane]) * factor;
|
|
if (lane != 3) {
|
|
factor *= 256;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
void Record::write32(std::size_t offset, std::uint32_t value)
|
|
{
|
|
for (std::size_t lane = 0; lane < 4; ++lane) {
|
|
wire_[offset + lane] = static_cast<std::uint8_t>(value % 256);
|
|
value /= 256;
|
|
}
|
|
}
|
|
std::uint32_t Record::token() const
|
|
{
|
|
return read32(4);
|
|
}
|
|
std::uint16_t Record::tag() const
|
|
{
|
|
return static_cast<std::uint16_t>(wire_[8] + 256u * wire_[9]);
|
|
}
|
|
std::size_t Record::count() const
|
|
{
|
|
return static_cast<std::size_t>(wire_[10]) + 256u * wire_[11];
|
|
}
|
|
std::size_t Record::size() const
|
|
{
|
|
return wire_.size();
|
|
}
|
|
std::uint32_t Record::checksum() const
|
|
{
|
|
return read32(12);
|
|
}
|
|
std::int32_t Record::get(std::size_t index) const
|
|
{
|
|
const std::uint32_t raw = read32(16 + 4 * index);
|
|
const std::int64_t decoded = raw <= 2147483647u ?
|
|
static_cast<std::int64_t>(raw) : static_cast<std::int64_t>(raw) - 4294967296LL;
|
|
return static_cast<std::int32_t>(decoded);
|
|
}
|
|
std::uint8_t Record::byte(std::size_t offset) const
|
|
{
|
|
return wire_[offset];
|
|
}
|
|
void Record::refresh_checksum()
|
|
{
|
|
std::uint32_t sum = 0;
|
|
for (std::size_t position = 16; position < wire_.size(); position += 4) {
|
|
sum += read32(position);
|
|
}
|
|
write32(12, sum);
|
|
}
|
|
void Record::set(std::size_t index, std::int32_t value)
|
|
{
|
|
write32(16 + 4 * index, static_cast<std::uint32_t>(value));
|
|
}
|
|
void Record::fill(std::size_t start, std::size_t count, std::int32_t value)
|
|
{
|
|
for (std::size_t remaining = count; remaining != 0; --remaining) {
|
|
set(start + remaining - 1, value);
|
|
}
|
|
refresh_checksum();
|
|
}
|
|
void Record::copy_from(const Record& source, std::size_t from,
|
|
std::size_t to, std::size_t count)
|
|
{
|
|
const std::size_t first = 16 + 4 * from;
|
|
const std::size_t last = first + 4 * count;
|
|
const std::vector<std::uint8_t> slice(source.wire_.begin() + first,
|
|
source.wire_.begin() + last);
|
|
for (std::size_t index = 0; index < slice.size(); ++index) {
|
|
wire_[16 + 4 * to + index] = slice[index];
|
|
}
|
|
refresh_checksum();
|
|
}
|
|
}}
|