Make machine configuration authoritative and restore native checkpoints exactly

This commit is contained in:
2026-09-18 09:09:41 +08:00
parent 6a69511276
commit 4a568f1f4c
94 changed files with 10882 additions and 301 deletions

View File

@@ -12,6 +12,18 @@ typedef struct {
static protocol_state state;
uint32_t sim_protocol_checkpoint_size(void) { return sizeof(state); }
int32_t sim_protocol_checkpoint_export(uint8_t *output, uint32_t capacity) {
if (output == NULL || capacity != sizeof(state)) return SIM_PROTOCOL_ERR_ARGUMENT;
memcpy(output, &state, sizeof(state)); return SIM_PROTOCOL_OK;
}
int32_t sim_protocol_checkpoint_restore(const uint8_t *input, uint32_t length) {
if (input == NULL || length != sizeof(state)) return SIM_PROTOCOL_ERR_ARGUMENT;
const protocol_state *saved = (const protocol_state *)input;
if (saved->state > SIM_PROTOCOL_DESTROYED) return SIM_PROTOCOL_ERR_ARGUMENT;
memcpy(&state, saved, sizeof(state)); return SIM_PROTOCOL_OK;
}
static int has_text(const char *value) {
return value != NULL && value[0] != '\0' && strlen(value) <= 128;
}