MCPcopy Create free account
hub / github.com/Niko1221/Strata / fake_cap

Function fake_cap

engine/src/split/tools/memlock_test.cpp:47–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45int fake_ok(const void*, size_t) { ++g_calls; return 0; }
46int fake_fail(const void*, size_t) { ++g_calls; errno = ENOMEM; return -1; }
47int fake_cap(const void*, size_t n) { // like the kernel: a call that would pass the allowance fails whole
48 ++g_calls;
49 uint64_t cur = g_locked.load();
50 for (;;) {
51 if (cur + n > g_cap.load()) { errno = ENOMEM; return -1; }
52 if (g_locked.compare_exchange_weak(cur, cur + n)) return 0;
53 }
54}
55
56std::vector<LockPart> two_parts(uint8_t* a, size_t na, uint8_t* b, size_t nb) {
57 LockPart x, y;

Callers

nothing calls this directly

Calls 2

compare_exchange_weakMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected