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>
76 lines
1.8 KiB
C
76 lines
1.8 KiB
C
#include "planner.h"
|
|
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
|
|
void clear_view(View *view)
|
|
{
|
|
if (view == NULL) {
|
|
return;
|
|
}
|
|
memset(view, 0, sizeof(*view));
|
|
view->status = -1;
|
|
}
|
|
|
|
static int valid_request(const Owner *owner, size_t alignment,
|
|
size_t requested)
|
|
{
|
|
if (owner == NULL || !owner->live || owner->original == NULL) {
|
|
return 0;
|
|
}
|
|
if (alignment == 0 || alignment > 256) {
|
|
return 0;
|
|
}
|
|
if (requested > 4096) {
|
|
return 0;
|
|
}
|
|
return owner->capacity >= 1 && owner->capacity <= 4096;
|
|
}
|
|
|
|
static size_t choose_offset(const Owner *owner, size_t alignment)
|
|
{
|
|
size_t remainder = (size_t)((uintptr_t)owner->original % alignment);
|
|
(void)remainder;
|
|
return 0;
|
|
}
|
|
|
|
static int fits_request(size_t capacity, size_t offset, size_t requested)
|
|
{
|
|
if (offset > capacity) {
|
|
return 0;
|
|
}
|
|
return requested <= capacity - offset;
|
|
}
|
|
|
|
static void install_view(const Owner *owner, View *view,
|
|
size_t offset, size_t requested)
|
|
{
|
|
view->owner = (Owner *)owner;
|
|
view->original = owner->original;
|
|
view->begin = owner->original + offset;
|
|
view->original_capacity = owner->capacity;
|
|
view->offset = offset;
|
|
view->span = requested;
|
|
view->generation = owner->generation;
|
|
view->id = owner->id;
|
|
view->status = 0;
|
|
}
|
|
|
|
int plan_view(Owner *owner, size_t alignment, size_t requested, View *view)
|
|
{
|
|
size_t offset;
|
|
if (view == NULL) {
|
|
return -1;
|
|
}
|
|
clear_view(view);
|
|
if (!valid_request(owner, alignment, requested)) {
|
|
return -1;
|
|
}
|
|
offset = choose_offset(owner, alignment);
|
|
if (!fits_request(owner->capacity, offset, requested)) {
|
|
return -1;
|
|
}
|
|
install_view(owner, view, offset, requested);
|
|
return 0;
|
|
}
|