writeonce/runtime/src/borrow.c
shoney.arickathil 631d277e0c feat(runtime): wovm VM core (Iteration 2)
- 16 tasks complete: arena, object model, borrow word, containers,
  RC + budgeted cycle collector, wob_build, validating loader,
  interpreter core (dual dispatch), object opcodes, drop-map unwinding,
  builtins + DB_STUB + TRAP, ICALL, wovm CLI + just recipes
- 13 test suites × 2 dispatch flavors (ASan+UBSan) + CLI smoke, all green
- .wob v1 format pinned in src/wob.h + docs/plan/oop-vm/00-wob-format.md
- wo-rt.c reference event-loop preserved for sub-project 2

This is Iteration 2 of the OOP milestone; compiler front (Iteration 3)
is in progress on this branch. They meet at Iteration 4 (emitter+e2e).
2026-08-10 09:35:55 +02:00

17 lines
382 B
C

#include "borrow.h"
int wo_borrow_shared(wo_hdr *o) {
if (o->borrow == WO_BORROW_EXCL) return -1;
o->borrow++;
return 0;
}
int wo_borrow_excl(wo_hdr *o) {
if (o->borrow != WO_BORROW_FREE) return -1;
o->borrow = WO_BORROW_EXCL;
return 0;
}
void wo_release_shared(wo_hdr *o) { o->borrow--; }
void wo_release_excl(wo_hdr *o) { o->borrow = WO_BORROW_FREE; }