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

75 lines
2.3 KiB
C++

#ifndef OWNER_FRAMES_HPP
#define OWNER_FRAMES_HPP
#include <cstddef>
#include <cstdint>
#include <string>
#include <vector>
namespace frames {
constexpr int OK=0, QUEUED=1, ARG=-1, ABSENT=-2, BUSY=-3, LIMIT=-4, OWNER=-5, DUPLICATE=-6, MISSING=-7, SPACE=-8, RANGE=-9;
constexpr int NORMAL=0, RECURSIVE=1;
constexpr unsigned MAX_DEPTH=8, MAX_HANDLES=8, MAX_OBJECTS=4, MAX_WAITERS=4;
struct Attr { int mode=NORMAL; unsigned limit=1; };
struct AttrView { int mode; unsigned limit; };
struct WaitView { int actor; std::uint32_t note; };
struct View {
int mode;
unsigned limit;
unsigned aliases;
int owner;
unsigned depth;
unsigned waiting;
std::uint32_t top;
std::uint64_t entered;
std::uint64_t exited;
std::uint64_t handoffs;
};
struct Stats {
unsigned handles;
unsigned objects;
unsigned frames;
unsigned waiters;
std::uint64_t creates;
std::uint64_t duplicates;
std::uint64_t closes;
std::uint64_t revision;
};
struct Frame { int actor; std::uint32_t note; };
struct Lock {
bool used=false;
Attr attr;
std::vector<Frame> held;
std::vector<Frame> pending;
std::uint64_t entered=0, exited=0, handoffs=0;
};
struct Bank {
std::vector<Lock> locks=std::vector<Lock>(MAX_OBJECTS);
std::vector<int> handles=std::vector<int>(MAX_HANDLES,-1);
std::uint64_t creates=0, duplicates=0, closes=0, revision=0;
};
int attr_init(Attr*);
int attr_mode(Attr*,int);
int attr_limit(Attr*,unsigned);
int attr_read(const Attr*,AttrView*);
int reset(Bank*);
int create(Bank*,const Attr*,int*);
int duplicate(Bank*,int,int*);
int close(Bank*,int);
int enter(Bank*,int,int,std::uint32_t);
int request(Bank*,int,int,std::uint32_t);
int leave(Bank*,int,int);
int cancel(Bank*,int,int);
int view(const Bank*,int,View*);
int queued(const Bank*,int,unsigned,WaitView*);
int stats(const Bank*,Stats*);
struct ActorView { unsigned held_objects; unsigned held_frames; unsigned pending_objects; };
int actor_view(const Bank*,int,ActorView*);
struct Row { int handle; View value; };
int export_rows(const Bank*,std::vector<Row>*);
int owned(const Bank*,int,std::vector<int>*);
const char* result_name(int);
int parse_u32(const char*,std::size_t,std::uint32_t*);
int tokenize(const char*,std::size_t,std::vector<std::string>*);
std::string execute(Bank*,const char*,std::size_t);
}
#endif