include/context_vars/context_vars_hamt.h

filter: Statementstmt 100% 12 / 12 Branchbran 71.4% 10 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 84.6% 22 / 26 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/context_vars/context_vars_obj.h ↑ Summary include/context_vars/context_vars_var.h »
1 #ifndef CONTEXT_VARS_HAMT_H
2 #define CONTEXT_VARS_HAMT_H
3  
4 /* HAMT's table, resolved once when this module loads and never per call.
5 *
6 * Where every other consumer in this workspace treats a NULL table as a
7 * degrade it always had, this one cannot: a context IS a HAMT map, and with
8 * no table there is nothing for a variable to be stored in. So the three
9 * ways of not getting one all croak, each saying which it was, and the load
10 * of Context::Vars fails with that message.
11 *
12 * Calls are written (CONTEXT_VARS_HAMT->map_fetch)(aTHX_ ...). The
13 * parentheses keep a member's name from being read as a function-like macro
14 * on a perl built with PERL_IMPLICIT_SYS. */
15 static const hamt_abi *CONTEXT_VARS_HAMT = NULL;
16  
17 40 static void context_vars_hamt_resolve(pTHX) {
18 SV *sv, *err;
19 const hamt_abi *t;
20  
21 40 ▶ if (CONTEXT_VARS_HAMT) return;
Branch: 1 branch
BranchTrueFalseTotal
if (CONTEXT_VARS_HAMT) return; 0 40 40
22  
23 /* The VALUE eval_pv returns, not the top of the stack. */
24 40 sv = eval_pv("require HAMT; HAMT::_abi_ptr()", 0);
25 40 err = get_sv("@", 0);
26 40 ▶ if (err && SvTRUE(err))
Branch: 2 branches
BranchTrueFalseTotal
if (err && SvTRUE(err)) 40 0 40
if (err && SvTRUE(err)) 1 39 40
27 1 croak("Context::Vars needs HAMT, with its C ABI at version %d or "
28 "later, and could not load it: %" SVf,
29 HAMT_ABI_VERSION, SVfARG(err));
30 39 ▶ if (!sv || !SvOK(sv) || !SvUV(sv))
Branch: 3 branches
BranchTrueFalseTotal
if (!sv || !SvOK(sv) || !SvUV(sv)) 39 0 39
if (!sv || !SvOK(sv) || !SvUV(sv)) 39 0 39
if (!sv || !SvOK(sv) || !SvUV(sv)) 1 38 39
31 1 croak("Context::Vars needs HAMT, with its C ABI at version %d or "
32 "later: the HAMT that loaded has no C ABI table",
33 HAMT_ABI_VERSION);
34  
35 38 t = INT2PTR(const hamt_abi *, SvUV(sv));
36 38 ▶ if (t->abi_version < HAMT_ABI_VERSION)
Branch: 1 branch
BranchTrueFalseTotal
if (t->abi_version < HAMT_ABI_VERSION) 1 37 38
37 1 croak("Context::Vars needs HAMT with its C ABI at version %d or "
38 "later: the HAMT that loaded has version %d",
39 HAMT_ABI_VERSION, t->abi_version);
40  
41 37 CONTEXT_VARS_HAMT = t;
42 }
43  
44 #endif
« include/context_vars/context_vars_obj.h ↑ Summary include/context_vars/context_vars_var.h »