| 45 | int fake_ok(const void*, size_t) { ++g_calls; return 0; } |
| 46 | int fake_fail(const void*, size_t) { ++g_calls; errno = ENOMEM; return -1; } |
| 47 | int 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 | |
| 56 | std::vector<LockPart> two_parts(uint8_t* a, size_t na, uint8_t* b, size_t nb) { |
| 57 | LockPart x, y; |
nothing calls this directly
no test coverage detected