One user-space repair task per eligible HWE debug-diag / compile-deploy base ID: 320 admitted (C 218, C++ 97, build scripts 5), 1 skipped by the content filter. Each ships a public spec with a check-to-basis table, at least two defects with single-fix fixtures, a symptom-masking fixture and an alternative correct implementation. Claude re-checked all 320: structure, the HWE quality items and trace6 Docker calibration receipts against current digests (320/320 USABLE). Difficulty is unmeasured. Known follow-up: 212 tasks use 120 ad-hoc family names; the next batch maps them to the canonical list. The batch's 1,256-line progress log stays in its factory report and the 36-local branch batch15-hwe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
73 lines
2.4 KiB
C
73 lines
2.4 KiB
C
#include "descriptor.h"
|
|
#include <string.h>
|
|
uintptr_t table_base(const struct descriptor_table *table) {
|
|
if (table == NULL) {
|
|
return 0;
|
|
}
|
|
return (uintptr_t)table->data;
|
|
}
|
|
int table_create(struct descriptor_table *table, unsigned capacity, unsigned alignment) {
|
|
struct descriptor_table next;
|
|
if (table == NULL || capacity == 0 || capacity > MAX_ENTRIES) {
|
|
return RESULT_INPUT;
|
|
}
|
|
if (alignment != 32 && alignment != 64 && alignment != 128) {
|
|
return RESULT_INPUT;
|
|
}
|
|
memset(&next, 0, sizeof(next));
|
|
next.capacity = capacity;
|
|
next.alignment = alignment;
|
|
next.stride = alignment;
|
|
next.allocation_bytes = (size_t)capacity * alignment;
|
|
next.data = arena_allocate(alignment, next.allocation_bytes);
|
|
if (next.data == NULL) {
|
|
return RESULT_MEMORY;
|
|
}
|
|
*table = next;
|
|
return RESULT_OK;
|
|
}
|
|
void table_destroy(struct descriptor_table *table) {
|
|
if (table == NULL) {
|
|
return;
|
|
}
|
|
arena_release(table->data);
|
|
memset(table, 0, sizeof(*table));
|
|
}
|
|
static void encode(unsigned char *bytes, unsigned index,
|
|
struct transfer transfer, uint64_t cookie) {
|
|
wire_put64(bytes, UINT64_C(4096));
|
|
wire_put32(bytes + 8, 64);
|
|
wire_put32(bytes + 12, transfer.control);
|
|
wire_put64(bytes + 16, cookie);
|
|
wire_put32(bytes + 24, index);
|
|
wire_put32(bytes + 28, descriptor_checksum(bytes, 28));
|
|
}
|
|
int table_store(struct descriptor_table *table, unsigned index,
|
|
struct transfer transfer, uint64_t cookie) {
|
|
size_t offset;
|
|
if (table == NULL || table->data == NULL || index >= table->capacity) {
|
|
return RESULT_INPUT;
|
|
}
|
|
offset = (size_t)index * table->stride;
|
|
if (offset > table->allocation_bytes ||
|
|
table->allocation_bytes - offset < WIRE_BYTES) {
|
|
return RESULT_INPUT;
|
|
}
|
|
table->staged[index] = transfer;
|
|
encode(table->data + offset, index, transfer, cookie);
|
|
return RESULT_OK;
|
|
}
|
|
int table_publish(struct descriptor_table *table, unsigned count, uint64_t cookie) {
|
|
unsigned index;
|
|
if (table == NULL || count > table->capacity) {
|
|
return RESULT_INPUT;
|
|
}
|
|
for (index = 0; index < count; ++index) {
|
|
size_t offset = (size_t)index * table->stride;
|
|
unsigned char *bytes = table->data + offset;
|
|
wire_put64(bytes + 16, cookie);
|
|
wire_put32(bytes + 28, descriptor_checksum(bytes, 28));
|
|
}
|
|
return RESULT_OK;
|
|
}
|