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>
110 lines
3.0 KiB
C
110 lines
3.0 KiB
C
#include "descriptor.h"
|
|
#include <string.h>
|
|
void batch_initialize(struct batch *batch) {
|
|
if (batch != NULL) {
|
|
memset(batch, 0, sizeof(*batch));
|
|
}
|
|
}
|
|
uint64_t batch_cookie(const struct batch *batch) {
|
|
if (batch == NULL) {
|
|
return 0;
|
|
}
|
|
return ((uint64_t)batch->epoch << 32) | batch->count;
|
|
}
|
|
int batch_begin(struct batch *batch, uint64_t capacity, uint64_t alignment) {
|
|
struct descriptor_table next;
|
|
int result;
|
|
if (batch == NULL || capacity == 0 || capacity > MAX_ENTRIES) {
|
|
return RESULT_INPUT;
|
|
}
|
|
if (alignment != 32 && alignment != 64 && alignment != 128) {
|
|
return RESULT_INPUT;
|
|
}
|
|
if (batch->phase == PHASE_BUILDING || batch->phase == PHASE_SUBMITTED) {
|
|
return RESULT_STATE;
|
|
}
|
|
if (batch->epoch == UINT32_MAX) {
|
|
return RESULT_STATE;
|
|
}
|
|
memset(&next, 0, sizeof(next));
|
|
result = table_create(&next, (unsigned)capacity, (unsigned)alignment);
|
|
if (result != RESULT_OK) {
|
|
return result;
|
|
}
|
|
table_destroy(&batch->table);
|
|
batch->table = next;
|
|
batch->count = 0;
|
|
batch->epoch += 1;
|
|
batch->phase = PHASE_BUILDING;
|
|
return RESULT_OK;
|
|
}
|
|
int batch_append(struct batch *batch, uint64_t address, uint64_t length, uint64_t control) {
|
|
struct transfer transfer;
|
|
int result;
|
|
if (batch == NULL) {
|
|
return RESULT_INPUT;
|
|
}
|
|
if (batch->phase != PHASE_BUILDING) {
|
|
return RESULT_STATE;
|
|
}
|
|
if (length == 0 || length > MAX_TRANSFER || control > 3 ||
|
|
address > UINT64_MAX - length) {
|
|
return RESULT_INPUT;
|
|
}
|
|
if (batch->count == batch->table.capacity) {
|
|
return RESULT_FULL;
|
|
}
|
|
transfer.address = address;
|
|
transfer.length = (uint32_t)length;
|
|
transfer.control = (uint32_t)control;
|
|
result = table_store(&batch->table, batch->count, transfer, batch_cookie(batch));
|
|
if (result != RESULT_OK) {
|
|
return result;
|
|
}
|
|
batch->count += 1;
|
|
return RESULT_OK;
|
|
}
|
|
int batch_submit(struct batch *batch) {
|
|
int result;
|
|
if (batch == NULL) {
|
|
return RESULT_INPUT;
|
|
}
|
|
if (batch->phase != PHASE_BUILDING || batch->count == 0) {
|
|
return RESULT_STATE;
|
|
}
|
|
result = table_publish(&batch->table, batch->count, batch_cookie(batch));
|
|
if (result != RESULT_OK) {
|
|
return result;
|
|
}
|
|
batch->phase = PHASE_BUILDING;
|
|
return RESULT_OK;
|
|
}
|
|
int batch_complete(struct batch *batch, uint64_t cookie) {
|
|
if (batch == NULL) {
|
|
return RESULT_INPUT;
|
|
}
|
|
if (batch->phase != PHASE_SUBMITTED) {
|
|
return RESULT_STATE;
|
|
}
|
|
if (cookie != batch_cookie(batch)) {
|
|
return RESULT_STALE;
|
|
}
|
|
batch->phase = PHASE_COMPLETE;
|
|
return RESULT_OK;
|
|
}
|
|
int batch_cancel(struct batch *batch) {
|
|
if (batch == NULL) {
|
|
return RESULT_INPUT;
|
|
}
|
|
table_destroy(&batch->table);
|
|
batch->count = 0;
|
|
batch->phase = PHASE_IDLE;
|
|
return RESULT_OK;
|
|
}
|
|
void batch_destroy(struct batch *batch) {
|
|
if (batch != NULL) {
|
|
table_destroy(&batch->table);
|
|
batch_initialize(batch);
|
|
}
|
|
}
|