| 1 |
|
| #ifndef STORE_HAMT_H |
| 2 |
|
| #define STORE_HAMT_H |
| 3 |
|
| |
| 4 |
|
| /* HAMT's table, resolved once when this library loads and never per call. |
| 5 |
|
| * Calls are written (STORE_HAMT->vec_push)(aTHX_ ...): the parentheses keep |
| 6 |
|
| * a member's name from being read as one of the macros XSUB.h makes of |
| 7 |
|
| * ordinary names on a perl built with PERL_IMPLICIT_SYS. */ |
| 8 |
|
| static const hamt_abi *STORE_HAMT = NULL; |
| 9 |
|
| |
| 10 |
|
| /* hamt_abi.h tells an optional consumer to carry on without the table. This |
| 11 |
|
| * one cannot: there is no history without a vector to keep it in. So a |
| 12 |
|
| * missing or older HAMT stops the load, saying which it was. */ |
| 13 |
23 |
| static void store_hamt_boot(pTHX) { |
| 14 |
|
| const hamt_abi *t; |
| 15 |
23 |
| SV *sv = eval_pv("require HAMT; HAMT::_abi_ptr()", 0); |
| 16 |
|
| |
| 17 |
23 |
▶ | if (SvTRUE(ERRSV)) |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvTRUE(ERRSV)) |
23 |
0 |
23 |
| if (SvTRUE(ERRSV)) |
1 |
22 |
23 |
|
| 18 |
1 |
▶ | croak("State::Store: cannot load HAMT: %" SVf, SVfARG(ERRSV)); |
Branch: 1 branch
| Branch | True | False | Total |
| croak("State::Store: cannot load HAMT: %" SVf, SVfARG(ERRSV)); |
1 |
0 |
1 |
|
| 19 |
22 |
▶ | if (!sv || !SvOK(sv)) |
Branch: 2 branches
| Branch | True | False | Total |
| if (!sv || !SvOK(sv)) |
22 |
0 |
22 |
| if (!sv || !SvOK(sv)) |
1 |
21 |
22 |
|
| 20 |
1 |
| croak("State::Store: HAMT did not hand over its C ABI"); |
| 21 |
21 |
| t = INT2PTR(const hamt_abi *, SvUV(sv)); |
| 22 |
21 |
▶ | if (!t) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!t) |
1 |
20 |
21 |
|
| 23 |
1 |
| croak("State::Store: HAMT did not hand over its C ABI"); |
| 24 |
20 |
▶ | if (t->abi_version < HAMT_ABI_VERSION) |
Branch: 1 branch
| Branch | True | False | Total |
| if (t->abi_version < HAMT_ABI_VERSION) |
1 |
19 |
20 |
|
| 25 |
1 |
| croak("State::Store: HAMT's C ABI is version %d and version %d or later is needed", |
| 26 |
|
| t->abi_version, HAMT_ABI_VERSION); |
| 27 |
19 |
| STORE_HAMT = t; |
| 28 |
19 |
| } |
| 29 |
|
| |
| 30 |
|
| #endif |