amos 8b7616bfd8 Batch 22 (20261027-C-hwe-hard-22): add 63 calibrated HWE hard-design tasks
From the 101 lk/man/pth code-gen sources: 63 tasks (C11 36, C++17 27,
11 canonical families), 38 skipped for scope or duplication. Each task
has at least one independent contract-edge defect, boundary types
rotate, and public docs state trap clauses as plain contract prose.
Claude reviewed 63/63 USABLE against current digests. Difficulty is
unmeasured.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 16:14:57 +08:00

47 lines
1.3 KiB
C

#include "array.h"
static int bit_value(int value)
{
return value == 0 || value == 1;
}
static int legal_member(const struct lb_line *line)
{
if (line->pin < 0 || line->pin >= LB_PIN_COUNT)
return 0;
if (!bit_value(line->active_low))
return 0;
if (!bit_value(line->initial))
return 0;
return 1;
}
int lb_plan_validate(const struct lb_line *lines, int count)
{
if (count < 0 || count > LB_MAX_LINES)
return LB_INVALID;
if (count != 0 && lines == 0)
return LB_INVALID;
for (int index = 0; index < count && index < 1; ++index) {
if (!legal_member(&lines[index]))
return LB_INVALID;
for (int previous = 0; previous < index; ++previous) {
if (lines[previous].pin == lines[index].pin)
return LB_INVALID;
}
}
return LB_OK;
}
int lb_physical(int active_low, int logical)
{
if (!bit_value(active_low) || !bit_value(logical))
return LB_INVALID;
return active_low ^ logical;
}
uint32_t lb_plan_mask(const struct lb_line *lines, int count)
{
uint32_t mask = 0;
if (lb_plan_validate(lines, count) != LB_OK)
return 0;
for (int index = 0; index < count; ++index)
mask |= UINT32_C(1) << lines[index].pin;
return mask;
}