| 1 |
|
| #define PERL_NO_GET_CONTEXT |
| 2 |
|
| #include "EXTERN.h" |
| 3 |
|
| #include "perl.h" |
| 4 |
|
| #include "XSUB.h" |
| 5 |
|
| #include "ppport.h" |
| 6 |
6 |
| static int stk_wait_interrupted(void) { dTHX; return PL_sig_pending != 0; } |
| 7 |
|
| #define STK_WAIT_INTERRUPTED() stk_wait_interrupted() |
| 8 |
|
| #define STK_WAIT_SLICE_NS 250000000L |
| 9 |
|
| #include "stack.h" |
| 10 |
|
| |
| 11 |
|
| #define EXTRACT_STK(sv) \ |
| 12 |
|
| if (!sv_isobject(sv) || !sv_derived_from(sv, "Data::Stack::Shared")) \ |
| 13 |
|
| croak("Expected a Data::Stack::Shared object"); \ |
| 14 |
|
| StkHandle *h = INT2PTR(StkHandle*, SvIV(SvRV(sv))); \ |
| 15 |
|
| if (!h) croak("Attempted to use a destroyed Data::Stack::Shared object"); \ |
| 16 |
|
| StkHandle *h0 = h; PERL_UNUSED_VAR(h0); \ |
| 17 |
|
| sv_2mortal(SvREFCNT_inc(SvRV(sv))) |
| 18 |
|
| |
| 19 |
|
| /* Re-read the handle after a call that can run Perl code (tied/overloaded |
| 20 |
|
| * argument magic). That code may call $obj->DESTROY explicitly, which frees |
| 21 |
|
| * the handle and zeroes the IV; EXTRACT_STK's mortal pins the referent only |
| 22 |
|
| * against refcount-driven destruction, not an explicit DESTROY, so the local |
| 23 |
|
| * `h` would dangle. Used only where magic can actually intervene between |
| 24 |
|
| * EXTRACT_STK and the first use of h. */ |
| 25 |
|
| #define REEXTRACT_STK(sv) \ |
| 26 |
|
| if (!SvROK(sv)) \ |
| 27 |
|
| croak("Data::Stack::Shared object was replaced during the call"); \ |
| 28 |
|
| h = INT2PTR(StkHandle*, SvIV(SvRV(sv))); \ |
| 29 |
|
| if (h != h0) croak("Data::Stack::Shared object replaced or destroyed during the call") |
| 30 |
|
| |
| 31 |
|
| #define MAKE_OBJ(class, handle) \ |
| 32 |
|
| SV *obj = newSViv(PTR2IV(handle)); \ |
| 33 |
|
| SV *ref = newRV_noinc(obj); \ |
| 34 |
|
| sv_bless(ref, gv_stashpv(class, GV_ADD)); \ |
| 35 |
|
| RETVAL = ref |
| 36 |
|
| |
| 37 |
|
| |
| 38 |
|
| |
| 39 |
14 |
| static int stk_perl_push(pTHX_ SV *self, StkHandle *h, const void *val, uint32_t len, double timeout) { |
| 40 |
14 |
| StkHandle *h0 = h; |
| 41 |
|
| struct timespec deadline, remaining; |
| 42 |
14 |
▶ | if (timeout > 0) stk_make_deadline(timeout, &deadline); |
Branch: 1 branch
| Branch | True | False | Total |
| if (timeout > 0) stk_make_deadline(timeout, &deadline); |
1 |
13 |
14 |
|
| 43 |
14 |
| double seconds = timeout; |
| 44 |
0 |
| for (;;) { |
| 45 |
14 |
| int result = stk_push(h, val, len, seconds); |
| 46 |
14 |
▶ | if (result >= 0) return result; |
Branch: 1 branch
| Branch | True | False | Total |
| if (result >= 0) return result; |
14 |
0 |
14 |
|
| 47 |
0 |
▶ | PERL_ASYNC_CHECK(); |
Branch: 1 branch
| Branch | True | False | Total |
| PERL_ASYNC_CHECK(); |
0 |
0 |
0 |
|
| 48 |
0 |
▶ | REEXTRACT_STK(self); |
Branch: 2 branches
| Branch | True | False | Total |
| REEXTRACT_STK(self); |
0 |
0 |
0 |
| REEXTRACT_STK(self); |
0 |
0 |
0 |
|
| 49 |
0 |
▶ | if (timeout > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (timeout > 0) { |
0 |
0 |
0 |
|
| 50 |
0 |
▶ | if (!stk_remaining(&deadline, &remaining)) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!stk_remaining(&deadline, &remaining)) return 0; |
0 |
0 |
0 |
|
| 51 |
0 |
| seconds = (double)remaining.tv_sec + (double)remaining.tv_nsec / 1e9; |
| 52 |
|
| } |
| 53 |
|
| } |
| 54 |
|
| } |
| 55 |
|
| |
| 56 |
24 |
| static int stk_perl_pop(pTHX_ SV *self, StkHandle *h, void *out, double timeout) { |
| 57 |
24 |
| StkHandle *h0 = h; |
| 58 |
|
| struct timespec deadline, remaining; |
| 59 |
24 |
▶ | if (timeout > 0) stk_make_deadline(timeout, &deadline); |
Branch: 1 branch
| Branch | True | False | Total |
| if (timeout > 0) stk_make_deadline(timeout, &deadline); |
2 |
22 |
24 |
|
| 60 |
24 |
| double seconds = timeout; |
| 61 |
0 |
| for (;;) { |
| 62 |
24 |
| int result = stk_pop(h, out, seconds); |
| 63 |
24 |
▶ | if (result >= 0) return result; |
Branch: 1 branch
| Branch | True | False | Total |
| if (result >= 0) return result; |
24 |
0 |
24 |
|
| 64 |
0 |
▶ | PERL_ASYNC_CHECK(); |
Branch: 1 branch
| Branch | True | False | Total |
| PERL_ASYNC_CHECK(); |
0 |
0 |
0 |
|
| 65 |
0 |
▶ | REEXTRACT_STK(self); |
Branch: 2 branches
| Branch | True | False | Total |
| REEXTRACT_STK(self); |
0 |
0 |
0 |
| REEXTRACT_STK(self); |
0 |
0 |
0 |
|
| 66 |
0 |
▶ | if (timeout > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (timeout > 0) { |
0 |
0 |
0 |
|
| 67 |
0 |
▶ | if (!stk_remaining(&deadline, &remaining)) return 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!stk_remaining(&deadline, &remaining)) return 0; |
0 |
0 |
0 |
|
| 68 |
0 |
| seconds = (double)remaining.tv_sec + (double)remaining.tv_nsec / 1e9; |
| 69 |
|
| } |
| 70 |
|
| } |
| 71 |
|
| } |
| 72 |
|
| |
| 73 |
|
| MODULE = Data::Stack::Shared PACKAGE = Data::Stack::Shared |
| 74 |
|
| |
| 75 |
|
| PROTOTYPES: DISABLE |
| 76 |
|
| |
| 77 |
|
| void |
| 78 |
|
| DESTROY(self) |
| 79 |
|
| SV *self |
| 80 |
|
| CODE: |
| 81 |
35 |
▶ | if (!sv_isobject(self) || !sv_derived_from(self, "Data::Stack::Shared")) return; |
Branch: 2 branches
| Branch | True | False | Total |
| if (!sv_isobject(self) || !sv_derived_from(self, "Data::Stack::Shared")) return; |
35 |
0 |
35 |
| if (!sv_isobject(self) || !sv_derived_from(self, "Data::Stack::Shared")) return; |
0 |
35 |
35 |
|
| 82 |
35 |
| StkHandle *h = INT2PTR(StkHandle*, SvIV(SvRV(self))); |
| 83 |
35 |
▶ | if (!h) return; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!h) return; |
0 |
35 |
35 |
|
| 84 |
35 |
| sv_setiv(SvRV(self), 0); |
| 85 |
35 |
| stk_destroy(h); |
| 86 |
|
| |
| 87 |
|
| UV |
| 88 |
|
| size(self) |
| 89 |
|
| SV *self |
| 90 |
|
| PREINIT: |
| 91 |
11 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
11 |
0 |
11 |
| EXTRACT_STK(self); |
0 |
11 |
11 |
| EXTRACT_STK(self); |
0 |
11 |
11 |
|
| 92 |
|
| CODE: |
| 93 |
11 |
▶ | RETVAL = stk_size(h); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = stk_size(h); |
0 |
11 |
11 |
|
| 94 |
|
| OUTPUT: |
| 95 |
|
| RETVAL |
| 96 |
|
| |
| 97 |
|
| UV |
| 98 |
|
| capacity(self) |
| 99 |
|
| SV *self |
| 100 |
|
| PREINIT: |
| 101 |
3 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
3 |
0 |
3 |
| EXTRACT_STK(self); |
0 |
3 |
3 |
| EXTRACT_STK(self); |
0 |
3 |
3 |
|
| 102 |
|
| CODE: |
| 103 |
3 |
▶ | RETVAL = (UV)h->hdr->capacity; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = (UV)h->hdr->capacity; |
0 |
3 |
3 |
|
| 104 |
|
| OUTPUT: |
| 105 |
|
| RETVAL |
| 106 |
|
| |
| 107 |
|
| bool |
| 108 |
|
| is_empty(self) |
| 109 |
|
| SV *self |
| 110 |
|
| PREINIT: |
| 111 |
6 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
6 |
0 |
6 |
| EXTRACT_STK(self); |
0 |
6 |
6 |
| EXTRACT_STK(self); |
0 |
6 |
6 |
|
| 112 |
|
| CODE: |
| 113 |
6 |
▶ | RETVAL = stk_size(h) == 0; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = stk_size(h) == 0; |
6 |
0 |
6 |
|
| 114 |
|
| OUTPUT: |
| 115 |
|
| RETVAL |
| 116 |
|
| |
| 117 |
|
| bool |
| 118 |
|
| is_full(self) |
| 119 |
|
| SV *self |
| 120 |
|
| PREINIT: |
| 121 |
2 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
2 |
0 |
2 |
| EXTRACT_STK(self); |
0 |
2 |
2 |
| EXTRACT_STK(self); |
0 |
2 |
2 |
|
| 122 |
|
| CODE: |
| 123 |
2 |
▶ | RETVAL = stk_size(h) >= (UV)h->hdr->capacity; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = stk_size(h) >= (UV)h->hdr->capacity; |
2 |
0 |
2 |
|
| 124 |
|
| OUTPUT: |
| 125 |
|
| RETVAL |
| 126 |
|
| |
| 127 |
|
| void |
| 128 |
|
| clear(self) |
| 129 |
|
| SV *self |
| 130 |
|
| PREINIT: |
| 131 |
3 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
3 |
0 |
3 |
| EXTRACT_STK(self); |
0 |
3 |
3 |
| EXTRACT_STK(self); |
0 |
3 |
3 |
|
| 132 |
|
| CODE: |
| 133 |
3 |
| stk_clear(h); |
| 134 |
|
| |
| 135 |
|
| UV |
| 136 |
|
| drain(self) |
| 137 |
|
| SV *self |
| 138 |
|
| PREINIT: |
| 139 |
2 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
2 |
0 |
2 |
| EXTRACT_STK(self); |
0 |
2 |
2 |
| EXTRACT_STK(self); |
0 |
2 |
2 |
|
| 140 |
|
| CODE: |
| 141 |
2 |
▶ | RETVAL = stk_drain(h); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = stk_drain(h); |
0 |
2 |
2 |
|
| 142 |
|
| OUTPUT: |
| 143 |
|
| RETVAL |
| 144 |
|
| |
| 145 |
|
| SV * |
| 146 |
|
| path(self) |
| 147 |
|
| SV *self |
| 148 |
|
| PREINIT: |
| 149 |
1 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
1 |
0 |
1 |
| EXTRACT_STK(self); |
0 |
1 |
1 |
| EXTRACT_STK(self); |
0 |
1 |
1 |
|
| 150 |
|
| CODE: |
| 151 |
1 |
▶ | RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef; |
1 |
0 |
1 |
|
| 152 |
|
| OUTPUT: |
| 153 |
|
| RETVAL |
| 154 |
|
| |
| 155 |
|
| IV |
| 156 |
|
| memfd(self) |
| 157 |
|
| SV *self |
| 158 |
|
| PREINIT: |
| 159 |
1 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
1 |
0 |
1 |
| EXTRACT_STK(self); |
0 |
1 |
1 |
| EXTRACT_STK(self); |
0 |
1 |
1 |
|
| 160 |
|
| CODE: |
| 161 |
1 |
▶ | RETVAL = h->backing_fd; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = h->backing_fd; |
0 |
1 |
1 |
|
| 162 |
|
| OUTPUT: |
| 163 |
|
| RETVAL |
| 164 |
|
| |
| 165 |
|
| IV |
| 166 |
|
| eventfd(self) |
| 167 |
|
| SV *self |
| 168 |
|
| PREINIT: |
| 169 |
2 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
2 |
0 |
2 |
| EXTRACT_STK(self); |
0 |
2 |
2 |
| EXTRACT_STK(self); |
0 |
2 |
2 |
|
| 170 |
|
| CODE: |
| 171 |
2 |
| RETVAL = stk_create_eventfd(h); |
| 172 |
2 |
▶ | if (RETVAL < 0) croak("eventfd: %s", strerror(errno)); |
Branch: 1 branch
| Branch | True | False | Total |
| if (RETVAL < 0) croak("eventfd: %s", strerror(errno)); |
0 |
2 |
2 |
|
| 173 |
|
| OUTPUT: |
| 174 |
|
| RETVAL |
| 175 |
|
| |
| 176 |
|
| void |
| 177 |
|
| eventfd_set(self, fd) |
| 178 |
|
| SV *self |
| 179 |
|
| int fd |
| 180 |
|
| PREINIT: |
| 181 |
3 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
3 |
0 |
3 |
| EXTRACT_STK(self); |
0 |
3 |
3 |
| EXTRACT_STK(self); |
0 |
3 |
3 |
|
| 182 |
|
| CODE: |
| 183 |
3 |
▶ | if (h->notify_fd >= 0 && h->notify_fd != fd) close(h->notify_fd); |
Branch: 2 branches
| Branch | True | False | Total |
| if (h->notify_fd >= 0 && h->notify_fd != fd) close(h->notify_fd); |
3 |
0 |
3 |
| if (h->notify_fd >= 0 && h->notify_fd != fd) close(h->notify_fd); |
2 |
1 |
3 |
|
| 184 |
3 |
| h->notify_fd = fd; |
| 185 |
|
| |
| 186 |
|
| IV |
| 187 |
|
| fileno(self) |
| 188 |
|
| SV *self |
| 189 |
|
| PREINIT: |
| 190 |
5 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
5 |
0 |
5 |
| EXTRACT_STK(self); |
0 |
5 |
5 |
| EXTRACT_STK(self); |
0 |
5 |
5 |
|
| 191 |
|
| CODE: |
| 192 |
5 |
▶ | RETVAL = h->notify_fd; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = h->notify_fd; |
0 |
5 |
5 |
|
| 193 |
|
| OUTPUT: |
| 194 |
|
| RETVAL |
| 195 |
|
| |
| 196 |
|
| bool |
| 197 |
|
| notify(self) |
| 198 |
|
| SV *self |
| 199 |
|
| PREINIT: |
| 200 |
3 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
3 |
0 |
3 |
| EXTRACT_STK(self); |
0 |
3 |
3 |
| EXTRACT_STK(self); |
0 |
3 |
3 |
|
| 201 |
|
| CODE: |
| 202 |
3 |
▶ | RETVAL = stk_notify(h); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = stk_notify(h); |
3 |
0 |
3 |
|
| 203 |
|
| OUTPUT: |
| 204 |
|
| RETVAL |
| 205 |
|
| |
| 206 |
|
| SV * |
| 207 |
|
| eventfd_consume(self) |
| 208 |
|
| SV *self |
| 209 |
|
| PREINIT: |
| 210 |
2 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
2 |
0 |
2 |
| EXTRACT_STK(self); |
0 |
2 |
2 |
| EXTRACT_STK(self); |
0 |
2 |
2 |
|
| 211 |
|
| CODE: |
| 212 |
2 |
| int64_t v = stk_eventfd_consume(h); |
| 213 |
2 |
▶ | RETVAL = (v >= 0) ? newSViv((IV)v) : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = (v >= 0) ? newSViv((IV)v) : &PL_sv_undef; |
2 |
0 |
2 |
|
| 214 |
|
| OUTPUT: |
| 215 |
|
| RETVAL |
| 216 |
|
| |
| 217 |
|
| void |
| 218 |
|
| sync(self) |
| 219 |
|
| SV *self |
| 220 |
|
| PREINIT: |
| 221 |
1 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
1 |
0 |
1 |
| EXTRACT_STK(self); |
0 |
1 |
1 |
| EXTRACT_STK(self); |
0 |
1 |
1 |
|
| 222 |
|
| CODE: |
| 223 |
1 |
▶ | if (stk_msync(h) != 0) croak("msync: %s", strerror(errno)); |
Branch: 1 branch
| Branch | True | False | Total |
| if (stk_msync(h) != 0) croak("msync: %s", strerror(errno)); |
0 |
1 |
1 |
|
| 224 |
|
| |
| 225 |
|
| void |
| 226 |
|
| unlink(self_or_class, ...) |
| 227 |
|
| SV *self_or_class |
| 228 |
|
| CODE: |
| 229 |
|
| const char *p; |
| 230 |
1 |
▶ | if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::Stack::Shared")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::Stack::Shared")) { |
1 |
0 |
1 |
| if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::Stack::Shared")) { |
1 |
0 |
1 |
|
| 231 |
1 |
| StkHandle *h = INT2PTR(StkHandle*, SvIV(SvRV(self_or_class))); |
| 232 |
1 |
▶ | if (!h) croak("Attempted to use a destroyed object"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!h) croak("Attempted to use a destroyed object"); |
0 |
1 |
1 |
|
| 233 |
1 |
| p = h->path; |
| 234 |
|
| } else { |
| 235 |
0 |
▶ | if (items < 2) croak("Usage: ...->unlink($path)"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (items < 2) croak("Usage: ...->unlink($path)"); |
0 |
0 |
0 |
|
| 236 |
0 |
| p = SvPV_nolen(ST(1)); |
| 237 |
|
| } |
| 238 |
1 |
▶ | if (!p) croak("cannot unlink anonymous or memfd object"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!p) croak("cannot unlink anonymous or memfd object"); |
0 |
1 |
1 |
|
| 239 |
1 |
▶ | if (unlink(p) != 0 && errno != ENOENT) croak("unlink(%s): %s", p, strerror(errno)); |
Branch: 2 branches
| Branch | True | False | Total |
| if (unlink(p) != 0 && errno != ENOENT) croak("unlink(%s): %s", p, strerror(errno)); |
0 |
1 |
1 |
| if (unlink(p) != 0 && errno != ENOENT) croak("unlink(%s): %s", p, strerror(errno)); |
0 |
0 |
0 |
|
| 240 |
|
| |
| 241 |
|
| SV * |
| 242 |
|
| stats(self) |
| 243 |
|
| SV *self |
| 244 |
|
| PREINIT: |
| 245 |
2 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
2 |
0 |
2 |
| EXTRACT_STK(self); |
0 |
2 |
2 |
| EXTRACT_STK(self); |
0 |
2 |
2 |
|
| 246 |
|
| CODE: |
| 247 |
2 |
| HV *hv = newHV(); |
| 248 |
2 |
| StkHeader *hdr = h->hdr; |
| 249 |
2 |
| hv_store(hv, "size", 4, newSVuv(stk_size(h)), 0); |
| 250 |
2 |
| hv_store(hv, "capacity", 8, newSVuv((UV)hdr->capacity), 0); |
| 251 |
2 |
| hv_store(hv, "pushes", 6, newSVuv((UV)__atomic_load_n(&hdr->stat_pushes, __ATOMIC_RELAXED)), 0); |
| 252 |
2 |
| hv_store(hv, "pops", 4, newSVuv((UV)__atomic_load_n(&hdr->stat_pops, __ATOMIC_RELAXED)), 0); |
| 253 |
2 |
| hv_store(hv, "waits", 5, newSVuv((UV)__atomic_load_n(&hdr->stat_waits, __ATOMIC_RELAXED)), 0); |
| 254 |
2 |
| hv_store(hv, "timeouts", 8, newSVuv((UV)__atomic_load_n(&hdr->stat_timeouts, __ATOMIC_RELAXED)), 0); |
| 255 |
2 |
| hv_store(hv, "mmap_size", 9, newSVuv((UV)h->mmap_size), 0); |
| 256 |
2 |
| RETVAL = newRV_noinc((SV *)hv); |
| 257 |
|
| OUTPUT: |
| 258 |
|
| RETVAL |
| 259 |
|
| |
| 260 |
|
| |
| 261 |
|
| |
| 262 |
|
| MODULE = Data::Stack::Shared PACKAGE = Data::Stack::Shared::Int |
| 263 |
|
| |
| 264 |
|
| PROTOTYPES: DISABLE |
| 265 |
|
| |
| 266 |
|
| SV * |
| 267 |
|
| new(class, path, capacity, ...) |
| 268 |
|
| const char *class |
| 269 |
|
| SV *path |
| 270 |
|
| UV capacity |
| 271 |
|
| PREINIT: |
| 272 |
|
| char errbuf[STK_ERR_BUFLEN]; |
| 273 |
|
| CODE: |
| 274 |
19 |
▶ | mode_t mode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; |
Branch: 4 branches
| Branch | True | False | Total |
| mode_t mode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; |
0 |
19 |
19 |
| mode_t mode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; |
0 |
0 |
0 |
| mode_t mode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; |
0 |
0 |
0 |
| mode_t mode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; |
0 |
0 |
0 |
|
| 275 |
30 |
▶ | const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL; |
Branch: 3 branches
| Branch | True | False | Total |
| const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL; |
0 |
19 |
19 |
| const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL; |
0 |
0 |
0 |
| const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL; |
11 |
8 |
19 |
|
| 276 |
19 |
| StkHandle *h = stk_create(p, capacity, sizeof(int64_t), STK_VAR_INT, mode, errbuf); |
| 277 |
19 |
▶ | if (!h) croak("Data::Stack::Shared::Int->new: %s", errbuf[0] ? errbuf : "out of memory"); |
Branch: 2 branches
| Branch | True | False | Total |
| if (!h) croak("Data::Stack::Shared::Int->new: %s", errbuf[0] ? errbuf : "out of memory"); |
4 |
15 |
19 |
| if (!h) croak("Data::Stack::Shared::Int->new: %s", errbuf[0] ? errbuf : "out of memory"); |
4 |
0 |
4 |
|
| 278 |
15 |
| MAKE_OBJ(class, h); |
| 279 |
|
| OUTPUT: |
| 280 |
|
| RETVAL |
| 281 |
|
| |
| 282 |
|
| SV * |
| 283 |
|
| new_memfd(class, name, capacity) |
| 284 |
|
| const char *class |
| 285 |
|
| const char *name |
| 286 |
|
| UV capacity |
| 287 |
|
| PREINIT: |
| 288 |
|
| char errbuf[STK_ERR_BUFLEN]; |
| 289 |
|
| CODE: |
| 290 |
1 |
| StkHandle *h = stk_create_memfd(name, capacity, sizeof(int64_t), STK_VAR_INT, errbuf); |
| 291 |
1 |
▶ | if (!h) croak("Data::Stack::Shared::Int->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); |
Branch: 2 branches
| Branch | True | False | Total |
| if (!h) croak("Data::Stack::Shared::Int->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); |
0 |
1 |
1 |
| if (!h) croak("Data::Stack::Shared::Int->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); |
0 |
0 |
0 |
|
| 292 |
1 |
| MAKE_OBJ(class, h); |
| 293 |
|
| OUTPUT: |
| 294 |
|
| RETVAL |
| 295 |
|
| |
| 296 |
|
| SV * |
| 297 |
|
| new_from_fd(class, fd) |
| 298 |
|
| const char *class |
| 299 |
|
| int fd |
| 300 |
|
| PREINIT: |
| 301 |
|
| char errbuf[STK_ERR_BUFLEN]; |
| 302 |
|
| CODE: |
| 303 |
1 |
| StkHandle *h = stk_open_fd(fd, STK_VAR_INT, errbuf); |
| 304 |
1 |
▶ | if (!h) croak("Data::Stack::Shared::Int->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); |
Branch: 2 branches
| Branch | True | False | Total |
| if (!h) croak("Data::Stack::Shared::Int->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); |
0 |
1 |
1 |
| if (!h) croak("Data::Stack::Shared::Int->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); |
0 |
0 |
0 |
|
| 305 |
1 |
| MAKE_OBJ(class, h); |
| 306 |
|
| OUTPUT: |
| 307 |
|
| RETVAL |
| 308 |
|
| |
| 309 |
|
| bool |
| 310 |
|
| push(self, val) |
| 311 |
|
| SV *self |
| 312 |
|
| IV val |
| 313 |
|
| PREINIT: |
| 314 |
59 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
59 |
0 |
59 |
| EXTRACT_STK(self); |
0 |
59 |
59 |
| EXTRACT_STK(self); |
0 |
59 |
59 |
|
| 315 |
|
| CODE: |
| 316 |
59 |
| int64_t v = (int64_t)val; |
| 317 |
59 |
▶ | RETVAL = stk_try_push(h, &v, sizeof(v)); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = stk_try_push(h, &v, sizeof(v)); |
57 |
2 |
59 |
|
| 318 |
|
| OUTPUT: |
| 319 |
|
| RETVAL |
| 320 |
|
| |
| 321 |
|
| bool |
| 322 |
|
| push_wait(self, val, ...) |
| 323 |
|
| SV *self |
| 324 |
|
| IV val |
| 325 |
|
| PREINIT: |
| 326 |
1 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
1 |
0 |
1 |
| EXTRACT_STK(self); |
0 |
1 |
1 |
| EXTRACT_STK(self); |
0 |
1 |
1 |
|
| 327 |
1 |
| double timeout = -1; |
| 328 |
|
| CODE: |
| 329 |
1 |
▶ | if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); |
Branch: 4 branches
| Branch | True | False | Total |
| if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); |
1 |
0 |
1 |
| if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); |
0 |
1 |
1 |
| if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); |
0 |
0 |
0 |
| if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); |
1 |
0 |
1 |
|
| 330 |
1 |
| int64_t v = (int64_t)val; |
| 331 |
1 |
▶ | REEXTRACT_STK(self); |
Branch: 2 branches
| Branch | True | False | Total |
| REEXTRACT_STK(self); |
0 |
1 |
1 |
| REEXTRACT_STK(self); |
0 |
1 |
1 |
|
| 332 |
1 |
▶ | RETVAL = stk_perl_push(aTHX_ self, h, &v, sizeof(v), timeout); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = stk_perl_push(aTHX_ self, h, &v, sizeof(v), timeout); |
0 |
1 |
1 |
|
| 333 |
|
| OUTPUT: |
| 334 |
|
| RETVAL |
| 335 |
|
| |
| 336 |
|
| SV * |
| 337 |
|
| pop(self) |
| 338 |
|
| SV *self |
| 339 |
|
| PREINIT: |
| 340 |
18037 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
18037 |
0 |
18037 |
| EXTRACT_STK(self); |
0 |
18037 |
18037 |
| EXTRACT_STK(self); |
0 |
18037 |
18037 |
|
| 341 |
|
| CODE: |
| 342 |
|
| int64_t v; |
| 343 |
18037 |
▶ | RETVAL = stk_try_pop(h, &v) ? newSViv((IV)v) : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = stk_try_pop(h, &v) ? newSViv((IV)v) : &PL_sv_undef; |
18033 |
4 |
18037 |
|
| 344 |
|
| OUTPUT: |
| 345 |
|
| RETVAL |
| 346 |
|
| |
| 347 |
|
| SV * |
| 348 |
|
| pop_wait(self, ...) |
| 349 |
|
| SV *self |
| 350 |
|
| PREINIT: |
| 351 |
2 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
2 |
0 |
2 |
| EXTRACT_STK(self); |
0 |
2 |
2 |
| EXTRACT_STK(self); |
0 |
2 |
2 |
|
| 352 |
2 |
| double timeout = -1; |
| 353 |
|
| CODE: |
| 354 |
2 |
▶ | if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); |
Branch: 4 branches
| Branch | True | False | Total |
| if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); |
2 |
0 |
2 |
| if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); |
0 |
2 |
2 |
| if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); |
0 |
0 |
0 |
| if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); |
2 |
0 |
2 |
|
| 355 |
|
| int64_t v; |
| 356 |
2 |
▶ | REEXTRACT_STK(self); |
Branch: 2 branches
| Branch | True | False | Total |
| REEXTRACT_STK(self); |
0 |
2 |
2 |
| REEXTRACT_STK(self); |
0 |
2 |
2 |
|
| 357 |
2 |
▶ | RETVAL = stk_perl_pop(aTHX_ self, h, &v, timeout) ? newSViv((IV)v) : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = stk_perl_pop(aTHX_ self, h, &v, timeout) ? newSViv((IV)v) : &PL_sv_undef; |
1 |
1 |
2 |
|
| 358 |
|
| OUTPUT: |
| 359 |
|
| RETVAL |
| 360 |
|
| |
| 361 |
|
| SV * |
| 362 |
|
| peek(self) |
| 363 |
|
| SV *self |
| 364 |
|
| PREINIT: |
| 365 |
2 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
2 |
0 |
2 |
| EXTRACT_STK(self); |
0 |
2 |
2 |
| EXTRACT_STK(self); |
0 |
2 |
2 |
|
| 366 |
|
| CODE: |
| 367 |
|
| int64_t v; |
| 368 |
2 |
▶ | RETVAL = stk_peek(h, &v) ? newSViv((IV)v) : &PL_sv_undef; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = stk_peek(h, &v) ? newSViv((IV)v) : &PL_sv_undef; |
2 |
0 |
2 |
|
| 369 |
|
| OUTPUT: |
| 370 |
|
| RETVAL |
| 371 |
|
| |
| 372 |
|
| |
| 373 |
|
| |
| 374 |
|
| MODULE = Data::Stack::Shared PACKAGE = Data::Stack::Shared::Str |
| 375 |
|
| |
| 376 |
|
| PROTOTYPES: DISABLE |
| 377 |
|
| |
| 378 |
|
| SV * |
| 379 |
|
| new(class, path, capacity, max_len, ...) |
| 380 |
|
| const char *class |
| 381 |
|
| SV *path |
| 382 |
|
| UV capacity |
| 383 |
|
| UV max_len |
| 384 |
|
| PREINIT: |
| 385 |
|
| char errbuf[STK_ERR_BUFLEN]; |
| 386 |
|
| CODE: |
| 387 |
18 |
▶ | if (max_len == 0) croak("max_len must be > 0"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (max_len == 0) croak("max_len must be > 0"); |
0 |
18 |
18 |
|
| 388 |
18 |
▶ | if (max_len > 0x7FFFFFFFu) /* bit 31 of the stored length prefix is the UTF8 flag */ |
Branch: 1 branch
| Branch | True | False | Total |
| if (max_len > 0x7FFFFFFFu) /* bit 31 of the stored length prefix is the UTF8 flag */ |
0 |
18 |
18 |
|
| 389 |
0 |
| croak("max_len too large"); |
| 390 |
18 |
▶ | mode_t mode = (items > 4 && (SvGETMAGIC(ST(4)), SvOK(ST(4)))) ? (mode_t)SvUV(ST(4)) : 0600; |
Branch: 4 branches
| Branch | True | False | Total |
| mode_t mode = (items > 4 && (SvGETMAGIC(ST(4)), SvOK(ST(4)))) ? (mode_t)SvUV(ST(4)) : 0600; |
0 |
18 |
18 |
| mode_t mode = (items > 4 && (SvGETMAGIC(ST(4)), SvOK(ST(4)))) ? (mode_t)SvUV(ST(4)) : 0600; |
0 |
0 |
0 |
| mode_t mode = (items > 4 && (SvGETMAGIC(ST(4)), SvOK(ST(4)))) ? (mode_t)SvUV(ST(4)) : 0600; |
0 |
0 |
0 |
| mode_t mode = (items > 4 && (SvGETMAGIC(ST(4)), SvOK(ST(4)))) ? (mode_t)SvUV(ST(4)) : 0600; |
0 |
0 |
0 |
|
| 391 |
18 |
| uint32_t elem_size = (uint32_t)(sizeof(uint32_t) + max_len); |
| 392 |
18 |
▶ | const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL; |
Branch: 3 branches
| Branch | True | False | Total |
| const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL; |
0 |
18 |
18 |
| const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL; |
0 |
0 |
0 |
| const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL; |
0 |
18 |
18 |
|
| 393 |
18 |
| StkHandle *h = stk_create(p, capacity, elem_size, STK_VAR_STR, mode, errbuf); |
| 394 |
18 |
▶ | if (!h) croak("Data::Stack::Shared::Str->new: %s", errbuf[0] ? errbuf : "out of memory"); |
Branch: 2 branches
| Branch | True | False | Total |
| if (!h) croak("Data::Stack::Shared::Str->new: %s", errbuf[0] ? errbuf : "out of memory"); |
0 |
18 |
18 |
| if (!h) croak("Data::Stack::Shared::Str->new: %s", errbuf[0] ? errbuf : "out of memory"); |
0 |
0 |
0 |
|
| 395 |
18 |
| MAKE_OBJ(class, h); |
| 396 |
|
| OUTPUT: |
| 397 |
|
| RETVAL |
| 398 |
|
| |
| 399 |
|
| SV * |
| 400 |
|
| new_memfd(class, name, capacity, max_len) |
| 401 |
|
| const char *class |
| 402 |
|
| const char *name |
| 403 |
|
| UV capacity |
| 404 |
|
| UV max_len |
| 405 |
|
| PREINIT: |
| 406 |
|
| char errbuf[STK_ERR_BUFLEN]; |
| 407 |
|
| CODE: |
| 408 |
0 |
▶ | if (max_len == 0) croak("max_len must be > 0"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (max_len == 0) croak("max_len must be > 0"); |
0 |
0 |
0 |
|
| 409 |
0 |
▶ | if (max_len > 0x7FFFFFFFu) /* bit 31 of the stored length prefix is the UTF8 flag */ |
Branch: 1 branch
| Branch | True | False | Total |
| if (max_len > 0x7FFFFFFFu) /* bit 31 of the stored length prefix is the UTF8 flag */ |
0 |
0 |
0 |
|
| 410 |
0 |
| croak("max_len too large"); |
| 411 |
0 |
| uint32_t elem_size = (uint32_t)(sizeof(uint32_t) + max_len); |
| 412 |
0 |
| StkHandle *h = stk_create_memfd(name, capacity, elem_size, STK_VAR_STR, errbuf); |
| 413 |
0 |
▶ | if (!h) croak("Data::Stack::Shared::Str->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); |
Branch: 2 branches
| Branch | True | False | Total |
| if (!h) croak("Data::Stack::Shared::Str->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); |
0 |
0 |
0 |
| if (!h) croak("Data::Stack::Shared::Str->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); |
0 |
0 |
0 |
|
| 414 |
0 |
| MAKE_OBJ(class, h); |
| 415 |
|
| OUTPUT: |
| 416 |
|
| RETVAL |
| 417 |
|
| |
| 418 |
|
| SV * |
| 419 |
|
| new_from_fd(class, fd) |
| 420 |
|
| const char *class |
| 421 |
|
| int fd |
| 422 |
|
| PREINIT: |
| 423 |
|
| char errbuf[STK_ERR_BUFLEN]; |
| 424 |
|
| CODE: |
| 425 |
0 |
| StkHandle *h = stk_open_fd(fd, STK_VAR_STR, errbuf); |
| 426 |
0 |
▶ | if (!h) croak("Data::Stack::Shared::Str->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); |
Branch: 2 branches
| Branch | True | False | Total |
| if (!h) croak("Data::Stack::Shared::Str->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); |
0 |
0 |
0 |
| if (!h) croak("Data::Stack::Shared::Str->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); |
0 |
0 |
0 |
|
| 427 |
0 |
| MAKE_OBJ(class, h); |
| 428 |
|
| OUTPUT: |
| 429 |
|
| RETVAL |
| 430 |
|
| |
| 431 |
|
| bool |
| 432 |
|
| push(self, val) |
| 433 |
|
| SV *self |
| 434 |
|
| SV *val |
| 435 |
|
| PREINIT: |
| 436 |
22 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
22 |
0 |
22 |
| EXTRACT_STK(self); |
0 |
22 |
22 |
| EXTRACT_STK(self); |
0 |
22 |
22 |
|
| 437 |
|
| CODE: |
| 438 |
|
| STRLEN slen; |
| 439 |
22 |
| const char *s = SvPV(val, slen); |
| 440 |
22 |
▶ | REEXTRACT_STK(self); |
Branch: 2 branches
| Branch | True | False | Total |
| REEXTRACT_STK(self); |
0 |
22 |
22 |
| REEXTRACT_STK(self); |
0 |
22 |
22 |
|
| 441 |
22 |
| uint32_t max_len = h->elem_size - sizeof(uint32_t); |
| 442 |
22 |
▶ | if (slen > max_len) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (slen > max_len) { |
12 |
10 |
22 |
|
| 443 |
12 |
| slen = max_len; |
| 444 |
12 |
▶ | if (SvUTF8(val)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvUTF8(val)) |
11 |
1 |
12 |
|
| 445 |
23 |
▶ | while (slen && UTF8_IS_CONTINUATION((U8)s[slen])) slen--; |
Branch: 2 branches
| Branch | True | False | Total |
| while (slen && UTF8_IS_CONTINUATION((U8)s[slen])) slen--; |
22 |
1 |
23 |
| while (slen && UTF8_IS_CONTINUATION((U8)s[slen])) slen--; |
12 |
10 |
22 |
|
| 446 |
|
| } |
| 447 |
|
| uint8_t *buf; |
| 448 |
22 |
| Newxz(buf, h->elem_size, uint8_t); |
| 449 |
22 |
| uint32_t l32 = (uint32_t)slen | (SvUTF8(val) ? 0x80000000u : 0u); /* bit 31 = SvUTF8 */ |
| 450 |
22 |
| memcpy(buf, &l32, sizeof(uint32_t)); |
| 451 |
22 |
| memcpy(buf + sizeof(uint32_t), s, slen); |
| 452 |
22 |
| RETVAL = stk_try_push(h, buf, h->elem_size); |
| 453 |
22 |
| Safefree(buf); |
| 454 |
|
| OUTPUT: |
| 455 |
|
| RETVAL |
| 456 |
|
| |
| 457 |
|
| bool |
| 458 |
|
| push_wait(self, val, ...) |
| 459 |
|
| SV *self |
| 460 |
|
| SV *val |
| 461 |
|
| PREINIT: |
| 462 |
13 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
13 |
0 |
13 |
| EXTRACT_STK(self); |
0 |
13 |
13 |
| EXTRACT_STK(self); |
0 |
13 |
13 |
|
| 463 |
13 |
| double timeout = -1; |
| 464 |
|
| CODE: |
| 465 |
13 |
▶ | if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); |
Branch: 4 branches
| Branch | True | False | Total |
| if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); |
0 |
13 |
13 |
| if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); |
0 |
0 |
0 |
| if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); |
0 |
0 |
0 |
| if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); |
0 |
0 |
0 |
|
| 466 |
|
| STRLEN slen; |
| 467 |
13 |
| const char *s = SvPV(val, slen); |
| 468 |
13 |
▶ | REEXTRACT_STK(self); |
Branch: 2 branches
| Branch | True | False | Total |
| REEXTRACT_STK(self); |
0 |
13 |
13 |
| REEXTRACT_STK(self); |
0 |
13 |
13 |
|
| 469 |
13 |
| uint32_t max_len = h->elem_size - sizeof(uint32_t); |
| 470 |
13 |
▶ | if (slen > max_len) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (slen > max_len) { |
12 |
1 |
13 |
|
| 471 |
12 |
| slen = max_len; |
| 472 |
12 |
▶ | if (SvUTF8(val)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvUTF8(val)) |
11 |
1 |
12 |
|
| 473 |
23 |
▶ | while (slen && UTF8_IS_CONTINUATION((U8)s[slen])) slen--; |
Branch: 2 branches
| Branch | True | False | Total |
| while (slen && UTF8_IS_CONTINUATION((U8)s[slen])) slen--; |
22 |
1 |
23 |
| while (slen && UTF8_IS_CONTINUATION((U8)s[slen])) slen--; |
12 |
10 |
22 |
|
| 474 |
|
| } |
| 475 |
|
| uint8_t *buf; |
| 476 |
13 |
| Newxz(buf, h->elem_size, uint8_t); |
| 477 |
13 |
| SAVEFREEPV(buf); |
| 478 |
13 |
| uint32_t l32 = (uint32_t)slen | (SvUTF8(val) ? 0x80000000u : 0u); /* bit 31 = SvUTF8 */ |
| 479 |
13 |
| memcpy(buf, &l32, sizeof(uint32_t)); |
| 480 |
13 |
| memcpy(buf + sizeof(uint32_t), s, slen); |
| 481 |
13 |
▶ | RETVAL = stk_perl_push(aTHX_ self, h, buf, h->elem_size, timeout); |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = stk_perl_push(aTHX_ self, h, buf, h->elem_size, timeout); |
13 |
0 |
13 |
|
| 482 |
|
| OUTPUT: |
| 483 |
|
| RETVAL |
| 484 |
|
| |
| 485 |
|
| SV * |
| 486 |
|
| pop(self) |
| 487 |
|
| SV *self |
| 488 |
|
| PREINIT: |
| 489 |
18013 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
18013 |
0 |
18013 |
| EXTRACT_STK(self); |
0 |
18013 |
18013 |
| EXTRACT_STK(self); |
0 |
18013 |
18013 |
|
| 490 |
|
| CODE: |
| 491 |
|
| uint8_t *buf; |
| 492 |
18013 |
| Newx(buf, h->elem_size, uint8_t); |
| 493 |
18013 |
| SAVEFREEPV(buf); |
| 494 |
18013 |
▶ | if (stk_try_pop(h, buf)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (stk_try_pop(h, buf)) { |
18011 |
2 |
18013 |
|
| 495 |
|
| uint32_t len; |
| 496 |
18011 |
| memcpy(&len, buf, sizeof(uint32_t)); |
| 497 |
18011 |
| int is_utf8 = (len & 0x80000000u) != 0; /* bit 31 = SvUTF8 */ |
| 498 |
18011 |
| len &= 0x7FFFFFFFu; |
| 499 |
18011 |
| uint32_t max_len = h->elem_size - sizeof(uint32_t); |
| 500 |
18011 |
▶ | if (len > max_len) len = max_len; |
Branch: 1 branch
| Branch | True | False | Total |
| if (len > max_len) len = max_len; |
0 |
18011 |
18011 |
|
| 501 |
18011 |
| RETVAL = newSVpvn((char *)buf + sizeof(uint32_t), len); |
| 502 |
18011 |
▶ | if (is_utf8) SvUTF8_on(RETVAL); |
Branch: 1 branch
| Branch | True | False | Total |
| if (is_utf8) SvUTF8_on(RETVAL); |
2 |
18009 |
18011 |
|
| 503 |
|
| } else { |
| 504 |
2 |
| RETVAL = &PL_sv_undef; |
| 505 |
|
| } |
| 506 |
|
| OUTPUT: |
| 507 |
|
| RETVAL |
| 508 |
|
| |
| 509 |
|
| SV * |
| 510 |
|
| pop_wait(self, ...) |
| 511 |
|
| SV *self |
| 512 |
|
| PREINIT: |
| 513 |
22 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
22 |
0 |
22 |
| EXTRACT_STK(self); |
0 |
22 |
22 |
| EXTRACT_STK(self); |
0 |
22 |
22 |
|
| 514 |
22 |
| double timeout = -1; |
| 515 |
|
| CODE: |
| 516 |
22 |
▶ | if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); |
Branch: 4 branches
| Branch | True | False | Total |
| if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); |
0 |
22 |
22 |
| if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); |
0 |
0 |
0 |
| if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); |
0 |
0 |
0 |
| if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); |
0 |
0 |
0 |
|
| 517 |
22 |
▶ | REEXTRACT_STK(self); |
Branch: 2 branches
| Branch | True | False | Total |
| REEXTRACT_STK(self); |
0 |
22 |
22 |
| REEXTRACT_STK(self); |
0 |
22 |
22 |
|
| 518 |
|
| uint8_t *buf; |
| 519 |
22 |
| Newx(buf, h->elem_size, uint8_t); |
| 520 |
22 |
| SAVEFREEPV(buf); |
| 521 |
22 |
▶ | if (stk_perl_pop(aTHX_ self, h, buf, timeout)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (stk_perl_pop(aTHX_ self, h, buf, timeout)) { |
22 |
0 |
22 |
|
| 522 |
|
| uint32_t len; |
| 523 |
22 |
| memcpy(&len, buf, sizeof(uint32_t)); |
| 524 |
22 |
| int is_utf8 = (len & 0x80000000u) != 0; /* bit 31 = SvUTF8 */ |
| 525 |
22 |
| len &= 0x7FFFFFFFu; |
| 526 |
22 |
| uint32_t max_len = h->elem_size - sizeof(uint32_t); |
| 527 |
22 |
▶ | if (len > max_len) len = max_len; |
Branch: 1 branch
| Branch | True | False | Total |
| if (len > max_len) len = max_len; |
0 |
22 |
22 |
|
| 528 |
22 |
| RETVAL = newSVpvn((char *)buf + sizeof(uint32_t), len); |
| 529 |
22 |
▶ | if (is_utf8) SvUTF8_on(RETVAL); |
Branch: 1 branch
| Branch | True | False | Total |
| if (is_utf8) SvUTF8_on(RETVAL); |
22 |
0 |
22 |
|
| 530 |
|
| } else { |
| 531 |
0 |
| RETVAL = &PL_sv_undef; |
| 532 |
|
| } |
| 533 |
|
| OUTPUT: |
| 534 |
|
| RETVAL |
| 535 |
|
| |
| 536 |
|
| SV * |
| 537 |
|
| peek(self) |
| 538 |
|
| SV *self |
| 539 |
|
| PREINIT: |
| 540 |
23 |
▶ | EXTRACT_STK(self); |
Branch: 3 branches
| Branch | True | False | Total |
| EXTRACT_STK(self); |
23 |
0 |
23 |
| EXTRACT_STK(self); |
0 |
23 |
23 |
| EXTRACT_STK(self); |
0 |
23 |
23 |
|
| 541 |
|
| CODE: |
| 542 |
|
| uint8_t *buf; |
| 543 |
23 |
| Newx(buf, h->elem_size, uint8_t); |
| 544 |
23 |
| SAVEFREEPV(buf); |
| 545 |
23 |
▶ | if (stk_peek(h, buf)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (stk_peek(h, buf)) { |
23 |
0 |
23 |
|
| 546 |
|
| uint32_t len; |
| 547 |
23 |
| memcpy(&len, buf, sizeof(uint32_t)); |
| 548 |
23 |
| int is_utf8 = (len & 0x80000000u) != 0; /* bit 31 = SvUTF8 */ |
| 549 |
23 |
| len &= 0x7FFFFFFFu; |
| 550 |
23 |
| uint32_t max_len = h->elem_size - sizeof(uint32_t); |
| 551 |
23 |
▶ | if (len > max_len) len = max_len; |
Branch: 1 branch
| Branch | True | False | Total |
| if (len > max_len) len = max_len; |
0 |
23 |
23 |
|
| 552 |
23 |
| RETVAL = newSVpvn((char *)buf + sizeof(uint32_t), len); |
| 553 |
23 |
▶ | if (is_utf8) SvUTF8_on(RETVAL); |
Branch: 1 branch
| Branch | True | False | Total |
| if (is_utf8) SvUTF8_on(RETVAL); |
22 |
1 |
23 |
|
| 554 |
|
| } else { |
| 555 |
0 |
| RETVAL = &PL_sv_undef; |
| 556 |
|
| } |
| 557 |
|
| OUTPUT: |
| 558 |
|
| RETVAL |