Hyperman.c

filter: Statementstmt 84.9% 903 / 1063 Branchbran 51.4% 250 / 486 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 74.4% 1153 / 1549 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/abi.xs ↑ Summary include/hyperman/hm_workerhook_perl.h »
1 /*
2 * This file was generated automatically by ExtUtils::ParseXS version 3.63 from the
3 * contents of Hyperman.xs. Do not edit this file, edit Hyperman.xs instead.
4 *
5 * ANY CHANGES MADE HERE WILL BE LOST!
6 *
7 */
8  
9 #line 1 "Hyperman.xs"
10 /*
11 * Hyperman.xs - Root XS file
12 *
13 * Thin wrapper (Chandra-style layout): pulls in the C core from
14 * include/hyperman/ - the backend vtable + implementations (unity build),
15 * the Future primitive, and the loop/server core - then the per-package
16 * XS fragments via INCLUDE:. All Hyperman-namespace behavior lives in C;
17 * the .pm files are documentation/loader stubs.
18 */
19  
20 #ifndef _GNU_SOURCE
21 #define _GNU_SOURCE /* memmem on glibc */
22 #endif
23 #define PERL_NO_GET_CONTEXT
24 /* Under PERL_IMPLICIT_SYS - every Strawberry build - XSUB.h rewrites the
25 * plain CRT and socket names into PerlMem_/PerlSock_/PerlEnv_ macros that
26 * dereference my_perl. This core is C: its helpers are static functions in
27 * headers with no interpreter to hand, and even a struct member called
28 * `wait` collides with the PerlProc_wait macro. NO_XSLOCKS is the switch
29 * XSUB.h provides for exactly that, and it must come before the include or
30 * the rewrites are already in place.
31 *
32 * Nothing is given up. This code owns what it allocates and closes what it
33 * opens end to end, so it never hands a pointer to perl's allocator or takes
34 * one from it; the SV and PerlIO calls it does make are functions, not
35 * remapped names, and are unaffected. */
36 #define NO_XSLOCKS
37 #include "EXTERN.h"
38 #include "perl.h"
39 #include "XSUB.h"
40 #include "hm_compat.h" /* perl API shims (XS_INTERNAL, mg_findext, croak_sv) */
41  
42 /* The platform headers come from the shim, first and only - the same rule
43 * hm_core.h follows. On POSIX hm_win.h expands to exactly the <sys/socket.h>
44 * / <sys/uio.h> / netinet / <unistd.h> block this file used to spell out
45 * by hand; on Windows it expands to Winsock. Spelling them out here is what
46 * broke the 0.23 Windows build: <sys/uio.h> does not exist on MinGW, and it
47 * was included eighteen lines above the header that knows that. */
48 #include "hm_win.h"
49  
50 /* CRT headers, present everywhere: not the shim's business. */
51 #include <string.h>
52 #include <stdlib.h>
53 #include <ctype.h>
54 #include <signal.h>
55  
56 /* The prefork supervisor's headers. hm_core.h compiles that whole half
57 * under #ifndef _WIN32 (no fork, no waitpid, no POSIX signals there), so
58 * its includes carry the same guard. */
59 #ifndef _WIN32
60 #include <sys/wait.h>
61 #ifdef __linux__
62 #include <sched.h>
63 #endif
64 #endif
65  
66 #include "hyperman.h"
67  
68 /* readiness backends: one translation unit, guarded per platform */
69 #include "backend_kqueue.c"
70 #include "backend_epoll.c"
71 #include "backend_iouring.c"
72 #include "backend_wsapoll.c"
73 #include "backend_poll.c"
74  
75 #include "hm_future.h"
76 #include "hm_sa.h" /* Shared::Arena's table and the one arena */
77 #include "hm_sa_abuse.h" /* the denylist and the fixed window, on it */
78 #include "hm_sa_bus.h" /* the message bus, on a ring in it */
79 #include "hm_sa_bus_perl.h" /* ... and its Perl-side collector and deliverer */
80 #include "hm_sa_board.h" /* the worker scoreboard and the distinct clients */
81 #include "hm_compress.h" /* gzip on the way out (zlib optional) */
82 #include "hm_workerhook.h" /* the v4 on_worker_start registry; hm_core fires
83 * it, hm_abi_impl registers into it */
84 #include "hm_workerhook_perl.h" /* ... and the Perl door onto that registry */
85 #include "hm_core.h"
86 #include "hm_abi_impl.h"
87  
88 #line 89 "Hyperman.c"
89 #ifndef PERL_UNUSED_VAR
90 # define PERL_UNUSED_VAR(var) if (0) var = var
91 #endif
92  
93 #ifndef dVAR
94 # define dVAR dNOOP
95 #endif
96  
97  
98 /* This stuff is not part of the API! You have been warned. */
99 #ifndef PERL_VERSION_DECIMAL
100 # define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
101 #endif
102 #ifndef PERL_DECIMAL_VERSION
103 # define PERL_DECIMAL_VERSION \
104 PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
105 #endif
106 #ifndef PERL_VERSION_GE
107 # define PERL_VERSION_GE(r,v,s) \
108 (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
109 #endif
110 #ifndef PERL_VERSION_LE
111 # define PERL_VERSION_LE(r,v,s) \
112 (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
113 #endif
114  
115 /* XS_INTERNAL is the explicit static-linkage variant of the default
116 * XS macro.
117 *
118 * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
119 * "static", ie. it exports XSUB symbols. You probably don't want that
120 * for anything but the BOOT XSUB.
121 *
122 * See XSUB.h in core!
123 */
124  
125  
126 /* TODO: This might be compatible further back than 5.10.0. */
127 #if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
128 # undef XS_EXTERNAL
129 # undef XS_INTERNAL
130 # if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
131 # define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
132 # define XS_INTERNAL(name) static XSPROTO(name)
133 # endif
134 # if defined(__SYMBIAN32__)
135 # define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
136 # define XS_INTERNAL(name) EXPORT_C static XSPROTO(name)
137 # endif
138 # ifndef XS_EXTERNAL
139 # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
140 # define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
141 # define XS_INTERNAL(name) static void name(pTHX_ CV* cv __attribute__unused__)
142 # else
143 # ifdef __cplusplus
144 # define XS_EXTERNAL(name) extern "C" XSPROTO(name)
145 # define XS_INTERNAL(name) static XSPROTO(name)
146 # else
147 # define XS_EXTERNAL(name) XSPROTO(name)
148 # define XS_INTERNAL(name) static XSPROTO(name)
149 # endif
150 # endif
151 # endif
152 #endif
153  
154 /* perl >= 5.10.0 && perl <= 5.15.1 */
155  
156  
157 /* The XS_EXTERNAL macro is used for functions that must not be static
158 * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
159 * macro defined, the best we can do is assume XS is the same.
160 * Dito for XS_INTERNAL.
161 */
162 #ifndef XS_EXTERNAL
163 # define XS_EXTERNAL(name) XS(name)
164 #endif
165 #ifndef XS_INTERNAL
166 # define XS_INTERNAL(name) XS(name)
167 #endif
168  
169 /* Now, finally, after all this mess, we want an ExtUtils::ParseXS
170 * internal macro that we're free to redefine for varying linkage due
171 * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
172 * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
173 */
174  
175 #undef XS_EUPXS
176 #if defined(PERL_EUPXS_ALWAYS_EXPORT)
177 # define XS_EUPXS(name) XS_EXTERNAL(name)
178 #else
179 /* default to internal */
180 # define XS_EUPXS(name) XS_INTERNAL(name)
181 #endif
182  
183 #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
184 #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
185  
186 /* prototype to pass -Wmissing-prototypes */
187 static void
188 S_croak_xs_usage(const CV *const cv, const char *const params);
189  
190 static void
191 S_croak_xs_usage(const CV *const cv, const char *const params)
192 {
193 const GV *const gv = CvGV(cv);
194  
195 PERL_ARGS_ASSERT_CROAK_XS_USAGE;
196  
197 if (gv) {
198 const char *const gvname = GvNAME(gv);
199 const HV *const stash = GvSTASH(gv);
200 const char *const hvname = stash ? HvNAME(stash) : NULL;
201  
202 if (hvname)
203 Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
204 else
205 Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
206 } else {
207 /* Pants. I don't think that it should be possible to get here. */
208 Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
209 }
210 }
211 #undef PERL_ARGS_ASSERT_CROAK_XS_USAGE
212  
213 #define croak_xs_usage S_croak_xs_usage
214  
215 #endif
216  
217 /* NOTE: the prototype of newXSproto() is different in versions of perls,
218 * so we define a portable version of newXSproto()
219 */
220 #ifdef newXS_flags
221 #define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
222 #else
223 #define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
224 #endif /* !defined(newXS_flags) */
225  
226 #if PERL_VERSION_LE(5, 21, 5)
227 # define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
228 #else
229 # define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
230 #endif
231  
232 /* simple backcompat versions of the TARGx() macros with no optimisation */
233 #ifndef TARGi
234 # define TARGi(iv, do_taint) sv_setiv_mg(TARG, iv)
235 # define TARGu(uv, do_taint) sv_setuv_mg(TARG, uv)
236 # define TARGn(nv, do_taint) sv_setnv_mg(TARG, nv)
237 #endif
238  
239 #line 240 "Hyperman.c"
240  
241 /* INCLUDE: Including 'xs/hyperman.xs' from 'Hyperman.xs' */
242  
243  
244 XS_EUPXS(XS_Hyperman_run); /* prototype to pass -Wmissing-prototypes */
245 161 XS_EUPXS(XS_Hyperman_run)
246 {
247 161 dVAR; dXSARGS;
248 161 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 161 161
249 0 croak_xs_usage(cv, "class, ...");
250 {
251 161 ▶ SV * class = ST(0)
Branch: 1 branch
BranchTrueFalseTotal
SV * class = ST(0) 1 160 161
252 ;
253 #line 21 "./xs/hyperman.xs"
254 {
255 hm_worker_cfg cfg;
256 hm_listener_spec dfl; /* top-level defaults, seeded into each spec */
257 SV *port_sv = NULL, *listen_sv = NULL;
258 int i;
259 PERL_UNUSED_VAR(class);
260  
261 if ((items - 1) % 2)
262 croak("Hyperman->run: odd number of options");
263  
264 memset(&cfg, 0, sizeof(cfg));
265 cfg.log_fd = -1;
266 cfg.err_fd = -1;
267 cfg.http3_max_conns = 1024; /* an explicit 0 lifts the cap */
268 /* -1 is "the caller said nothing", which is NOT the same as
269 * completion => 0. The memset above would otherwise read as an
270 * explicit request to turn completion-mode reads off on every
271 * server that never mentions them. */
272 cfg.completion = -1;
273 memset(&dfl, 0, sizeof(dfl));
274 dfl.host = "0.0.0.0";
275 dfl.port = 8080;
276  
277 for (i = 1; i + 1 < items; i += 2) {
278 const char *key = SvPV_nolen(ST(i));
279 SV *val = ST(i + 1);
280 if (strEQ(key, "app")) cfg.app = val;
281 else if (strEQ(key, "host")) { if (SvOK(val)) dfl.host = SvPV_nolen(val); }
282 else if (strEQ(key, "port")) port_sv = val;
283 else if (strEQ(key, "listen")) listen_sv = SvOK(val) ? val : NULL; /* # uncoverable condition right count:2 class:ignore_covered_err */
284 else if (strEQ(key, "workers")) cfg.nworkers = (int)SvIV(val);
285 else if (strEQ(key, "idle_timeout")) cfg.idle_t = SvNV(val);
286 else if (strEQ(key, "header_timeout")) cfg.header_t = SvNV(val);
287 else if (strEQ(key, "body_timeout")) cfg.body_t = SvNV(val);
288 else if (strEQ(key, "request_timeout")) cfg.request_t = SvNV(val);
289 else if (strEQ(key, "body_min_rate")) cfg.body_min_rate = hm_opt_count(aTHX_ val, key);
290 else if (strEQ(key, "max_pipeline")) cfg.max_pipe = (int)SvIV(val);
291 else if (strEQ(key, "reuseport")) cfg.reuseport = SvTRUE(val) ? 1 : 0;
292 /* Completion-mode reads. On by default wherever the backend can
293 * do them - which is io_uring, and only when it was asked for by
294 * name - so this is here to turn them OFF. Inert everywhere else:
295 * a backend that cannot submit reads simply ignores it. */
296 else if (strEQ(key, "completion")) cfg.completion = SvTRUE(val) ? 1 : 0;
297 else if (strEQ(key, "deny")) { if (SvOK(val) && SvROK(val)) cfg.deny = val; }
298 else if (strEQ(key, "deny_capacity")) cfg.deny_cap = (unsigned)SvUV(val);
299 else if (strEQ(key, "rate_capacity")) cfg.rate_cap = (unsigned)SvUV(val);
300 /* The message bus. `bus_slots` is headroom before a slow worker
301 * is lapped; `bus_slot_size` is the largest message that will be
302 * accepted. Two knobs because they answer two different
303 * complaints. */
304 else if (strEQ(key, "bus_slots")) cfg.bus_slots = (unsigned)SvUV(val);
305 else if (strEQ(key, "bus_slot_size")) cfg.bus_slot_size = (unsigned)SvUV(val);
306 else if (strEQ(key, "bus_groups")) cfg.bus_groups = (unsigned)SvUV(val);
307 /* The Shared::Arena. A name makes it attachable by another
308 * process and survives a restart; the size is computed from the
309 * tenants unless overridden. */
310 else if (strEQ(key, "arena_name")) {
311 if (SvOK(val)) cfg.arena_name = SvPV(val, cfg.arena_name_len);
312 }
313 else if (strEQ(key, "arena_size")) cfg.arena_size = SvUV(val);
314 /* Count distinct peers at accept. Off by default: it is a hash
315 * and a CAS-max on the accept path, about 20ns, and this server
316 * promises that path costs nothing it did not ask for. */
317 else if (strEQ(key, "distinct_clients")) cfg.distinct_clients = SvTRUE(val) ? 1 : 0;
318 else if (strEQ(key, "access_log")) {
319 /* coderef -> per-request Perl callback (as before);
320 * a filehandle or a path -> fast C-side Combined-log writer. */
321 if (!SvOK(val)) {
322 cfg.log_cb = NULL;
323 } else if (SvROK(val) && SvTYPE(SvRV(val)) == SVt_PVCV) {
324 cfg.log_cb = val;
325 } else {
326 SV *g = (SvROK(val) && SvTYPE(SvRV(val)) == SVt_PVGV)
327 ? SvRV(val) : val;
328 if (SvTYPE(g) == SVt_PVGV) {
329 IO *io = GvIO((GV *)g);
330 PerlIO *fp = io ? (IoOFP(io) ? IoOFP(io) : IoIFP(io)) : NULL; /* # uncoverable condition right count:2 class:ignore_covered_err */
331 int raw = fp ? PerlIO_fileno(fp) : -1;
332 if (raw < 0)
333 croak("Hyperman->run: access_log handle has no fileno");
334 cfg.log_fd = dup(raw); /* own it; freed with the loop */
335 if (cfg.log_fd < 0)
336 croak("Hyperman->run: dup access_log fd: %s", /* # uncoverable statement class:ignore_covered_err */
337 strerror(errno)); /* # uncoverable statement class:ignore_covered_err */
338 #ifndef _WIN32
339 (void)fcntl(cfg.log_fd, F_SETFD, FD_CLOEXEC);
340 #endif
341 } else {
342 cfg.log_path = SvPV_nolen(val); /* opened in the parent */
343 }
344 }
345 }
346 else if (strEQ(key, "user")) { if (SvOK(val)) cfg.drop_user = SvPV_nolen(val); }
347 else if (strEQ(key, "group")) { if (SvOK(val)) cfg.drop_group = SvPV_nolen(val); }
348 else if (strEQ(key, "pid_file")) { if (SvOK(val)) cfg.pid_path = SvPV_nolen(val); }
349 else if (strEQ(key, "listen_fds")) cfg.listen_fds = SvTRUE(val) ? 1 : 0;
350 else if (strEQ(key, "umask")) {
351 /* a number as perl parsed it (0077 is already 63), or a string
352 * of octal digits as a shell would write it ("077") */
353 if (SvOK(val)) {
354 if (SvIOK(val) || SvNOK(val)) cfg.umask_val = (unsigned)SvUV(val); /* # uncoverable condition left count:2 class:ignore_covered_err */
355 else {
356 char *end;
357 const char *s = SvPV_nolen(val);
358 cfg.umask_val = (unsigned)strtoul(s, &end, 8);
359 if (*s == '\0' || *end != '\0')
360 croak("Hyperman->run: umask '%s' is not an octal number", s);
361 }
362 cfg.umask_set = 1;
363 }
364 }
365 else if (strEQ(key, "access_log_format")) {
366 if (SvOK(val)) cfg.log_format = SvPV_nolen(val);
367 }
368 else if (strEQ(key, "error_log")) {
369 /* a filehandle or a path; the server's own messages go there
370 * instead of stderr. psgi.errors is the application's and is
371 * not moved. */
372 if (SvOK(val)) {
373 SV *g = (SvROK(val) && SvTYPE(SvRV(val)) == SVt_PVGV)
374 ? SvRV(val) : val;
375 if (SvTYPE(g) == SVt_PVGV) {
376 IO *io = GvIO((GV *)g);
377 PerlIO *fp = io ? (IoOFP(io) ? IoOFP(io) : IoIFP(io)) : NULL; /* # uncoverable condition right count:2 class:ignore_covered_err */
378 int raw = fp ? PerlIO_fileno(fp) : -1;
379 if (raw < 0)
380 croak("Hyperman->run: error_log handle has no fileno");
381 cfg.err_fd = dup(raw);
382 if (cfg.err_fd < 0)
383 croak("Hyperman->run: dup error_log fd: %s", strerror(errno)); /* # uncoverable statement class:ignore_covered_err */
384 #ifndef _WIN32
385 (void)fcntl(cfg.err_fd, F_SETFD, FD_CLOEXEC);
386 #endif
387 } else {
388 cfg.err_path = SvPV_nolen(val);
389 }
390 }
391 }
392 else if (strEQ(key, "max_requests_per_worker"))
393 cfg.max_requests = hm_opt_count(aTHX_ val, key);
394 /* Response compression. Off by default: a server that starts
395 * compressing on upgrade is a surprise. Accepted and inert on a
396 * build without zlib, so a config is portable across them. */
397 else if (strEQ(key, "compress")) cfg.compress = SvTRUE(val) ? 1 : 0;
398 else if (strEQ(key, "compress_min_length"))
399 cfg.compress_min = (size_t)hm_opt_count(aTHX_ val, key);
400 /* The request ceiling: headers plus body, buffered per
401 * connection before the app is called. This is the only thing
402 * bounding a worker's memory against a large POST, so 0 is
403 * REFUSED rather than read as "unlimited" - an unbounded read
404 * ceiling is a memory-exhaustion switch and must not be
405 * reachable by a config typo that produces a falsy value. */
406 else if (strEQ(key, "max_body")) {
407 UV n = hm_opt_count(aTHX_ val, key); /* -1 was UV_MAX: unbounded */
408 if (!n)
409 croak("Hyperman->run: max_body must be a byte count - "
410 "0 would mean an unbounded request buffer, which "
411 "is a memory-exhaustion switch, not a setting");
412 cfg.max_read = (size_t)n;
413 }
414 else if (strEQ(key, "compress_level")) {
415 IV lv = SvIV(val);
416 if (lv < 1 || lv > 9) /* # uncoverable condition left count:1 class:ignore_covered_err */
417 croak("Hyperman->run: compress_level must be 1..9");
418 cfg.compress_level = (int)lv;
419 }
420 else if (strEQ(key, "shutdown_grace")) cfg.grace = SvNV(val);
421 else if (strEQ(key, "affinity")) cfg.affinity = SvTRUE(val) ? 1 : 0;
422 else if (strEQ(key, "http2")) dfl.http2 = SvTRUE(val) ? 1 : 0;
423 else if (strEQ(key, "http3")) dfl.http3 = SvTRUE(val) ? 1 : 0;
424 else if (strEQ(key, "proxy_protocol")) dfl.proxy_protocol = SvTRUE(val) ? 1 : 0;
425 else if (strEQ(key, "http3_max_conns")) cfg.http3_max_conns = hm_opt_count(aTHX_ val, key);
426 else if (strEQ(key, "tls_cert")) dfl.tls_cert = SvOK(val) ? SvPV_nolen(val) : NULL; /* # uncoverable condition right count:2 class:ignore_covered_err */
427 else if (strEQ(key, "tls_key")) dfl.tls_key = SvOK(val) ? SvPV_nolen(val) : NULL; /* # uncoverable condition right count:2 class:ignore_covered_err */
428 else if (strEQ(key, "tls_ca")) dfl.tls_ca = SvOK(val) ? SvPV_nolen(val) : NULL; /* # uncoverable condition right count:2 class:ignore_covered_err */
429 else if (strEQ(key, "tls_sni")) dfl.tls_sni = SvOK(val) ? val : NULL; /* # uncoverable condition right count:2 class:ignore_covered_err */
430 else if (strEQ(key, "redirect_https")) dfl.redirect_https = (int)SvIV(val);
431 else if (strEQ(key, "tls_verify")) {
432 const char *m = SvPV_nolen(val);
433 if (strEQ(m, "require")) dfl.tls_verify = 2;
434 else if (strEQ(m, "optional")) dfl.tls_verify = 1;
435 else if (strEQ(m, "none")) dfl.tls_verify = 0;
436 else croak("Hyperman->run: tls_verify must be none/optional/require");
437 }
438 else croak("Hyperman->run: unknown option '%s'", key);
439 }
440 if (!(cfg.app && SvROK(cfg.app) && SvTYPE(SvRV(cfg.app)) == SVt_PVCV))
441 croak("Hyperman->run: 'app' is required");
442 if (dfl.redirect_https == 1) dfl.redirect_https = 443;
443  
444 /* Build the listener specs. Three shapes, most specific wins:
445 * listen => [ {..}, .. ] - full per-listener control (incl. TLS)
446 * port => [ N, M ] - several plain listeners sharing defaults
447 * port => N (or unset) - one listener from the top-level options */
448 {
449 hm_listener_spec *ls;
450 int n, j;
451 AV *lav = (listen_sv && SvROK(listen_sv)
452 && SvTYPE(SvRV(listen_sv)) == SVt_PVAV)
453 ? (AV *)SvRV(listen_sv) : NULL;
454 AV *pav = (port_sv && SvROK(port_sv)
455 && SvTYPE(SvRV(port_sv)) == SVt_PVAV)
456 ? (AV *)SvRV(port_sv) : NULL;
457  
458 if (listen_sv && !lav)
459 croak("Hyperman->run: 'listen' must be an arrayref of hashrefs");
460  
461 n = lav ? (int)(av_len(lav) + 1)
462 : pav ? (int)(av_len(pav) + 1)
463 : 1;
464 if (n < 1) croak("Hyperman->run: 'listen'/'port' is empty");
465 ls = (hm_listener_spec *)hm_xcalloc(n, sizeof(hm_listener_spec));
466  
467 for (j = 0; j < n; j++) {
468 ls[j] = dfl; /* seed with top-level defaults */
469 if (lav) {
470 SV **e = av_fetch(lav, j, 0);
471 if (!(e && SvROK(*e) && SvTYPE(SvRV(*e)) == SVt_PVHV))
472 croak("Hyperman->run: listen[%d] must be a hashref", j);
473 hm_listener_from_hv(aTHX_ (HV *)SvRV(*e), &ls[j]);
474 } else if (pav) {
475 SV **e = av_fetch(pav, j, 0);
476 if (e) ls[j].port = (int)SvIV(*e);
477 } else if (port_sv && SvOK(port_sv)) { /* # uncoverable condition right count:2 class:ignore_covered_err */
478 ls[j].port = (int)SvIV(port_sv);
479 }
480 hm_check_listener(aTHX_ &ls[j]);
481 }
482  
483 cfg.lspecs = ls;
484 cfg.nlspecs = n;
485 hm_run_server(aTHX_ &cfg); /* normally blocks until shutdown */
486 free(ls);
487 }
488 }
489 #line 490 "Hyperman.c"
490 }
491 77 XSRETURN_EMPTY;
492 }
493  
494  
495 XS_EUPXS(XS_Hyperman_timer); /* prototype to pass -Wmissing-prototypes */
496 6 XS_EUPXS(XS_Hyperman_timer)
497 {
498 6 dVAR; dXSARGS;
499 6 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 6 6
500 0 croak_xs_usage(cv, "class, secs");
501 {
502 6 SV * class = ST(0)
503 ;
504 6 double secs = (double)SvNV(ST(1))
505 ;
506 SV * RETVAL;
507 #line 300 "./xs/hyperman.xs"
508 {
509 hm_loop *loop = hm_need_loop();
510 SV *f = hmf_new(aTHX_ "Hyperman::Future");
511 PERL_UNUSED_VAR(class);
512 hm_add_timer_watch(aTHX_ loop, secs, f, HM_TW_FUTURE);
513 RETVAL = f;
514 }
515 #line 516 "Hyperman.c"
516 6 RETVAL = sv_2mortal(RETVAL);
517 6 ST(0) = RETVAL;
518 }
519 6 XSRETURN(1);
520 }
521  
522  
523 XS_EUPXS(XS_Hyperman_io_ready); /* prototype to pass -Wmissing-prototypes */
524 3 XS_EUPXS(XS_Hyperman_io_ready)
525 {
526 3 dVAR; dXSARGS;
527 3 ▶ if (items < 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) 0 3 3
528 0 croak_xs_usage(cv, "class, fh, ...");
529 {
530 3 SV * class = ST(0)
531 ;
532 3 SV * fh = ST(1)
533 ;
534 SV * RETVAL;
535 #line 317 "./xs/hyperman.xs"
536 {
537 hm_loop *loop = hm_need_loop();
538 const char *mode = (items > 2 && SvOK(ST(2))) ? SvPV_nolen(ST(2)) : "r"; /* # uncoverable condition right count:2 class:ignore_covered_err */
539 SV *f = hmf_new(aTHX_ "Hyperman::Future");
540 PERL_UNUSED_VAR(class);
541 hm_add_io_watch(aTHX_ loop, hm_fd_of(aTHX_ fh), mode, f, 0);
542 RETVAL = f;
543 }
544 #line 545 "Hyperman.c"
545 1 RETVAL = sv_2mortal(RETVAL);
546 1 ST(0) = RETVAL;
547 }
548 1 XSRETURN(1);
549 }
550  
551  
552 XS_EUPXS(XS_Hyperman_stats); /* prototype to pass -Wmissing-prototypes */
553 13 XS_EUPXS(XS_Hyperman_stats)
554 {
555 13 dVAR; dXSARGS;
556 PERL_UNUSED_VAR(cv); /* -W */
557 PERL_UNUSED_VAR(items); /* -W */
558 {
559 SV * RETVAL;
560 #line 335 "./xs/hyperman.xs"
561 {
562 int pool = 0, i;
563 for (i = 1; i + 1 < items; i += 2)
564 if (strEQ(SvPV_nolen(ST(i)), "pool")) pool = SvTRUE(ST(i + 1)) ? 1 : 0;
565 if (pool) {
566 hm_sa_pool_stats p;
567 if (!hm_sa_board_pool(&p)) RETVAL = &PL_sv_undef;
568 else {
569 HV *h = newHV();
570 hv_stores(h, "workers", newSVuv((UV)p.workers));
571 hv_stores(h, "alive", newSVuv((UV)p.alive));
572 hv_stores(h, "requests", newSVuv((UV)p.requests));
573 hv_stores(h, "accepts", newSVuv((UV)p.accepts));
574 hv_stores(h, "denied", newSVuv((UV)p.denied));
575 hv_stores(h, "connections", newSVuv((UV)p.conns));
576 hv_stores(h, "bytes_out", newSVuv((UV)p.bytes_out));
577 hv_stores(h, "datagrams", newSVuv((UV)p.datagrams));
578 hv_stores(h, "h3_requests", newSVuv((UV)p.h3));
579 RETVAL = newRV_noinc((SV *)h);
580 }
581 }
582 else if (!hm_cur_loop) {
583 RETVAL = &PL_sv_undef;
584 } else {
585 HV *h = newHV();
586 hv_stores(h, "requests", newSVuv(hm_cur_loop->requests));
587 hv_stores(h, "accepts", newSVuv(hm_cur_loop->accepts));
588 hv_stores(h, "denied", newSVuv(hm_cur_loop->denied));
589 hv_stores(h, "bytes_out", newSVuv(hm_cur_loop->bytes_out));
590 hv_stores(h, "datagrams", newSVuv(hm_cur_loop->datagrams));
591 hv_stores(h, "h3_conns", newSVuv(hm_cur_loop->h3_conns));
592 hv_stores(h, "h3_live", newSVuv(hm_cur_loop->h3_live));
593 hv_stores(h, "h3_requests", newSVuv(hm_cur_loop->h3_requests));
594 hv_stores(h, "datagrams_out", newSVuv(hm_cur_loop->datagrams_out));
595 hv_stores(h, "connections", newSViv(hm_cur_loop->nconns));
596 hv_stores(h, "backend", newSVpv(hm_cur_loop->be->name, 0));
597 hv_stores(h, "pid", newSViv((IV)hm_os_getpid()));
598 RETVAL = newRV_noinc((SV *)h);
599 }
600 }
601 #line 602 "Hyperman.c"
602 13 RETVAL = sv_2mortal(RETVAL);
603 13 ST(0) = RETVAL;
604 }
605 13 XSRETURN(1);
606 }
607  
608  
609 XS_EUPXS(XS_Hyperman_has_http2); /* prototype to pass -Wmissing-prototypes */
610 11 XS_EUPXS(XS_Hyperman_has_http2)
611 {
612 11 dVAR; dXSARGS;
613 PERL_UNUSED_VAR(cv); /* -W */
614 PERL_UNUSED_VAR(items); /* -W */
615 {
616 int RETVAL;
617 11 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 11 0 11
618 #line 384 "./xs/hyperman.xs"
619 PERL_UNUSED_VAR(items);
620 RETVAL = hm_h2_available();
621 #line 622 "Hyperman.c"
622 11 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 11 11
623 11 ST(0) = TARG;
624 }
625 11 XSRETURN(1);
626 }
627  
628  
629 XS_EUPXS(XS_Hyperman_has_http3); /* prototype to pass -Wmissing-prototypes */
630 9 XS_EUPXS(XS_Hyperman_has_http3)
631 {
632 9 dVAR; dXSARGS;
633 PERL_UNUSED_VAR(cv); /* -W */
634 PERL_UNUSED_VAR(items); /* -W */
635 {
636 int RETVAL;
637 9 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 9 0 9
638 #line 396 "./xs/hyperman.xs"
639 PERL_UNUSED_VAR(items);
640 RETVAL = hm_h3_available();
641 #line 642 "Hyperman.c"
642 9 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 9 9
643 9 ST(0) = TARG;
644 }
645 9 XSRETURN(1);
646 }
647  
648  
649 XS_EUPXS(XS_Hyperman_quic_library); /* prototype to pass -Wmissing-prototypes */
650 1 XS_EUPXS(XS_Hyperman_quic_library)
651 {
652 1 dVAR; dXSARGS;
653 PERL_UNUSED_VAR(cv); /* -W */
654 PERL_UNUSED_VAR(items); /* -W */
655 {
656 #line 407 "./xs/hyperman.xs"
657 const char *s;
658 #line 659 "Hyperman.c"
659 SV * RETVAL;
660 #line 409 "./xs/hyperman.xs"
661 PERL_UNUSED_VAR(items);
662 s = hm_quic_library();
663 RETVAL = s ? newSVpv(s, 0) : newSV(0); /* # uncoverable condition left count:1 class:ignore_covered_err */
664 #line 665 "Hyperman.c"
665 1 RETVAL = sv_2mortal(RETVAL);
666 1 ST(0) = RETVAL;
667 }
668 1 XSRETURN(1);
669 }
670  
671  
672 XS_EUPXS(XS_Hyperman__accepts_gzip); /* prototype to pass -Wmissing-prototypes */
673 30 XS_EUPXS(XS_Hyperman__accepts_gzip)
674 {
675 30 dVAR; dXSARGS;
676 30 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 30 30
677 0 croak_xs_usage(cv, "hdr");
678 {
679 30 SV * hdr = ST(0)
680 ;
681 int RETVAL;
682 30 ▶ dXSTARG;
Branch: 2 branches
BranchTrueFalseTotal
dXSTARG; 30 0 30
dXSTARG; 29 1 30
683 #line 421 "./xs/hyperman.xs"
684 {
685 STRLEN l = 0;
686 const char *h = SvOK(hdr) ? SvPV_const(hdr, l) : NULL;
687 RETVAL = hz_accepts_gzip(h, (size_t)l);
688 }
689 #line 690 "Hyperman.c"
690 30 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 28 2 30
691 30 ST(0) = TARG;
692 }
693 30 XSRETURN(1);
694 }
695  
696  
697 XS_EUPXS(XS_Hyperman__gzip); /* prototype to pass -Wmissing-prototypes */
698 3 XS_EUPXS(XS_Hyperman__gzip)
699 {
700 3 dVAR; dXSARGS;
701 3 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 3 3
702 0 croak_xs_usage(cv, "bytes");
703 {
704 3 ▶ SV * bytes = ST(0)
Branch: 1 branch
BranchTrueFalseTotal
SV * bytes = ST(0) 2 1 3
705 ;
706 SV * RETVAL;
707 #line 436 "./xs/hyperman.xs"
708 {
709 STRLEN l = 0;
710 const char *b = SvOK(bytes) ? SvPV_const(bytes, l) : NULL;
711 char *out = NULL;
712 size_t ol = 0;
713 if (b && hz_gzip(b, (size_t)l, HZ_LEVEL, &out, &ol)) {
714 RETVAL = newSVpvn(out, ol);
715 Safefree(out);
716 } else {
717 RETVAL = newSV(0);
718 }
719 }
720 #line 721 "Hyperman.c"
721 3 RETVAL = sv_2mortal(RETVAL);
722 3 ST(0) = RETVAL;
723 }
724 3 XSRETURN(1);
725 }
726  
727  
728 XS_EUPXS(XS_Hyperman_has_compression); /* prototype to pass -Wmissing-prototypes */
729 3 XS_EUPXS(XS_Hyperman_has_compression)
730 {
731 3 dVAR; dXSARGS;
732 PERL_UNUSED_VAR(cv); /* -W */
733 PERL_UNUSED_VAR(items); /* -W */
734 {
735 int RETVAL;
736 3 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 3 0 3
737 #line 457 "./xs/hyperman.xs"
738 PERL_UNUSED_VAR(items);
739 RETVAL = hz_available();
740 #line 741 "Hyperman.c"
741 3 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 3 3
742 3 ST(0) = TARG;
743 }
744 3 XSRETURN(1);
745 }
746  
747  
748 XS_EUPXS(XS_Hyperman_has_tls); /* prototype to pass -Wmissing-prototypes */
749 17 XS_EUPXS(XS_Hyperman_has_tls)
750 {
751 17 dVAR; dXSARGS;
752 PERL_UNUSED_VAR(cv); /* -W */
753 PERL_UNUSED_VAR(items); /* -W */
754 {
755 int RETVAL;
756 17 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 17 0 17
757 #line 466 "./xs/hyperman.xs"
758 PERL_UNUSED_VAR(items);
759 RETVAL = hm_tls_available();
760 #line 761 "Hyperman.c"
761 17 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 17 17
762 17 ST(0) = TARG;
763 }
764 17 XSRETURN(1);
765 }
766  
767  
768 XS_EUPXS(XS_Hyperman_has_ktls); /* prototype to pass -Wmissing-prototypes */
769 2 XS_EUPXS(XS_Hyperman_has_ktls)
770 {
771 2 dVAR; dXSARGS;
772 PERL_UNUSED_VAR(cv); /* -W */
773 PERL_UNUSED_VAR(items); /* -W */
774 {
775 int RETVAL;
776 2 ▶ dXSTARG;
Branch: 2 branches
BranchTrueFalseTotal
dXSTARG; 2 0 2
dXSTARG; 0 2 2
777 #line 478 "./xs/hyperman.xs"
778 PERL_UNUSED_VAR(items);
779 #ifdef HM_HAVE_KTLS
780 RETVAL = 1;
781 #else
782 RETVAL = 0;
783 #endif
784 #line 785 "Hyperman.c"
785 2 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 2 2
786 2 ST(0) = TARG;
787 }
788 2 XSRETURN(1);
789 }
790  
791  
792 XS_EUPXS(XS_Hyperman_tls_library); /* prototype to pass -Wmissing-prototypes */
793 1 XS_EUPXS(XS_Hyperman_tls_library)
794 {
795 1 dVAR; dXSARGS;
796 PERL_UNUSED_VAR(cv); /* -W */
797 PERL_UNUSED_VAR(items); /* -W */
798 {
799 #line 494 "./xs/hyperman.xs"
800 const char *s;
801 #line 802 "Hyperman.c"
802 SV * RETVAL;
803 #line 496 "./xs/hyperman.xs"
804 PERL_UNUSED_VAR(items);
805 s = hm_tls_library();
806 RETVAL = s ? newSVpv(s, 0) : newSV(0); /* # uncoverable condition right count:1 class:ignore_covered_err */
807 #line 808 "Hyperman.c"
808 1 RETVAL = sv_2mortal(RETVAL);
809 1 ST(0) = RETVAL;
810 }
811 1 XSRETURN(1);
812 }
813  
814  
815 XS_EUPXS(XS_Hyperman_tls_reload); /* prototype to pass -Wmissing-prototypes */
816 3 XS_EUPXS(XS_Hyperman_tls_reload)
817 {
818 3 dVAR; dXSARGS;
819 3 ▶ if (items < 1 || items > 2)
Branch: 2 branches
BranchTrueFalseTotal
if (items < 1 || items > 2) 3 0 3
if (items < 1 || items > 2) 0 3 3
820 0 croak_xs_usage(cv, "class, sni = &PL_sv_undef");
821 {
822 3 SV * class = ST(0)
823 ;
824 SV * sni;
825 int RETVAL;
826 3 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 3 0 3
827  
828 3 ▶ if (items < 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) 0 3 3
829 0 sni = &PL_sv_undef;
830 else {
831 3 sni = ST(1)
832 ;
833 }
834 #line 522 "./xs/hyperman.xs"
835 PERL_UNUSED_VAR(class);
836 RETVAL = hm_cur_loop ? hm_tls_reload(aTHX_ hm_cur_loop, sni) : 0;
837 #line 838 "Hyperman.c"
838 3 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 3 3
839 3 ST(0) = TARG;
840 }
841 3 XSRETURN(1);
842 }
843  
844  
845 XS_EUPXS(XS_Hyperman_loop); /* prototype to pass -Wmissing-prototypes */
846 8 XS_EUPXS(XS_Hyperman_loop)
847 {
848 8 ▶ dVAR; dXSARGS;
Branch: 1 branch
BranchTrueFalseTotal
dVAR; dXSARGS; 7 1 8
849 PERL_UNUSED_VAR(cv); /* -W */
850 PERL_UNUSED_VAR(items); /* -W */
851 {
852 SV * RETVAL;
853 #line 533 "./xs/hyperman.xs"
854 PERL_UNUSED_VAR(items);
855 if (hm_cur_loop) RETVAL = hm_loop_to_sv(aTHX_ hm_cur_loop);
856 else RETVAL = &PL_sv_undef;
857 #line 858 "Hyperman.c"
858 8 RETVAL = sv_2mortal(RETVAL);
859 8 ST(0) = RETVAL;
860 }
861 8 XSRETURN(1);
862 }
863  
864  
865 XS_EUPXS(XS_Hyperman_detach); /* prototype to pass -Wmissing-prototypes */
866 13 XS_EUPXS(XS_Hyperman_detach)
867 {
868 13 dVAR; dXSARGS;
869 13 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 13 13
870 0 croak_xs_usage(cv, "env");
871 {
872 13 SV * env = ST(0)
873 ;
874 IV RETVAL;
875 13 ▶ dXSTARG;
Branch: 2 branches
BranchTrueFalseTotal
dXSTARG; 13 0 13
dXSTARG; 1 12 13
876 #line 547 "./xs/hyperman.xs"
877 {
878 HV *ehv;
879 SV **e;
880 AV *cid;
881 SV **fsv, **isv;
882 int fd, rc;
883 UV id;
884 if (!hm_cur_loop)
885 croak("Hyperman::detach: no running loop (call it from inside "
886 "a request)");
887 if (!SvROK(env) || SvTYPE(SvRV(env)) != SVt_PVHV) /* # uncoverable condition left count:2 class:ignore_covered_err */
888 croak("Hyperman::detach: give it the PSGI env hashref");
889 ehv = (HV *)SvRV(env);
890 e = hv_fetchs(ehv, "psgix.hyperman.conn", 0);
891 if (!(e && *e && SvROK(*e) && SvTYPE(SvRV(*e)) == SVt_PVAV))
892 croak("Hyperman::detach: no psgix.hyperman.conn in this env "
893 "(HTTP/2 and HTTP/3 streams share one connection, and "
894 "non-Hyperman servers have none, so none can detach)");
895 cid = (AV *)SvRV(*e);
896 fsv = av_fetch(cid, 0, 0);
897 isv = av_fetch(cid, 1, 0);
898 if (!(fsv && *fsv && isv && *isv))
899 croak("Hyperman::detach: malformed psgix.hyperman.conn");
900 fd = (int)SvIV(*fsv);
901 id = SvUV(*isv);
902 rc = hm_detach(aTHX_ hm_cur_loop, fd, id);
903 switch (rc) {
904 case 0: break;
905 case -1: croak("Hyperman::detach: the connection is gone "
906 "(the client hung up, or this env is stale)");
907 case -2: croak("Hyperman::detach: HTTP/2 connections cannot be " /* # uncoverable statement */
908 "detached (streams share one socket)");
909 case -3: croak("Hyperman::detach: TLS connections cannot be "
910 "detached (terminate TLS in front of Hyperman)");
911 case -4: croak("Hyperman::detach: a response is still draining "
912 "on this connection");
913 case -5: croak("Hyperman::detach: already detached");
914 case -6: croak("Hyperman::detach: not supported on this " /* # uncoverable statement */
915 "platform (it needs fork-style fd ownership)");
916 default: croak("Hyperman::detach: failed (%d)", rc); /* # uncoverable statement */
917 }
918 RETVAL = (IV)fd;
919 }
920 #line 921 "Hyperman.c"
921 4 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 1 3 4
922 4 ST(0) = TARG;
923 }
924 4 XSRETURN(1);
925 }
926  
927  
928 XS_EUPXS(XS_Hyperman_stream); /* prototype to pass -Wmissing-prototypes */
929 10 XS_EUPXS(XS_Hyperman_stream)
930 {
931 10 dVAR; dXSARGS;
932 10 ▶ if (items < 1 || items > 3)
Branch: 2 branches
BranchTrueFalseTotal
if (items < 1 || items > 3) 10 0 10
if (items < 1 || items > 3) 0 10 10
933 0 croak_xs_usage(cv, "env, status = 200, headers = NULL");
934 {
935 10 SV * env = ST(0)
936 ;
937 int status;
938 SV * headers;
939 SV * RETVAL;
940  
941 10 ▶ if (items < 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) 2 8 10
942 2 status = 200;
943 else {
944 8 status = (int)SvIV(ST(1))
945 ;
946 }
947  
948 10 ▶ if (items < 3)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 3) 2 8 10
949 2 headers = NULL;
950 else {
951 8 headers = ST(2)
952 ;
953 }
954 #line 619 "./xs/hyperman.xs"
955 {
956 AV *w;
957 void *h;
958 int fd;
959 UV id;
960 int64_t sid = -1;
961 if (!hm_cur_loop)
962 croak("Hyperman::stream: no running loop (call it from inside "
963 "a request)");
964 if (!SvROK(env) || SvTYPE(SvRV(env)) != SVt_PVHV) /* # uncoverable condition left count:2 class:ignore_covered_err */
965 croak("Hyperman::stream: give it the PSGI env hashref");
966 if (!hm_stream_ticket(aTHX_ env, &fd, &id, &sid))
967 croak("Hyperman::stream: no usable psgix.hyperman.stream in this "
968 "env (not a Hyperman request, or the env is stale)");
969 if (headers && !SvOK(headers)) headers = NULL;
970 if (headers && !(SvROK(headers)
971 && SvTYPE(SvRV(headers)) == SVt_PVAV))
972 croak("Hyperman::stream: headers must be an array reference");
973 h = hm_stream_open(aTHX_ (void *)hm_cur_loop, fd, id, sid,
974 status, headers);
975 if (!h)
976 croak("Hyperman::stream: cannot stream on this request (the "
977 "client is gone, a response was already sent, or the "
978 "handler has not deferred - open a stream from a "
979 "psgi.streaming coderef or after parking on a Future)");
980 w = newAV();
981 av_extend(w, 2);
982 av_store(w, 0, newSViv(PTR2IV(h)));
983 av_store(w, 1, newSVuv(((hm_stream *)h)->serial));
984 av_store(w, 2, newSVpvs("stream"));
985 RETVAL = newRV_noinc((SV *)w);
986 sv_bless(RETVAL, gv_stashpv("Hyperman::Writer", GV_ADD));
987 }
988 #line 989 "Hyperman.c"
989 5 RETVAL = sv_2mortal(RETVAL);
990 5 ST(0) = RETVAL;
991 }
992 5 XSRETURN(1);
993 }
994  
995  
996 XS_EUPXS(XS_Hyperman_deny_add); /* prototype to pass -Wmissing-prototypes */
997 29 XS_EUPXS(XS_Hyperman_deny_add)
998 {
999 29 dVAR; dXSARGS;
1000 29 ▶ if (items < 2 || items > 3)
Branch: 2 branches
BranchTrueFalseTotal
if (items < 2 || items > 3) 29 0 29
if (items < 2 || items > 3) 0 29 29
1001 0 croak_xs_usage(cv, "class, ip, ttl = 0");
1002 {
1003 29 SV * class = ST(0)
1004 ;
1005 29 SV * ip = ST(1)
1006 ;
1007 IV ttl;
1008  
1009 29 ▶ if (items < 3)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 3) 0 29 29
1010 0 ttl = 0;
1011 else {
1012 29 ttl = (IV)SvIV(ST(2))
1013 ;
1014 }
1015 #line 684 "./xs/hyperman.xs"
1016 PERL_UNUSED_VAR(class);
1017 if (SvOK(ip)) hm_sa_deny_add(SvPV_nolen(ip), (long)ttl);
1018 #line 1019 "Hyperman.c"
1019 }
1020 29 XSRETURN_EMPTY;
1021 }
1022  
1023  
1024 XS_EUPXS(XS_Hyperman_deny_remove); /* prototype to pass -Wmissing-prototypes */
1025 3 XS_EUPXS(XS_Hyperman_deny_remove)
1026 {
1027 3 dVAR; dXSARGS;
1028 3 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 3 3
1029 0 croak_xs_usage(cv, "class, ip");
1030 {
1031 3 SV * class = ST(0)
1032 ;
1033 3 ▶ SV * ip = ST(1)
Branch: 1 branch
BranchTrueFalseTotal
SV * ip = ST(1) 3 0 3
1034 ;
1035 #line 695 "./xs/hyperman.xs"
1036 PERL_UNUSED_VAR(class);
1037 if (SvOK(ip)) hm_sa_deny_remove(SvPV_nolen(ip));
1038 #line 1039 "Hyperman.c"
1039 }
1040 3 XSRETURN_EMPTY;
1041 }
1042  
1043  
1044 XS_EUPXS(XS_Hyperman_pool_stats); /* prototype to pass -Wmissing-prototypes */
1045 5 XS_EUPXS(XS_Hyperman_pool_stats)
1046 {
1047 5 dVAR; dXSARGS;
1048 5 ▶ if (items < 0 || items > 1)
Branch: 2 branches
BranchTrueFalseTotal
if (items < 0 || items > 1) 5 0 5
if (items < 0 || items > 1) 0 5 5
1049 0 croak_xs_usage(cv, "class = &PL_sv_undef");
1050 PERL_UNUSED_VAR(ax); /* -Wall */
1051 5 SP -= items;
1052 {
1053 SV * class;
1054  
1055 5 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 5 5
1056 0 class = &PL_sv_undef;
1057 else {
1058 5 class = ST(0)
1059 ;
1060 }
1061 #line 709 "./xs/hyperman.xs"
1062 {
1063 uint64_t i, n = hm_sa_board_slots();
1064 PERL_UNUSED_VAR(class);
1065 for (i = 0; i < n; i++) {
1066 sa_sb_reading rd;
1067 HV *h;
1068 if (!hm_sa_board_read((uint32_t)i, &rd)) continue;
1069 h = newHV();
1070 hv_stores(h, "pid", newSVuv((UV)rd.pid));
1071 hv_stores(h, "alive", newSViv(rd.alive ? 1 : 0));
1072 hv_stores(h, "updated", newSVuv((UV)rd.updated));
1073 hv_stores(h, "status", newSVpvn(rd.status, rd.statuslen));
1074 hv_stores(h, "requests", newSVuv((UV)rd.gauges[HM_SB_REQUESTS]));
1075 hv_stores(h, "accepts", newSVuv((UV)rd.gauges[HM_SB_ACCEPTS]));
1076 hv_stores(h, "denied", newSVuv((UV)rd.gauges[HM_SB_DENIED]));
1077 hv_stores(h, "connections", newSVuv((UV)rd.gauges[HM_SB_CONNS]));
1078 hv_stores(h, "bytes_out", newSVuv((UV)rd.gauges[HM_SB_BYTES_OUT]));
1079 hv_stores(h, "datagrams", newSVuv((UV)rd.gauges[HM_SB_DATAGRAMS]));
1080 hv_stores(h, "h3_requests", newSVuv((UV)rd.gauges[HM_SB_H3]));
1081 XPUSHs(sv_2mortal(newRV_noinc((SV *)h)));
1082 }
1083 }
1084 #line 1085 "Hyperman.c"
1085 5 PUTBACK;
1086 5 return;
1087 }
1088 }
1089  
1090  
1091 XS_EUPXS(XS_Hyperman_leader); /* prototype to pass -Wmissing-prototypes */
1092 5 XS_EUPXS(XS_Hyperman_leader)
1093 {
1094 5 dVAR; dXSARGS;
1095 5 ▶ if (items < 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) 0 5 5
1096 0 croak_xs_usage(cv, "class, name, ...");
1097 {
1098 5 SV * class = ST(0)
1099 ;
1100 5 ▶ SV * name = ST(1)
Branch: 1 branch
BranchTrueFalseTotal
SV * name = ST(1) 3 2 5
1101 ;
1102 SV * RETVAL;
1103 #line 742 "./xs/hyperman.xs"
1104 {
1105 int i, count;
1106 SV *ret = NULL;
1107 PERL_UNUSED_VAR(class);
1108 if (!hm_sa_arena_sv) XSRETURN_UNDEF;
1109 {
1110 dSP;
1111 ENTER; SAVETMPS;
1112 PUSHMARK(SP);
1113 EXTEND(SP, items + 1);
1114 PUSHs(hm_sa_arena_sv);
1115 PUSHs(name);
1116 for (i = 2; i < items; i++) PUSHs(ST(i));
1117 PUTBACK;
1118 count = call_method("lease", G_SCALAR);
1119 SPAGAIN;
1120 if (count == 1) ret = newSVsv(POPs);
1121 PUTBACK;
1122 FREETMPS; LEAVE;
1123 }
1124 if (!ret) XSRETURN_UNDEF;
1125 RETVAL = ret;
1126 }
1127 #line 1128 "Hyperman.c"
1128 2 RETVAL = sv_2mortal(RETVAL);
1129 2 ST(0) = RETVAL;
1130 }
1131 2 XSRETURN(1);
1132 }
1133  
1134  
1135 XS_EUPXS(XS_Hyperman_distinct_clients); /* prototype to pass -Wmissing-prototypes */
1136 206 XS_EUPXS(XS_Hyperman_distinct_clients)
1137 {
1138 206 dVAR; dXSARGS;
1139 206 ▶ if (items < 0 || items > 1)
Branch: 2 branches
BranchTrueFalseTotal
if (items < 0 || items > 1) 206 0 206
if (items < 0 || items > 1) 0 206 206
1140 0 croak_xs_usage(cv, "class = &PL_sv_undef");
1141 PERL_UNUSED_VAR(ax); /* -Wall */
1142 206 SP -= items;
1143 {
1144 SV * class;
1145  
1146 206 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 206 206
1147 0 class = &PL_sv_undef;
1148 else {
1149 206 class = ST(0)
1150 ;
1151 }
1152 #line 778 "./xs/hyperman.xs"
1153 {
1154 double c = hm_sa_hll_count();
1155 PERL_UNUSED_VAR(class);
1156 if (c < 0.0) XSRETURN_EMPTY;
1157 EXTEND(SP, 2);
1158 mPUSHn(c);
1159 mPUSHn(1.04 / 128.0); /* 1.04 / sqrt(2^14) */
1160 }
1161 #line 1162 "Hyperman.c"
1162 201 PUTBACK;
1163 201 return;
1164 }
1165 }
1166  
1167  
1168 XS_EUPXS(XS_Hyperman_arena); /* prototype to pass -Wmissing-prototypes */
1169 20 XS_EUPXS(XS_Hyperman_arena)
1170 {
1171 20 dVAR; dXSARGS;
1172 20 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 20 20
1173 0 croak_xs_usage(cv, "class");
1174 {
1175 20 ▶ SV * class = ST(0)
Branch: 1 branch
BranchTrueFalseTotal
SV * class = ST(0) 14 6 20
1176 ;
1177 SV * RETVAL;
1178 #line 796 "./xs/hyperman.xs"
1179 PERL_UNUSED_VAR(class);
1180 RETVAL = hm_sa_arena_sv ? newSVsv(hm_sa_arena_sv) : newSV(0);
1181 #line 1182 "Hyperman.c"
1182 20 RETVAL = sv_2mortal(RETVAL);
1183 20 ST(0) = RETVAL;
1184 }
1185 20 XSRETURN(1);
1186 }
1187  
1188  
1189 XS_EUPXS(XS_Hyperman_deny_check); /* prototype to pass -Wmissing-prototypes */
1190 33 XS_EUPXS(XS_Hyperman_deny_check)
1191 {
1192 33 dVAR; dXSARGS;
1193 33 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 33 33
1194 0 croak_xs_usage(cv, "class, ip");
1195 {
1196 33 SV * class = ST(0)
1197 ;
1198 33 SV * ip = ST(1)
1199 ;
1200 IV RETVAL;
1201 33 ▶ dXSTARG;
Branch: 2 branches
BranchTrueFalseTotal
dXSTARG; 33 0 33
dXSTARG; 33 0 33
1202 #line 807 "./xs/hyperman.xs"
1203 PERL_UNUSED_VAR(class);
1204 RETVAL = SvOK(ip) ? hm_sa_deny_check(SvPV_nolen(ip)) : 0; /* # uncoverable condition right count:1 class:ignore_covered_err */
1205 #line 1206 "Hyperman.c"
1206 33 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 23 10 33
1207 33 ST(0) = TARG;
1208 }
1209 33 XSRETURN(1);
1210 }
1211  
1212  
1213 XS_EUPXS(XS_Hyperman_ratelimit_hit); /* prototype to pass -Wmissing-prototypes */
1214 11 XS_EUPXS(XS_Hyperman_ratelimit_hit)
1215 {
1216 11 dVAR; dXSARGS;
1217 11 ▶ if (items < 3 || items > 4)
Branch: 2 branches
BranchTrueFalseTotal
if (items < 3 || items > 4) 11 0 11
if (items < 3 || items > 4) 0 11 11
1218 0 croak_xs_usage(cv, "class, key, limit, window = 60");
1219 PERL_UNUSED_VAR(ax); /* -Wall */
1220 11 SP -= items;
1221 {
1222 11 SV * class = ST(0)
1223 ;
1224 11 SV * key = ST(1)
1225 ;
1226 11 IV limit = (IV)SvIV(ST(2))
1227 ;
1228 IV window;
1229  
1230 11 ▶ if (items < 4)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 4) 0 11 11
1231 0 window = 60;
1232 else {
1233 11 window = (IV)SvIV(ST(3))
1234 ;
1235 }
1236 #line 824 "./xs/hyperman.xs"
1237 {
1238 STRLEN klen;
1239 const char *kp = SvOK(key) ? SvPV_const(key, klen) : ""; /* # uncoverable condition right count:1 class:ignore_covered_err */
1240 long rem = 0, reset = 0;
1241 int ok;
1242 PERL_UNUSED_VAR(class);
1243 if (!SvOK(key)) klen = 0;
1244 ok = hm_sa_ratelimit_hit(kp, (size_t)klen, (long)limit, (long)window,
1245 &rem, &reset);
1246 EXTEND(SP, 3);
1247 mPUSHi(ok);
1248 mPUSHi(rem);
1249 mPUSHi(reset);
1250 }
1251 #line 1252 "Hyperman.c"
1252 11 PUTBACK;
1253 11 return;
1254 }
1255 }
1256  
1257  
1258 XS_EUPXS(XS_Hyperman_on_worker_start); /* prototype to pass -Wmissing-prototypes */
1259 6 XS_EUPXS(XS_Hyperman_on_worker_start)
1260 {
1261 6 dVAR; dXSARGS;
1262 6 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 6 6
1263 0 croak_xs_usage(cv, "class, cb");
1264 {
1265 6 SV * class = ST(0)
1266 ;
1267 6 SV * cb = ST(1)
1268 ;
1269 IV RETVAL;
1270 6 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 6 0 6
1271 #line 851 "./xs/hyperman.xs"
1272 PERL_UNUSED_VAR(class);
1273 RETVAL = hm_worker_hook_add_perl(aTHX_ cb);
1274 #line 1275 "Hyperman.c"
1275 4 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 4 4
1276 4 ST(0) = TARG;
1277 }
1278 4 XSRETURN(1);
1279 }
1280  
1281  
1282 XS_EUPXS(XS_Hyperman__proxy_selftest); /* prototype to pass -Wmissing-prototypes */
1283 2 XS_EUPXS(XS_Hyperman__proxy_selftest)
1284 {
1285 2 dVAR; dXSARGS;
1286 2 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 2 2
1287 0 croak_xs_usage(cv, "class");
1288 {
1289 2 SV * class = ST(0)
1290 ;
1291 IV RETVAL;
1292 2 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 2 0 2
1293 #line 864 "./xs/hyperman.xs"
1294 PERL_UNUSED_VAR(class);
1295 RETVAL = hm_proxy_selftest();
1296 #line 1297 "Hyperman.c"
1297 2 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 2 2
1298 2 ST(0) = TARG;
1299 }
1300 2 XSRETURN(1);
1301 }
1302  
1303  
1304 XS_EUPXS(XS_Hyperman__croak_sv_selftest); /* prototype to pass -Wmissing-prototypes */
1305 4 XS_EUPXS(XS_Hyperman__croak_sv_selftest)
1306 {
1307 4 dVAR; dXSARGS;
1308 4 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 4 4
1309 0 croak_xs_usage(cv, "class, sv");
1310 {
1311 4 SV * class = ST(0)
1312 ;
1313 4 SV * sv = ST(1)
1314 ;
1315 #line 884 "./xs/hyperman.xs"
1316 PERL_UNUSED_VAR(class);
1317 hm_croak_sv(aTHX_ sv);
1318 #line 1319 "Hyperman.c"
1319 }
1320 0 XSRETURN_EMPTY;
1321 }
1322  
1323  
1324 /* INCLUDE: Returning to 'Hyperman.xs' from 'xs/hyperman.xs' */
1325  
1326  
1327 /* INCLUDE: Including 'xs/future.xs' from 'Hyperman.xs' */
1328  
1329  
1330 XS_EUPXS(XS_Hyperman__Future_new); /* prototype to pass -Wmissing-prototypes */
1331 87 XS_EUPXS(XS_Hyperman__Future_new)
1332 {
1333 87 dVAR; dXSARGS;
1334 87 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 87 87
1335 0 croak_xs_usage(cv, "class");
1336 {
1337 87 ▶ SV * class = ST(0)
Branch: 1 branch
BranchTrueFalseTotal
SV * class = ST(0) 1 86 87
1338 ;
1339 SV * RETVAL;
1340 #line 16 "./xs/future.xs"
1341 {
1342 const char *name;
1343 if (SvROK(class) && SvOBJECT(SvRV(class))) /* # uncoverable condition right count:2 class:ignore_covered_err */
1344 name = HvNAME(SvSTASH(SvRV(class)));
1345 else
1346 name = SvPV_nolen(class);
1347 RETVAL = hmf_new(aTHX_ name);
1348 }
1349 #line 1350 "Hyperman.c"
1350 87 RETVAL = sv_2mortal(RETVAL);
1351 87 ST(0) = RETVAL;
1352 }
1353 87 XSRETURN(1);
1354 }
1355  
1356  
1357 XS_EUPXS(XS_Hyperman__Future_done); /* prototype to pass -Wmissing-prototypes */
1358 48 XS_EUPXS(XS_Hyperman__Future_done)
1359 {
1360 48 dVAR; dXSARGS;
1361 48 dXSI32;
1362 48 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 48 48
1363 0 croak_xs_usage(cv, "self, ...");
1364 {
1365 48 SV * self = ST(0)
1366 ;
1367 SV * RETVAL;
1368 #line 33 "./xs/future.xs"
1369 PERL_UNUSED_VAR(ix);
1370 if (hmf_state(aTHX_ self) == HMF_PENDING)
1371 hmf_settle(aTHX_ self, HMF_DONE, &ST(1), items - 1);
1372 RETVAL = SvREFCNT_inc(self);
1373 #line 1374 "Hyperman.c"
1374 46 RETVAL = sv_2mortal(RETVAL);
1375 46 ST(0) = RETVAL;
1376 }
1377 46 XSRETURN(1);
1378 }
1379  
1380  
1381 XS_EUPXS(XS_Hyperman__Future_fail); /* prototype to pass -Wmissing-prototypes */
1382 14 XS_EUPXS(XS_Hyperman__Future_fail)
1383 {
1384 14 dVAR; dXSARGS;
1385 14 dXSI32;
1386 14 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 14 14
1387 0 croak_xs_usage(cv, "self, ...");
1388 {
1389 14 SV * self = ST(0)
1390 ;
1391 SV * RETVAL;
1392 #line 46 "./xs/future.xs"
1393 PERL_UNUSED_VAR(ix);
1394 if (hmf_state(aTHX_ self) == HMF_PENDING) {
1395 if (items > 1) {
1396 hmf_settle(aTHX_ self, HMF_FAILED, &ST(1), items - 1);
1397 } else {
1398 SV *def = sv_2mortal(newSVpvs("Failed\n"));
1399 hmf_settle(aTHX_ self, HMF_FAILED, &def, 1);
1400 }
1401 }
1402 RETVAL = SvREFCNT_inc(self);
1403 #line 1404 "Hyperman.c"
1404 14 RETVAL = sv_2mortal(RETVAL);
1405 14 ST(0) = RETVAL;
1406 }
1407 14 XSRETURN(1);
1408 }
1409  
1410  
1411 XS_EUPXS(XS_Hyperman__Future_done_future); /* prototype to pass -Wmissing-prototypes */
1412 10 XS_EUPXS(XS_Hyperman__Future_done_future)
1413 {
1414 10 dVAR; dXSARGS;
1415 10 dXSI32;
1416 10 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 10 10
1417 0 croak_xs_usage(cv, "class, ...");
1418 {
1419 10 ▶ SV * class = ST(0)
Branch: 1 branch
BranchTrueFalseTotal
SV * class = ST(0) 0 10 10
1420 ;
1421 SV * RETVAL;
1422 #line 67 "./xs/future.xs"
1423 {
1424 const char *name = (SvROK(class) && SvOBJECT(SvRV(class))) ? HvNAME(SvSTASH(SvRV(class))) /* # uncoverable statement class:ignore_covered_err */
1425 : SvPV_nolen(class);
1426 PERL_UNUSED_VAR(ix);
1427 RETVAL = hmf_new(aTHX_ name);
1428 hmf_settle(aTHX_ RETVAL, HMF_DONE, &ST(1), items - 1);
1429 }
1430 #line 1431 "Hyperman.c"
1431 10 RETVAL = sv_2mortal(RETVAL);
1432 10 ST(0) = RETVAL;
1433 }
1434 10 XSRETURN(1);
1435 }
1436  
1437  
1438 XS_EUPXS(XS_Hyperman__Future_fail_future); /* prototype to pass -Wmissing-prototypes */
1439 4 XS_EUPXS(XS_Hyperman__Future_fail_future)
1440 {
1441 4 dVAR; dXSARGS;
1442 4 dXSI32;
1443 4 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 4 4
1444 0 croak_xs_usage(cv, "class, ...");
1445 {
1446 4 ▶ SV * class = ST(0)
Branch: 1 branch
BranchTrueFalseTotal
SV * class = ST(0) 0 4 4
1447 ;
1448 SV * RETVAL;
1449 #line 83 "./xs/future.xs"
1450 {
1451 const char *name = (SvROK(class) && SvOBJECT(SvRV(class))) ? HvNAME(SvSTASH(SvRV(class))) /* # uncoverable statement class:ignore_covered_err */
1452 : SvPV_nolen(class);
1453 PERL_UNUSED_VAR(ix);
1454 RETVAL = hmf_new(aTHX_ name);
1455 if (items > 1) {
1456 hmf_settle(aTHX_ RETVAL, HMF_FAILED, &ST(1), items - 1);
1457 } else {
1458 SV *def = sv_2mortal(newSVpvs("Failed\n"));
1459 hmf_settle(aTHX_ RETVAL, HMF_FAILED, &def, 1);
1460 }
1461 }
1462 #line 1463 "Hyperman.c"
1463 4 RETVAL = sv_2mortal(RETVAL);
1464 4 ST(0) = RETVAL;
1465 }
1466 4 XSRETURN(1);
1467 }
1468  
1469  
1470 XS_EUPXS(XS_Hyperman__Future_cancel); /* prototype to pass -Wmissing-prototypes */
1471 24 XS_EUPXS(XS_Hyperman__Future_cancel)
1472 {
1473 24 dVAR; dXSARGS;
1474 24 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 24 24
1475 0 croak_xs_usage(cv, "self");
1476 {
1477 24 SV * self = ST(0)
1478 ;
1479 SV * RETVAL;
1480 #line 102 "./xs/future.xs"
1481 hmf_cancel(aTHX_ self);
1482 RETVAL = SvREFCNT_inc(self);
1483 #line 1484 "Hyperman.c"
1484 24 RETVAL = sv_2mortal(RETVAL);
1485 24 ST(0) = RETVAL;
1486 }
1487 24 XSRETURN(1);
1488 }
1489  
1490  
1491 XS_EUPXS(XS_Hyperman__Future_is_ready); /* prototype to pass -Wmissing-prototypes */
1492 23 XS_EUPXS(XS_Hyperman__Future_is_ready)
1493 {
1494 23 dVAR; dXSARGS;
1495 23 dXSI32;
1496 23 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 23 23
1497 0 croak_xs_usage(cv, "self");
1498 {
1499 23 SV * self = ST(0)
1500 ;
1501 int RETVAL;
1502 23 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 23 0 23
1503 #line 113 "./xs/future.xs"
1504 PERL_UNUSED_VAR(ix);
1505 RETVAL = hmf_state(aTHX_ self) != HMF_PENDING;
1506 #line 1507 "Hyperman.c"
1507 23 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 1 22 23
1508 23 ST(0) = TARG;
1509 }
1510 23 XSRETURN(1);
1511 }
1512  
1513  
1514 XS_EUPXS(XS_Hyperman__Future_is_done); /* prototype to pass -Wmissing-prototypes */
1515 10 XS_EUPXS(XS_Hyperman__Future_is_done)
1516 {
1517 10 dVAR; dXSARGS;
1518 10 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 10 10
1519 0 croak_xs_usage(cv, "self");
1520 {
1521 10 SV * self = ST(0)
1522 ;
1523 int RETVAL;
1524 10 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 10 0 10
1525 #line 122 "./xs/future.xs"
1526 RETVAL = hmf_state(aTHX_ self) == HMF_DONE;
1527 #line 1528 "Hyperman.c"
1528 10 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 10 10
1529 10 ST(0) = TARG;
1530 }
1531 10 XSRETURN(1);
1532 }
1533  
1534  
1535 XS_EUPXS(XS_Hyperman__Future_is_failed); /* prototype to pass -Wmissing-prototypes */
1536 13 XS_EUPXS(XS_Hyperman__Future_is_failed)
1537 {
1538 13 dVAR; dXSARGS;
1539 13 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 13 13
1540 0 croak_xs_usage(cv, "self");
1541 {
1542 13 SV * self = ST(0)
1543 ;
1544 int RETVAL;
1545 13 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 13 0 13
1546 #line 130 "./xs/future.xs"
1547 RETVAL = hmf_state(aTHX_ self) == HMF_FAILED;
1548 #line 1549 "Hyperman.c"
1549 13 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 13 13
1550 13 ST(0) = TARG;
1551 }
1552 13 XSRETURN(1);
1553 }
1554  
1555  
1556 XS_EUPXS(XS_Hyperman__Future_is_cancelled); /* prototype to pass -Wmissing-prototypes */
1557 28 XS_EUPXS(XS_Hyperman__Future_is_cancelled)
1558 {
1559 28 dVAR; dXSARGS;
1560 28 dXSI32;
1561 28 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 28 28
1562 0 croak_xs_usage(cv, "self");
1563 {
1564 28 SV * self = ST(0)
1565 ;
1566 int RETVAL;
1567 28 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 28 0 28
1568 #line 140 "./xs/future.xs"
1569 PERL_UNUSED_VAR(ix);
1570 RETVAL = hmf_state(aTHX_ self) == HMF_CANCELLED;
1571 #line 1572 "Hyperman.c"
1572 28 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 28 28
1573 28 ST(0) = TARG;
1574 }
1575 28 XSRETURN(1);
1576 }
1577  
1578  
1579 XS_EUPXS(XS_Hyperman__Future_AWAIT_CLONE); /* prototype to pass -Wmissing-prototypes */
1580 1 XS_EUPXS(XS_Hyperman__Future_AWAIT_CLONE)
1581 {
1582 1 dVAR; dXSARGS;
1583 1 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 1 1
1584 0 croak_xs_usage(cv, "self");
1585 {
1586 1 SV * self = ST(0)
1587 ;
1588 SV * RETVAL;
1589 #line 151 "./xs/future.xs"
1590 RETVAL = hmf_new(aTHX_ hmf_class_of(aTHX_ self));
1591 #line 1592 "Hyperman.c"
1592 1 RETVAL = sv_2mortal(RETVAL);
1593 1 ST(0) = RETVAL;
1594 }
1595 1 XSRETURN(1);
1596 }
1597  
1598  
1599 XS_EUPXS(XS_Hyperman__Future_on_ready); /* prototype to pass -Wmissing-prototypes */
1600 9 XS_EUPXS(XS_Hyperman__Future_on_ready)
1601 {
1602 9 dVAR; dXSARGS;
1603 9 dXSI32;
1604 9 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 9 9
1605 0 croak_xs_usage(cv, "self, cb");
1606 {
1607 9 SV * self = ST(0)
1608 ;
1609 9 SV * cb = ST(1)
1610 ;
1611 SV * RETVAL;
1612 #line 162 "./xs/future.xs"
1613 PERL_UNUSED_VAR(ix);
1614 hmf_on_ready(aTHX_ self, cb);
1615 RETVAL = SvREFCNT_inc(self);
1616 #line 1617 "Hyperman.c"
1617 7 RETVAL = sv_2mortal(RETVAL);
1618 7 ST(0) = RETVAL;
1619 }
1620 7 XSRETURN(1);
1621 }
1622  
1623  
1624 XS_EUPXS(XS_Hyperman__Future_on_cancel); /* prototype to pass -Wmissing-prototypes */
1625 9 XS_EUPXS(XS_Hyperman__Future_on_cancel)
1626 {
1627 9 dVAR; dXSARGS;
1628 9 dXSI32;
1629 9 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 9 9
1630 0 croak_xs_usage(cv, "self, thing");
1631 {
1632 9 SV * self = ST(0)
1633 ;
1634 9 SV * thing = ST(1)
1635 ;
1636 SV * RETVAL;
1637 #line 180 "./xs/future.xs"
1638 {
1639 IV st = hmf_state(aTHX_ self);
1640 PERL_UNUSED_VAR(ix);
1641 if (st == HMF_CANCELLED) {
1642 hmf_cancel_target(aTHX_ thing, self);
1643 } else if (st == HMF_PENDING) {
1644 SV *cb = hm_closure(aTHX_ hm_xs_oncancel_cb, NULL, thing,
1645 NULL, NULL, 0, 0);
1646 hmf_on_ready(aTHX_ self, cb);
1647 SvREFCNT_dec(cb);
1648 }
1649 RETVAL = SvREFCNT_inc(self);
1650 }
1651 #line 1652 "Hyperman.c"
1652 9 RETVAL = sv_2mortal(RETVAL);
1653 9 ST(0) = RETVAL;
1654 }
1655 9 XSRETURN(1);
1656 }
1657  
1658  
1659 XS_EUPXS(XS_Hyperman__Future_on_done); /* prototype to pass -Wmissing-prototypes */
1660 2002 XS_EUPXS(XS_Hyperman__Future_on_done)
1661 {
1662 2002 dVAR; dXSARGS;
1663 2002 dXSI32;
1664 2002 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 2002 2002
1665 0 croak_xs_usage(cv, "self, usercb");
1666 {
1667 2002 SV * self = ST(0)
1668 ;
1669 2002 ▶ SV * usercb = ST(1)
Branch: 1 branch
BranchTrueFalseTotal
SV * usercb = ST(1) 2001 1 2002
1670 ;
1671 SV * RETVAL;
1672 #line 203 "./xs/future.xs"
1673 {
1674 SV *cb = hm_closure(aTHX_ hm_xs_ondone_cb, NULL, usercb, NULL, NULL,
1675 ix == 0 ? HMF_DONE : HMF_FAILED, 0);
1676 hmf_on_ready(aTHX_ self, cb);
1677 SvREFCNT_dec(cb);
1678 RETVAL = SvREFCNT_inc(self);
1679 }
1680 #line 1681 "Hyperman.c"
1681 2002 RETVAL = sv_2mortal(RETVAL);
1682 2002 ST(0) = RETVAL;
1683 }
1684 2002 XSRETURN(1);
1685 }
1686  
1687  
1688 XS_EUPXS(XS_Hyperman__Future_await); /* prototype to pass -Wmissing-prototypes */
1689 1 XS_EUPXS(XS_Hyperman__Future_await)
1690 {
1691 1 dVAR; dXSARGS;
1692 1 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 1 1
1693 0 croak_xs_usage(cv, "self");
1694 {
1695 1 SV * self = ST(0)
1696 ;
1697 SV * RETVAL;
1698 #line 217 "./xs/future.xs"
1699 hmf_await(aTHX_ self);
1700 RETVAL = SvREFCNT_inc(self);
1701 #line 1702 "Hyperman.c"
1702 1 RETVAL = sv_2mortal(RETVAL);
1703 1 ST(0) = RETVAL;
1704 }
1705 1 XSRETURN(1);
1706 }
1707  
1708  
1709 XS_EUPXS(XS_Hyperman__Future_get); /* prototype to pass -Wmissing-prototypes */
1710 46 XS_EUPXS(XS_Hyperman__Future_get)
1711 {
1712 46 dVAR; dXSARGS;
1713 46 dXSI32;
1714 46 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 46 46
1715 0 croak_xs_usage(cv, "self");
1716 PERL_UNUSED_VAR(ax); /* -Wall */
1717 46 SP -= items;
1718 {
1719 46 ▶ SV * self = ST(0)
Branch: 1 branch
BranchTrueFalseTotal
SV * self = ST(0) 7 39 46
1720 ;
1721 #line 230 "./xs/future.xs"
1722 {
1723 IV st;
1724 /* AWAIT_GET is defined only on a future that is already ready, so it
1725 * reads the result where every other spelling waits for one.
1726 * AWAIT_WAIT is the spelling that does wait - it is what a toplevel
1727 * await resolves to. */
1728 if (ix == 3) {
1729 st = hmf_state(aTHX_ self);
1730 if (st == HMF_PENDING) croak("Hyperman::Future is not ready");
1731 } else {
1732 /* The wait pumps the loop, which runs other handlers: the Perl
1733 * stack can be reallocated under this frame, so the pointer this
1734 * PPCODE pushes results through is re-read afterwards. */
1735 PUTBACK;
1736 hmf_await(aTHX_ self);
1737 SPAGAIN;
1738 st = hmf_state(aTHX_ self);
1739 }
1740 if (st == HMF_FAILED) {
1741 AV *fav = hmf_values_av(aTHX_ self);
1742 SV **e = fav ? av_fetch(fav, 0, 0) : NULL; /* # uncoverable condition right count:1 class:ignore_covered_err */
1743 if (e) croak_sv(sv_mortalcopy(*e));
1744 croak("Failed"); /* # uncoverable statement */
1745 }
1746 if (st == HMF_CANCELLED)
1747 croak("Hyperman::Future was cancelled");
1748 {
1749 AV *rav = hmf_values_av(aTHX_ self);
1750 SSize_t n = rav ? av_len(rav) + 1 : 0; /* # uncoverable condition right count:1 class:ignore_covered_err */
1751 if (GIMME_V == G_ARRAY) {
1752 SSize_t i;
1753 EXTEND(SP, n);
1754 for (i = 0; i < n; i++) {
1755 SV **e = av_fetch(rav, i, 0);
1756 PUSHs(e ? sv_mortalcopy(*e) : &PL_sv_undef); /* # uncoverable condition right count:1 class:ignore_covered_err */
1757 }
1758 } else if (n) {
1759 SV **e = av_fetch(rav, 0, 0);
1760 XPUSHs(e ? sv_mortalcopy(*e) : &PL_sv_undef);
1761 } else {
1762 XPUSHs(&PL_sv_undef);
1763 }
1764 }
1765 }
1766 #line 1767 "Hyperman.c"
1767 28 PUTBACK;
1768 28 return;
1769 }
1770 }
1771  
1772  
1773 XS_EUPXS(XS_Hyperman__Future_failure); /* prototype to pass -Wmissing-prototypes */
1774 8 XS_EUPXS(XS_Hyperman__Future_failure)
1775 {
1776 8 dVAR; dXSARGS;
1777 8 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 8 8
1778 0 croak_xs_usage(cv, "self");
1779 PERL_UNUSED_VAR(ax); /* -Wall */
1780 8 SP -= items;
1781 {
1782 8 SV * self = ST(0)
1783 ;
1784 #line 283 "./xs/future.xs"
1785 {
1786 PUTBACK;
1787 hmf_await(aTHX_ self);
1788 SPAGAIN;
1789 if (hmf_state(aTHX_ self) != HMF_FAILED) XSRETURN_EMPTY;
1790 {
1791 AV *fav = hmf_values_av(aTHX_ self);
1792 SSize_t n = fav ? av_len(fav) + 1 : 0; /* # uncoverable condition right count:1 class:ignore_covered_err */
1793 if (GIMME_V == G_ARRAY) {
1794 SSize_t i;
1795 EXTEND(SP, n);
1796 for (i = 0; i < n; i++) {
1797 SV **e = av_fetch(fav, i, 0);
1798 PUSHs(e ? sv_mortalcopy(*e) : &PL_sv_undef); /* # uncoverable condition right count:1 class:ignore_covered_err */
1799 }
1800 } else if (n) {
1801 SV **e = av_fetch(fav, 0, 0);
1802 XPUSHs(e ? sv_mortalcopy(*e) : &PL_sv_undef);
1803 }
1804 }
1805 }
1806 #line 1807 "Hyperman.c"
1807 8 PUTBACK;
1808 8 return;
1809 }
1810 }
1811  
1812  
1813 XS_EUPXS(XS_Hyperman__Future__values); /* prototype to pass -Wmissing-prototypes */
1814 17 XS_EUPXS(XS_Hyperman__Future__values)
1815 {
1816 17 dVAR; dXSARGS;
1817 17 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 17 17
1818 0 croak_xs_usage(cv, "self");
1819 PERL_UNUSED_VAR(ax); /* -Wall */
1820 17 SP -= items;
1821 {
1822 17 SV * self = ST(0)
1823 ;
1824 #line 316 "./xs/future.xs"
1825 {
1826 AV *rav = hmf_values_av(aTHX_ self);
1827 SSize_t i, n = rav ? av_len(rav) + 1 : 0; /* # uncoverable condition right count:1 class:ignore_covered_err */
1828 EXTEND(SP, n);
1829 for (i = 0; i < n; i++) {
1830 SV **e = av_fetch(rav, i, 0);
1831 PUSHs(e ? sv_mortalcopy(*e) : &PL_sv_undef); /* # uncoverable condition right count:1 class:ignore_covered_err */
1832 }
1833 }
1834 #line 1835 "Hyperman.c"
1835 17 PUTBACK;
1836 17 return;
1837 }
1838 }
1839  
1840  
1841 XS_EUPXS(XS_Hyperman__Future_then); /* prototype to pass -Wmissing-prototypes */
1842 50023 XS_EUPXS(XS_Hyperman__Future_then)
1843 {
1844 50023 dVAR; dXSARGS;
1845 50023 dXSI32;
1846 50023 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 50023 50023
1847 0 croak_xs_usage(cv, "self, ...");
1848 {
1849 50023 ▶ SV * self = ST(0)
Branch: 1 branch
BranchTrueFalseTotal
SV * self = ST(0) 50022 1 50023
1850 ;
1851 SV * RETVAL;
1852 #line 334 "./xs/future.xs"
1853 {
1854 SV *on_done = NULL, *on_fail = NULL;
1855 SV *cb;
1856 if (ix == 0) { /* then($ok?, $err?) */
1857 if (items > 1 && SvOK(ST(1))) on_done = ST(1); /* # uncoverable condition right count:1 class:ignore_covered_err */
1858 if (items > 2 && SvOK(ST(2))) on_fail = ST(2); /* # uncoverable condition right count:2 class:ignore_covered_err */
1859 } else { /* else($err) */
1860 if (items > 1 && SvOK(ST(1))) on_fail = ST(1);
1861 }
1862 RETVAL = hmf_new(aTHX_ hmf_class_of(aTHX_ self));
1863 hmf_set_upstream(aTHX_ RETVAL, self);
1864 cb = hm_closure(aTHX_ hm_xs_then_cb, RETVAL, on_done, on_fail, NULL, 0, 0);
1865 hmf_on_ready(aTHX_ self, cb);
1866 SvREFCNT_dec(cb);
1867 }
1868 #line 1869 "Hyperman.c"
1869 50023 RETVAL = sv_2mortal(RETVAL);
1870 50023 ST(0) = RETVAL;
1871 }
1872 50023 XSRETURN(1);
1873 }
1874  
1875  
1876 XS_EUPXS(XS_Hyperman__Future_followed_by); /* prototype to pass -Wmissing-prototypes */
1877 9 XS_EUPXS(XS_Hyperman__Future_followed_by)
1878 {
1879 9 dVAR; dXSARGS;
1880 9 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 9 9
1881 0 croak_xs_usage(cv, "self, usercb");
1882 {
1883 9 SV * self = ST(0)
1884 ;
1885 9 SV * usercb = ST(1)
1886 ;
1887 SV * RETVAL;
1888 #line 360 "./xs/future.xs"
1889 {
1890 SV *cb;
1891 RETVAL = hmf_new(aTHX_ hmf_class_of(aTHX_ self));
1892 hmf_set_upstream(aTHX_ RETVAL, self);
1893 cb = hm_closure(aTHX_ hm_xs_then_cb, RETVAL, usercb, NULL, NULL, 1, 0);
1894 hmf_on_ready(aTHX_ self, cb);
1895 SvREFCNT_dec(cb);
1896 }
1897 #line 1898 "Hyperman.c"
1898 9 RETVAL = sv_2mortal(RETVAL);
1899 9 ST(0) = RETVAL;
1900 }
1901 9 XSRETURN(1);
1902 }
1903  
1904  
1905 XS_EUPXS(XS_Hyperman__Future_transform); /* prototype to pass -Wmissing-prototypes */
1906 9 XS_EUPXS(XS_Hyperman__Future_transform)
1907 {
1908 9 dVAR; dXSARGS;
1909 9 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 9 9
1910 0 croak_xs_usage(cv, "self, ...");
1911 {
1912 9 ▶ SV * self = ST(0)
Branch: 1 branch
BranchTrueFalseTotal
SV * self = ST(0) 1 8 9
1913 ;
1914 SV * RETVAL;
1915 #line 375 "./xs/future.xs"
1916 {
1917 SV *xd = NULL, *xf = NULL;
1918 SV *cb;
1919 int i;
1920 if ((items - 1) % 2)
1921 croak("transform: odd number of arguments");
1922 for (i = 1; i + 1 < items; i += 2) {
1923 const char *key = SvPV_nolen(ST(i));
1924 if (strEQ(key, "done")) xd = ST(i + 1);
1925 else if (strEQ(key, "fail")) xf = ST(i + 1);
1926 else croak("transform: unknown argument '%s'", key);
1927 }
1928 RETVAL = hmf_new(aTHX_ hmf_class_of(aTHX_ self));
1929 hmf_set_upstream(aTHX_ RETVAL, self);
1930 cb = hm_closure(aTHX_ hm_xs_transform_cb, RETVAL, xd, xf, NULL, 0, 0);
1931 hmf_on_ready(aTHX_ self, cb);
1932 SvREFCNT_dec(cb);
1933 }
1934 #line 1935 "Hyperman.c"
1935 7 RETVAL = sv_2mortal(RETVAL);
1936 7 ST(0) = RETVAL;
1937 }
1938 7 XSRETURN(1);
1939 }
1940  
1941  
1942 XS_EUPXS(XS_Hyperman__Future__set_upstream); /* prototype to pass -Wmissing-prototypes */
1943 1 XS_EUPXS(XS_Hyperman__Future__set_upstream)
1944 {
1945 1 dVAR; dXSARGS;
1946 1 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 1 1
1947 0 croak_xs_usage(cv, "derived, upstream");
1948 {
1949 1 SV * derived = ST(0)
1950 ;
1951 1 SV * upstream = ST(1)
1952 ;
1953 #line 402 "./xs/future.xs"
1954 hmf_set_upstream(aTHX_ derived, upstream);
1955 #line 1956 "Hyperman.c"
1956 }
1957 1 XSRETURN_EMPTY;
1958 }
1959  
1960  
1961 XS_EUPXS(XS_Hyperman__Future_wait_all); /* prototype to pass -Wmissing-prototypes */
1962 17 XS_EUPXS(XS_Hyperman__Future_wait_all)
1963 {
1964 17 dVAR; dXSARGS;
1965 17 dXSI32;
1966 17 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 17 17
1967 0 croak_xs_usage(cv, "class, ...");
1968 {
1969 17 SV * class = ST(0)
1970 ;
1971 SV * RETVAL;
1972 #line 414 "./xs/future.xs"
1973 {
1974 static const IV modes[4] = { HM_COMB_WAIT_ALL, HM_COMB_WAIT_ANY,
1975 HM_COMB_NEEDS_ALL, HM_COMB_NEEDS_ANY };
1976 RETVAL = hmf_combine(aTHX_ class, &ST(1), items - 1, modes[ix]);
1977 }
1978 #line 1979 "Hyperman.c"
1979 17 RETVAL = sv_2mortal(RETVAL);
1980 17 ST(0) = RETVAL;
1981 }
1982 17 XSRETURN(1);
1983 }
1984  
1985  
1986 XS_EUPXS(XS_Hyperman__Future_as_cpan_future); /* prototype to pass -Wmissing-prototypes */
1987 0 XS_EUPXS(XS_Hyperman__Future_as_cpan_future)
1988 {
1989 0 dVAR; dXSARGS;
1990 0 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 0 0
1991 0 croak_xs_usage(cv, "self");
1992 {
1993 0 SV * self = ST(0)
1994 ;
1995 SV * RETVAL;
1996 #line 428 "./xs/future.xs"
1997 {
1998 SV *cf, *cb;
1999 dSP;
2000 int n;
2001 load_module(PERL_LOADMOD_NOIMPORT, newSVpvs("Future"), NULL);
2002 ENTER; SAVETMPS;
2003 PUSHMARK(SP);
2004 XPUSHs(sv_2mortal(newSVpvs("Future")));
2005 PUTBACK;
2006 n = call_method("new", G_SCALAR);
2007 SPAGAIN;
2008 cf = n ? SvREFCNT_inc(POPs) : &PL_sv_undef; /* # uncoverable condition right count:1 class:ignore_covered_err */
2009 PUTBACK; FREETMPS; LEAVE;
2010 cb = hm_closure(aTHX_ hm_xs_tocpan_cb, cf, NULL, NULL, NULL, 0, 0);
2011 hmf_on_ready(aTHX_ self, cb);
2012 SvREFCNT_dec(cb);
2013 RETVAL = cf;
2014 }
2015 #line 2016 "Hyperman.c"
2016 0 RETVAL = sv_2mortal(RETVAL);
2017 0 ST(0) = RETVAL;
2018 }
2019 0 XSRETURN(1);
2020 }
2021  
2022  
2023 XS_EUPXS(XS_Hyperman__Future_from_future); /* prototype to pass -Wmissing-prototypes */
2024 3 XS_EUPXS(XS_Hyperman__Future_from_future)
2025 {
2026 3 dVAR; dXSARGS;
2027 3 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 3 3
2028 0 croak_xs_usage(cv, "class, other");
2029 {
2030 3 SV * class = ST(0)
2031 ;
2032 3 ▶ SV * other = ST(1)
Branch: 1 branch
BranchTrueFalseTotal
SV * other = ST(1) 0 3 3
2033 ;
2034 SV * RETVAL;
2035 #line 454 "./xs/future.xs"
2036 {
2037 const char *name = (SvROK(class) && SvOBJECT(SvRV(class))) ? HvNAME(SvSTASH(SvRV(class))) /* # uncoverable statement class:ignore_covered_err */
2038 : SvPV_nolen(class);
2039 SV *cb;
2040 RETVAL = hmf_new(aTHX_ name);
2041 cb = hm_closure(aTHX_ hm_xs_fromcpan_cb, RETVAL, NULL, NULL, NULL, 0, 0);
2042 hm_any_on_ready(aTHX_ other, cb);
2043 SvREFCNT_dec(cb);
2044 }
2045 #line 2046 "Hyperman.c"
2046 3 RETVAL = sv_2mortal(RETVAL);
2047 3 ST(0) = RETVAL;
2048 }
2049 3 XSRETURN(1);
2050 }
2051  
2052  
2053 /* INCLUDE: Returning to 'Hyperman.xs' from 'xs/future.xs' */
2054  
2055  
2056 /* INCLUDE: Including 'xs/loop.xs' from 'Hyperman.xs' */
2057  
2058  
2059 XS_EUPXS(XS_Hyperman__Loop_new); /* prototype to pass -Wmissing-prototypes */
2060 42 XS_EUPXS(XS_Hyperman__Loop_new)
2061 {
2062 42 dVAR; dXSARGS;
2063 42 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 42 42
2064 0 croak_xs_usage(cv, "class, ...");
2065 {
2066 42 ▶ SV * class = ST(0)
Branch: 1 branch
BranchTrueFalseTotal
SV * class = ST(0) 27 15 42
2067 ;
2068 SV * RETVAL;
2069 #line 10 "./xs/loop.xs"
2070 {
2071 const char *bname = (items > 1 && SvOK(ST(1))) ? SvPV_nolen(ST(1)) : NULL;
2072 hm_loop *loop;
2073 int i;
2074 PERL_UNUSED_VAR(class);
2075 loop = hm_loop_new(aTHX_ bname);
2076 if (!loop) croak("Hyperman::Loop: no usable event backend%s%s",
2077 bname ? " named " : "", bname ? bname : "");
2078 /* Key/value options after the backend name, so the loop takes the
2079 * same settings the server does rather than only reading the
2080 * environment. Odd counts croak instead of silently dropping one. */
2081 if (items > 2) {
2082 if ((items - 2) % 2)
2083 croak("Hyperman::Loop->new: odd number of options");
2084 for (i = 2; i + 1 < items; i += 2) {
2085 const char *key = SvPV_nolen(ST(i));
2086 SV *val = ST(i + 1);
2087 if (strEQ(key, "completion"))
2088 loop->completion =
2089 (SvTRUE(val) && loop->be->submit_recv) ? 1 : 0;
2090 else croak("Hyperman::Loop->new: unknown option '%s'", key);
2091 }
2092 }
2093 loop->perl_owned = 1;
2094 RETVAL = hm_loop_to_sv(aTHX_ loop);
2095 }
2096 #line 2097 "Hyperman.c"
2097 36 RETVAL = sv_2mortal(RETVAL);
2098 36 ST(0) = RETVAL;
2099 }
2100 36 XSRETURN(1);
2101 }
2102  
2103  
2104 XS_EUPXS(XS_Hyperman__Loop_run); /* prototype to pass -Wmissing-prototypes */
2105 17 XS_EUPXS(XS_Hyperman__Loop_run)
2106 {
2107 17 dVAR; dXSARGS;
2108 17 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 17 17
2109 0 croak_xs_usage(cv, "self");
2110 {
2111 17 SV * self = ST(0)
2112 ;
2113 #line 48 "./xs/loop.xs"
2114 hm_loop_run(aTHX_ hm_loop_from_sv(aTHX_ self), NULL);
2115 #line 2116 "Hyperman.c"
2116 }
2117 16 XSRETURN_EMPTY;
2118 }
2119  
2120  
2121 XS_EUPXS(XS_Hyperman__Loop_run_until); /* prototype to pass -Wmissing-prototypes */
2122 13 XS_EUPXS(XS_Hyperman__Loop_run_until)
2123 {
2124 13 dVAR; dXSARGS;
2125 13 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 13 13
2126 0 croak_xs_usage(cv, "self, future");
2127 {
2128 13 SV * self = ST(0)
2129 ;
2130 13 SV * future = ST(1)
2131 ;
2132 #line 55 "./xs/loop.xs"
2133 if (!hmf_is_future(aTHX_ future))
2134 croak("run_until: not a Hyperman::Future");
2135 hm_loop_run(aTHX_ hm_loop_from_sv(aTHX_ self), future);
2136 #line 2137 "Hyperman.c"
2137 }
2138 12 XSRETURN_EMPTY;
2139 }
2140  
2141  
2142 XS_EUPXS(XS_Hyperman__Loop_stop); /* prototype to pass -Wmissing-prototypes */
2143 17 XS_EUPXS(XS_Hyperman__Loop_stop)
2144 {
2145 17 dVAR; dXSARGS;
2146 17 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 17 17
2147 0 croak_xs_usage(cv, "self");
2148 {
2149 17 SV * self = ST(0)
2150 ;
2151 #line 63 "./xs/loop.xs"
2152 hm_loop_from_sv(aTHX_ self)->stop = 1;
2153 #line 2154 "Hyperman.c"
2154 }
2155 17 XSRETURN_EMPTY;
2156 }
2157  
2158  
2159 XS_EUPXS(XS_Hyperman__Loop_watch_io); /* prototype to pass -Wmissing-prototypes */
2160 4 XS_EUPXS(XS_Hyperman__Loop_watch_io)
2161 {
2162 4 dVAR; dXSARGS;
2163 4 ▶ if (items != 4)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 4) 0 4 4
2164 0 croak_xs_usage(cv, "self, fh, mode, cb");
2165 {
2166 4 SV * self = ST(0)
2167 ;
2168 4 SV * fh = ST(1)
2169 ;
2170 4 SV * mode = ST(2)
2171 ;
2172 4 SV * cb = ST(3)
2173 ;
2174 SV * RETVAL;
2175 #line 73 "./xs/loop.xs"
2176 {
2177 hm_loop *loop = hm_loop_from_sv(aTHX_ self);
2178 int fd = hm_fd_of(aTHX_ fh);
2179 const char *m = SvOK(mode) ? SvPV_nolen(mode) : "r"; /* # uncoverable condition right count:1 class:ignore_covered_err */
2180 AV *handle = newAV();
2181 hm_add_io_watch(aTHX_ loop, fd, m, cb, 1);
2182 av_push(handle, newSViv(fd));
2183 av_push(handle, newSVpv(m, 0));
2184 RETVAL = newRV_noinc((SV *)handle);
2185 }
2186 #line 2187 "Hyperman.c"
2187 4 RETVAL = sv_2mortal(RETVAL);
2188 4 ST(0) = RETVAL;
2189 }
2190 4 XSRETURN(1);
2191 }
2192  
2193  
2194 XS_EUPXS(XS_Hyperman__Loop_unwatch_io); /* prototype to pass -Wmissing-prototypes */
2195 6 XS_EUPXS(XS_Hyperman__Loop_unwatch_io)
2196 {
2197 6 dVAR; dXSARGS;
2198 6 ▶ if (items < 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) 0 6 6
2199 0 croak_xs_usage(cv, "self, watcher, ...");
2200 {
2201 6 SV * self = ST(0)
2202 ;
2203 6 SV * watcher = ST(1)
2204 ;
2205 #line 92 "./xs/loop.xs"
2206 {
2207 hm_loop *loop = hm_loop_from_sv(aTHX_ self);
2208 int fd;
2209 const char *m = "r";
2210 if (SvROK(watcher) && SvTYPE(SvRV(watcher)) == SVt_PVAV
2211 && !SvOBJECT(SvRV(watcher))) {
2212 AV *h = (AV *)SvRV(watcher);
2213 SV **f = av_fetch(h, 0, 0);
2214 SV **mo = av_fetch(h, 1, 0);
2215 fd = f ? (int)SvIV(*f) : -1; /* # uncoverable condition right count:1 class:ignore_covered_err */
2216 if (mo && SvOK(*mo)) m = SvPV_nolen(*mo);
2217 } else {
2218 fd = hm_fd_of(aTHX_ watcher);
2219 if (items > 2 && SvOK(ST(2))) m = SvPV_nolen(ST(2));
2220 }
2221 hm_del_io_watch(aTHX_ loop, fd,
2222 m[0] == 'w' ? HM_EV_WRITE : HM_EV_READ); /* # uncoverable condition left count:1 class:ignore_covered_err */
2223 }
2224 #line 2225 "Hyperman.c"
2225 }
2226 6 XSRETURN(1);
2227 }
2228  
2229  
2230 XS_EUPXS(XS_Hyperman__Loop_timer); /* prototype to pass -Wmissing-prototypes */
2231 33 XS_EUPXS(XS_Hyperman__Loop_timer)
2232 {
2233 33 dVAR; dXSARGS;
2234 33 ▶ if (items != 3)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 3) 0 33 33
2235 0 croak_xs_usage(cv, "self, secs, cb");
2236 {
2237 33 SV * self = ST(0)
2238 ;
2239 33 double secs = (double)SvNV(ST(1))
2240 ;
2241 33 SV * cb = ST(2)
2242 ;
2243 #line 126 "./xs/loop.xs"
2244 hm_add_timer_watch(aTHX_ hm_loop_from_sv(aTHX_ self), secs, cb, HM_TW_CB);
2245 #line 2246 "Hyperman.c"
2246 }
2247 33 XSRETURN_EMPTY;
2248 }
2249  
2250  
2251 XS_EUPXS(XS_Hyperman__Loop_timer_f); /* prototype to pass -Wmissing-prototypes */
2252 2022 XS_EUPXS(XS_Hyperman__Loop_timer_f)
2253 {
2254 2022 dVAR; dXSARGS;
2255 2022 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 2022 2022
2256 0 croak_xs_usage(cv, "self, secs");
2257 {
2258 2022 SV * self = ST(0)
2259 ;
2260 2022 double secs = (double)SvNV(ST(1))
2261 ;
2262 SV * RETVAL;
2263 #line 135 "./xs/loop.xs"
2264 RETVAL = hmf_new(aTHX_ "Hyperman::Future");
2265 hm_add_timer_watch(aTHX_ hm_loop_from_sv(aTHX_ self), secs, RETVAL,
2266 HM_TW_FUTURE);
2267 #line 2268 "Hyperman.c"
2268 2022 RETVAL = sv_2mortal(RETVAL);
2269 2022 ST(0) = RETVAL;
2270 }
2271 2022 XSRETURN(1);
2272 }
2273  
2274  
2275 XS_EUPXS(XS_Hyperman__Loop_readable_f); /* prototype to pass -Wmissing-prototypes */
2276 10 XS_EUPXS(XS_Hyperman__Loop_readable_f)
2277 {
2278 10 dVAR; dXSARGS;
2279 10 dXSI32;
2280 10 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 10 10
2281 0 croak_xs_usage(cv, "self, fh");
2282 {
2283 10 SV * self = ST(0)
2284 ;
2285 10 SV * fh = ST(1)
2286 ;
2287 SV * RETVAL;
2288 #line 148 "./xs/loop.xs"
2289 RETVAL = hmf_new(aTHX_ "Hyperman::Future");
2290 hm_add_io_watch(aTHX_ hm_loop_from_sv(aTHX_ self),
2291 hm_fd_of(aTHX_ fh), ix ? "w" : "r", RETVAL, 0);
2292 #line 2293 "Hyperman.c"
2293 10 RETVAL = sv_2mortal(RETVAL);
2294 10 ST(0) = RETVAL;
2295 }
2296 10 XSRETURN(1);
2297 }
2298  
2299  
2300 XS_EUPXS(XS_Hyperman__Loop_defer); /* prototype to pass -Wmissing-prototypes */
2301 3 XS_EUPXS(XS_Hyperman__Loop_defer)
2302 {
2303 3 dVAR; dXSARGS;
2304 3 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 3 3
2305 0 croak_xs_usage(cv, "self, cb");
2306 {
2307 3 SV * self = ST(0)
2308 ;
2309 3 SV * cb = ST(1)
2310 ;
2311 #line 159 "./xs/loop.xs"
2312 av_push(hm_loop_from_sv(aTHX_ self)->deferred, newSVsv(cb));
2313 #line 2314 "Hyperman.c"
2314 }
2315 3 XSRETURN_EMPTY;
2316 }
2317  
2318  
2319 XS_EUPXS(XS_Hyperman__Loop_install_await); /* prototype to pass -Wmissing-prototypes */
2320 1 XS_EUPXS(XS_Hyperman__Loop_install_await)
2321 {
2322 1 dVAR; dXSARGS;
2323 1 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 1 1
2324 0 croak_xs_usage(cv, "self");
2325 {
2326 1 SV * self = ST(0)
2327 ;
2328 SV * RETVAL;
2329 #line 167 "./xs/loop.xs"
2330 {
2331 SV *cb = hm_closure(aTHX_ hm_xs_await_cb, self, NULL, NULL, NULL, 0, 0);
2332 SV *aw = get_sv("Hyperman::Future::AWAIT", GV_ADD);
2333 sv_setsv(aw, cb);
2334 SvREFCNT_dec(cb);
2335 RETVAL = SvREFCNT_inc(self);
2336 }
2337 #line 2338 "Hyperman.c"
2338 1 RETVAL = sv_2mortal(RETVAL);
2339 1 ST(0) = RETVAL;
2340 }
2341 1 XSRETURN(1);
2342 }
2343  
2344  
2345 XS_EUPXS(XS_Hyperman__Loop_backend); /* prototype to pass -Wmissing-prototypes */
2346 3 XS_EUPXS(XS_Hyperman__Loop_backend)
2347 {
2348 3 dVAR; dXSARGS;
2349 3 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 3 3
2350 0 croak_xs_usage(cv, "self");
2351 {
2352 3 SV * self = ST(0)
2353 ;
2354 const char * RETVAL;
2355 3 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 3 0 3
2356 #line 181 "./xs/loop.xs"
2357 RETVAL = hm_loop_from_sv(aTHX_ self)->be->name;
2358 #line 2359 "Hyperman.c"
2359 3 sv_setpv((SV*)TARG, RETVAL);
2360 3 ST(0) = TARG;
2361 }
2362 3 XSRETURN(1);
2363 }
2364  
2365  
2366 XS_EUPXS(XS_Hyperman__Loop_DESTROY); /* prototype to pass -Wmissing-prototypes */
2367 914 XS_EUPXS(XS_Hyperman__Loop_DESTROY)
2368 {
2369 914 dVAR; dXSARGS;
2370 914 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 914 914
2371 0 croak_xs_usage(cv, "self");
2372 {
2373 914 SV * self = ST(0)
2374 ;
2375 #line 189 "./xs/loop.xs"
2376 {
2377 hm_loop *loop = hm_loop_from_sv(aTHX_ self);
2378 if (loop->perl_owned && !loop->running && loop != hm_cur_loop)
2379 hm_loop_free(aTHX_ loop);
2380 }
2381 #line 2382 "Hyperman.c"
2382 }
2383 914 XSRETURN_EMPTY;
2384 }
2385  
2386  
2387 /* INCLUDE: Returning to 'Hyperman.xs' from 'xs/loop.xs' */
2388  
2389  
2390 /* INCLUDE: Including 'xs/writer.xs' from 'Hyperman.xs' */
2391  
2392  
2393 XS_EUPXS(XS_Hyperman__Writer_write); /* prototype to pass -Wmissing-prototypes */
2394 53 XS_EUPXS(XS_Hyperman__Writer_write)
2395 {
2396 53 dVAR; dXSARGS;
2397 53 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 53 53
2398 0 croak_xs_usage(cv, "self, data");
2399 {
2400 53 SV * self = ST(0)
2401 ;
2402 53 SV * data = ST(1)
2403 ;
2404 IV RETVAL;
2405 53 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 53 0 53
2406 #line 45 "./xs/writer.xs"
2407 {
2408 AV *w = (AV *)SvRV(self);
2409 SSize_t n = av_len(w);
2410 RETVAL = -1;
2411 if (n == 2) { /* stream-handle form */
2412 SV **h = av_fetch(w, 0, 0);
2413 STRLEN l;
2414 const char *p = SvPV(data, l);
2415 if (h && SvIV(*h)) { /* # uncoverable condition right count:1 class:ignore_covered_err */
2416 int rc = hm_stream_write_h(aTHX_ INT2PTR(void *, SvIV(*h)), p, l);
2417 RETVAL = rc == HM_ABI_STREAM_OK ? 1
2418 : rc == HM_ABI_STREAM_FULL ? 0 : -1; /* # uncoverable condition right count:2 class:ignore_covered_err */
2419 }
2420 } else if (n >= 3) { /* h2 or h3: told apart by the tag */
2421 SV **f = av_fetch(w, 0, 0);
2422 SV **g = av_fetch(w, 1, 0);
2423 SV **s = av_fetch(w, 2, 0);
2424 if (f && g && s) {
2425 if (hm_writer_tag_is(aTHX_ w, "h1", 2))
2426 RETVAL = hm_stream_write(aTHX_ (int)SvIV(*f), SvUV(*g), SvUV(*s), data);
2427 else if (hm_writer_tag_is(aTHX_ w, "h3", 2))
2428 RETVAL = hm_h3_writer_write(aTHX_ (int)SvIV(*f), SvUV(*g), /* # uncoverable statement class:ignore_covered_err */
2429 (int64_t)SvIV(*s), data); /* # uncoverable statement class:ignore_covered_err */
2430 else
2431 RETVAL = hm_h2_writer_write(aTHX_ (int)SvIV(*f), SvUV(*g),
2432 (int32_t)SvIV(*s), data);
2433 }
2434 } else {
2435 SV **f = av_fetch(w, 0, 0);
2436 SV **i = av_fetch(w, 1, 0);
2437 if (f && i)
2438 RETVAL = hm_stream_write(aTHX_ (int)SvIV(*f), SvUV(*i), 0, data);
2439 }
2440 }
2441 #line 2442 "Hyperman.c"
2442 53 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 8 45 53
2443 53 ST(0) = TARG;
2444 }
2445 53 XSRETURN(1);
2446 }
2447  
2448  
2449 XS_EUPXS(XS_Hyperman__Writer_DESTROY); /* prototype to pass -Wmissing-prototypes */
2450 56 XS_EUPXS(XS_Hyperman__Writer_DESTROY)
2451 {
2452 56 dVAR; dXSARGS;
2453 56 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 56 56
2454 0 croak_xs_usage(cv, "self");
2455 {
2456 56 SV * self = ST(0)
2457 ;
2458 #line 102 "./xs/writer.xs"
2459 {
2460 AV *w = (AV *)SvRV(self);
2461 SSize_t n = av_len(w);
2462 if (n == 2) {
2463 SV **h = av_fetch(w, 0, 0);
2464 if (h && SvIV(*h)) { /* # uncoverable condition right count:1 class:ignore_covered_err */
2465 hm_stream_close_h(aTHX_ INT2PTR(void *, SvIV(*h)));
2466 sv_setiv(*h, 0);
2467 }
2468 } else if (n == 1) {
2469 SV **f = av_fetch(w, 0, 0);
2470 SV **i = av_fetch(w, 1, 0);
2471 if (f && i && hm_cur_loop)
2472 hm_stream_close(aTHX_ (int)SvIV(*f), SvUV(*i), 0);
2473 } else if (n >= 3 && hm_writer_tag_is(aTHX_ w, "h1", 2)) { /* # uncoverable condition right count:1 class:ignore_covered_err */
2474 SV **f = av_fetch(w, 0, 0);
2475 SV **g = av_fetch(w, 1, 0);
2476 SV **s = av_fetch(w, 2, 0);
2477 if (f && g && s && hm_cur_loop)
2478 hm_stream_close(aTHX_ (int)SvIV(*f), SvUV(*g), SvUV(*s));
2479 }
2480 }
2481 #line 2482 "Hyperman.c"
2482 }
2483 56 XSRETURN_EMPTY;
2484 }
2485  
2486  
2487 XS_EUPXS(XS_Hyperman__Writer_close); /* prototype to pass -Wmissing-prototypes */
2488 47 XS_EUPXS(XS_Hyperman__Writer_close)
2489 {
2490 47 dVAR; dXSARGS;
2491 47 ▶ if (items < 1 || items > 2)
Branch: 2 branches
BranchTrueFalseTotal
if (items < 1 || items > 2) 47 0 47
if (items < 1 || items > 2) 0 47 47
2492 0 croak_xs_usage(cv, "self, given = NULL");
2493 {
2494 47 SV * self = ST(0)
2495 ;
2496 SV * given;
2497  
2498 47 ▶ if (items < 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) 24 23 47
2499 24 given = NULL;
2500 else {
2501 23 given = ST(1)
2502 ;
2503 }
2504 #line 146 "./xs/writer.xs"
2505 {
2506 AV *w = (AV *)SvRV(self);
2507 SSize_t n = av_len(w);
2508 SV *err;
2509 AV *trailers = hm_trailers_build(aTHX_ given, &err);
2510 if (err) croak("Hyperman::Writer::close: %" SVf, SVfARG(err));
2511 if (trailers && n >= 3 && hm_writer_tag_is(aTHX_ w, "h3", 2)) {
2512 SvREFCNT_dec((SV *)trailers);
2513 croak("Hyperman::Writer::close: trailers are not implemented "
2514 "over HTTP/3");
2515 }
2516 if (n == 2) { /* stream-handle form */
2517 SV **h = av_fetch(w, 0, 0);
2518 if (h && SvIV(*h)) {
2519 hm_stream_finish_h(aTHX_ INT2PTR(void *, SvIV(*h)), trailers);
2520 trailers = NULL;
2521 /* the handle is freed; blank the slot so a second ->close
2522 * cannot hand the registry a stale pointer to compare */
2523 sv_setiv(*h, 0);
2524 }
2525 } else if (n >= 3) { /* h1, h2 or h3: told apart by the tag */
2526 SV **f = av_fetch(w, 0, 0);
2527 SV **g = av_fetch(w, 1, 0);
2528 SV **s = av_fetch(w, 2, 0);
2529 if (f && g && s) {
2530 if (hm_writer_tag_is(aTHX_ w, "h1", 2))
2531 hm_stream_finish(aTHX_ (int)SvIV(*f), SvUV(*g), SvUV(*s), trailers);
2532 else if (hm_writer_tag_is(aTHX_ w, "h3", 2))
2533 hm_h3_writer_close(aTHX_ (int)SvIV(*f), SvUV(*g), /* # uncoverable statement class:ignore_covered_err */
2534 (int64_t)SvIV(*s)); /* # uncoverable statement class:ignore_covered_err */
2535 else {
2536 hm_h2_writer_close(aTHX_ (int)SvIV(*f), SvUV(*g),
2537 (int32_t)SvIV(*s), trailers);
2538 trailers = NULL;
2539 }
2540 }
2541 } else {
2542 SV **f = av_fetch(w, 0, 0);
2543 SV **i = av_fetch(w, 1, 0);
2544 if (f && i)
2545 hm_stream_finish(aTHX_ (int)SvIV(*f), SvUV(*i), 0, trailers);
2546 }
2547 if (trailers) SvREFCNT_dec((SV *)trailers);
2548 }
2549 #line 2550 "Hyperman.c"
2550 }
2551 33 XSRETURN_EMPTY;
2552 }
2553  
2554  
2555 XS_EUPXS(XS_Hyperman__Writer_abort); /* prototype to pass -Wmissing-prototypes */
2556 5 XS_EUPXS(XS_Hyperman__Writer_abort)
2557 {
2558 5 dVAR; dXSARGS;
2559 5 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 5 5
2560 0 croak_xs_usage(cv, "self");
2561 {
2562 5 SV * self = ST(0)
2563 ;
2564 IV RETVAL;
2565 5 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 5 0 5
2566 #line 211 "./xs/writer.xs"
2567 {
2568 AV *w = (AV *)SvRV(self);
2569 RETVAL = HM_ABI_STREAM_STALE;
2570 if (av_len(w) == 2) {
2571 SV **h = av_fetch(w, 0, 0);
2572 if (h && SvIV(*h)) { /* # uncoverable condition right count:1 class:ignore_covered_err */
2573 RETVAL = hm_stream_abort_h(aTHX_ INT2PTR(void *, SvIV(*h)));
2574 sv_setiv(*h, 0); /* freed; a later ->close is a no-op */
2575 }
2576 }
2577 }
2578 #line 2579 "Hyperman.c"
2579 5 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 5 5
2580 5 ST(0) = TARG;
2581 }
2582 5 XSRETURN(1);
2583 }
2584  
2585  
2586 /* INCLUDE: Returning to 'Hyperman.xs' from 'xs/writer.xs' */
2587  
2588  
2589 /* INCLUDE: Including 'xs/event.xs' from 'Hyperman.xs' */
2590  
2591  
2592 XS_EUPXS(XS_Hyperman__Event__Kqueue_available); /* prototype to pass -Wmissing-prototypes */
2593 5 XS_EUPXS(XS_Hyperman__Event__Kqueue_available)
2594 {
2595 5 dVAR; dXSARGS;
2596 PERL_UNUSED_VAR(cv); /* -W */
2597 PERL_UNUSED_VAR(items); /* -W */
2598 {
2599 int RETVAL;
2600 5 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 5 0 5
2601 #line 6 "./xs/event.xs"
2602 PERL_UNUSED_VAR(items);
2603 RETVAL = hm_backend_kqueue_available();
2604 #line 2605 "Hyperman.c"
2605 5 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 5 5
2606 5 ST(0) = TARG;
2607 }
2608 5 XSRETURN(1);
2609 }
2610  
2611  
2612 XS_EUPXS(XS_Hyperman__Event__Epoll_available); /* prototype to pass -Wmissing-prototypes */
2613 5 XS_EUPXS(XS_Hyperman__Event__Epoll_available)
2614 {
2615 5 dVAR; dXSARGS;
2616 PERL_UNUSED_VAR(cv); /* -W */
2617 PERL_UNUSED_VAR(items); /* -W */
2618 {
2619 int RETVAL;
2620 5 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 5 0 5
2621 #line 16 "./xs/event.xs"
2622 PERL_UNUSED_VAR(items);
2623 RETVAL = hm_backend_epoll_available();
2624 #line 2625 "Hyperman.c"
2625 5 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 5 5
2626 5 ST(0) = TARG;
2627 }
2628 5 XSRETURN(1);
2629 }
2630  
2631  
2632 XS_EUPXS(XS_Hyperman__Event__Poll_available); /* prototype to pass -Wmissing-prototypes */
2633 5 XS_EUPXS(XS_Hyperman__Event__Poll_available)
2634 {
2635 5 dVAR; dXSARGS;
2636 PERL_UNUSED_VAR(cv); /* -W */
2637 PERL_UNUSED_VAR(items); /* -W */
2638 {
2639 int RETVAL;
2640 5 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 5 0 5
2641 #line 26 "./xs/event.xs"
2642 PERL_UNUSED_VAR(items);
2643 RETVAL = hm_backend_poll_available();
2644 #line 2645 "Hyperman.c"
2645 5 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 5 5
2646 5 ST(0) = TARG;
2647 }
2648 5 XSRETURN(1);
2649 }
2650  
2651  
2652 XS_EUPXS(XS_Hyperman__Event__IOUring_available); /* prototype to pass -Wmissing-prototypes */
2653 5 XS_EUPXS(XS_Hyperman__Event__IOUring_available)
2654 {
2655 5 dVAR; dXSARGS;
2656 PERL_UNUSED_VAR(cv); /* -W */
2657 PERL_UNUSED_VAR(items); /* -W */
2658 {
2659 int RETVAL;
2660 5 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 5 0 5
2661 #line 36 "./xs/event.xs"
2662 PERL_UNUSED_VAR(items);
2663 RETVAL = hm_backend_iouring_available();
2664 #line 2665 "Hyperman.c"
2665 5 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 5 5
2666 5 ST(0) = TARG;
2667 }
2668 5 XSRETURN(1);
2669 }
2670  
2671  
2672 /* INCLUDE: Returning to 'Hyperman.xs' from 'xs/event.xs' */
2673  
2674  
2675 /* INCLUDE: Including 'xs/abi.xs' from 'Hyperman.xs' */
2676  
2677  
2678 XS_EUPXS(XS_Hyperman__abi_ptr); /* prototype to pass -Wmissing-prototypes */
2679 2 XS_EUPXS(XS_Hyperman__abi_ptr)
2680 {
2681 2 dVAR; dXSARGS;
2682 2 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 2 2
2683 0 croak_xs_usage(cv, "");
2684 {
2685 IV RETVAL;
2686 2 ▶ dXSTARG;
Branch: 2 branches
BranchTrueFalseTotal
dXSTARG; 2 0 2
dXSTARG; 0 2 2
2687 #line 10 "./xs/abi.xs"
2688 RETVAL = PTR2IV(&hm_abi_table);
2689 #line 2690 "Hyperman.c"
2690 2 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 2 2
2691 2 ST(0) = TARG;
2692 }
2693 2 XSRETURN(1);
2694 }
2695  
2696  
2697 XS_EUPXS(XS_Hyperman__abi_selftest); /* prototype to pass -Wmissing-prototypes */
2698 1 XS_EUPXS(XS_Hyperman__abi_selftest)
2699 {
2700 1 dVAR; dXSARGS;
2701 1 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 1 1
2702 0 croak_xs_usage(cv, "");
2703 {
2704 IV RETVAL;
2705 1 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 1 0 1
2706 #line 20 "./xs/abi.xs"
2707 RETVAL = hm_abi_selftest(aTHX);
2708 #line 2709 "Hyperman.c"
2709 1 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 1 1
2710 1 ST(0) = TARG;
2711 }
2712 1 XSRETURN(1);
2713 }
2714  
2715  
2716 XS_EUPXS(XS_Hyperman__abi_version); /* prototype to pass -Wmissing-prototypes */
2717 1 XS_EUPXS(XS_Hyperman__abi_version)
2718 {
2719 1 dVAR; dXSARGS;
2720 1 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 1 1
2721 0 croak_xs_usage(cv, "");
2722 {
2723 IV RETVAL;
2724 1 ▶ dXSTARG;
Branch: 2 branches
BranchTrueFalseTotal
dXSTARG; 1 0 1
dXSTARG; 0 1 1
2725 #line 29 "./xs/abi.xs"
2726 RETVAL = hm_abi_table.abi_version;
2727 #line 2728 "Hyperman.c"
2728 1 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 1 1
2729 1 ST(0) = TARG;
2730 }
2731 1 XSRETURN(1);
2732 }
2733  
2734  
2735 XS_EUPXS(XS_Hyperman__abi_worker_hook_install); /* prototype to pass -Wmissing-prototypes */
2736 3 XS_EUPXS(XS_Hyperman__abi_worker_hook_install)
2737 {
2738 3 dVAR; dXSARGS;
2739 3 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 3 3
2740 0 croak_xs_usage(cv, "");
2741 {
2742 IV RETVAL;
2743 3 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 3 0 3
2744 #line 39 "./xs/abi.xs"
2745 RETVAL = hm_abi_worker_hook_install(aTHX);
2746 #line 2747 "Hyperman.c"
2747 3 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 3 3
2748 3 ST(0) = TARG;
2749 }
2750 3 XSRETURN(1);
2751 }
2752  
2753  
2754 XS_EUPXS(XS_Hyperman__abi_worker_hook_state); /* prototype to pass -Wmissing-prototypes */
2755 15 XS_EUPXS(XS_Hyperman__abi_worker_hook_state)
2756 {
2757 15 dVAR; dXSARGS;
2758 15 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 15 15
2759 0 croak_xs_usage(cv, "");
2760 PERL_UNUSED_VAR(ax); /* -Wall */
2761 15 ▶ SP -= items;
Branch: 1 branch
BranchTrueFalseTotal
SP -= items; 0 15 15
2762 {
2763 #line 48 "./xs/abi.xs"
2764 EXTEND(SP, 2);
2765 mPUSHi(HM_ABI_ST_WORKER_N);
2766 mPUSHi(HM_ABI_ST_WORKER_LOOP_OK);
2767 #line 2768 "Hyperman.c"
2768 15 PUTBACK;
2769 15 return;
2770 }
2771 }
2772  
2773  
2774 XS_EUPXS(XS_Hyperman__abi_stream_open); /* prototype to pass -Wmissing-prototypes */
2775 14 XS_EUPXS(XS_Hyperman__abi_stream_open)
2776 {
2777 14 dVAR; dXSARGS;
2778 14 ▶ if (items < 1 || items > 3)
Branch: 2 branches
BranchTrueFalseTotal
if (items < 1 || items > 3) 14 0 14
if (items < 1 || items > 3) 0 14 14
2779 0 croak_xs_usage(cv, "env, status = 200, headers = NULL");
2780 {
2781 14 SV * env = ST(0)
2782 ;
2783 int status;
2784 SV * headers;
2785 IV RETVAL;
2786 14 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 14 0 14
2787  
2788 14 ▶ if (items < 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) 0 14 14
2789 0 status = 200;
2790 else {
2791 14 status = (int)SvIV(ST(1))
2792 ;
2793 }
2794  
2795 14 ▶ if (items < 3)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 3) 0 14 14
2796 0 headers = NULL;
2797 else {
2798 14 headers = ST(2)
2799 ;
2800 }
2801 #line 64 "./xs/abi.xs"
2802 if (headers && !SvOK(headers)) headers = NULL;
2803 RETVAL = hm_abi_st_stream_open(aTHX_ env, status, headers);
2804 #line 2805 "Hyperman.c"
2805 14 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 14 14
2806 14 ST(0) = TARG;
2807 }
2808 14 XSRETURN(1);
2809 }
2810  
2811  
2812 XS_EUPXS(XS_Hyperman__abi_stream_write); /* prototype to pass -Wmissing-prototypes */
2813 18 XS_EUPXS(XS_Hyperman__abi_stream_write)
2814 {
2815 18 dVAR; dXSARGS;
2816 18 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 18 18
2817 0 croak_xs_usage(cv, "data");
2818 {
2819 18 SV * data = ST(0)
2820 ;
2821 IV RETVAL;
2822 18 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 18 0 18
2823 #line 77 "./xs/abi.xs"
2824 RETVAL = hm_abi_st_stream_write(aTHX_ data);
2825 #line 2826 "Hyperman.c"
2826 18 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 4 14 18
2827 18 ST(0) = TARG;
2828 }
2829 18 XSRETURN(1);
2830 }
2831  
2832  
2833 XS_EUPXS(XS_Hyperman__abi_stream_close); /* prototype to pass -Wmissing-prototypes */
2834 12 XS_EUPXS(XS_Hyperman__abi_stream_close)
2835 {
2836 12 dVAR; dXSARGS;
2837 12 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 12 12
2838 0 croak_xs_usage(cv, "");
2839 {
2840 IV RETVAL;
2841 12 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 12 0 12
2842 #line 84 "./xs/abi.xs"
2843 RETVAL = hm_abi_st_stream_close(aTHX);
2844 #line 2845 "Hyperman.c"
2845 12 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 5 7 12
2846 12 ST(0) = TARG;
2847 }
2848 12 XSRETURN(1);
2849 }
2850  
2851  
2852 XS_EUPXS(XS_Hyperman__abi_stream_close_trailers); /* prototype to pass -Wmissing-prototypes */
2853 0 XS_EUPXS(XS_Hyperman__abi_stream_close_trailers)
2854 {
2855 0 dVAR; dXSARGS;
2856 0 ▶ if (items < 0 || items > 1)
Branch: 2 branches
BranchTrueFalseTotal
if (items < 0 || items > 1) 0 0 0
if (items < 0 || items > 1) 0 0 0
2857 0 croak_xs_usage(cv, "trailers = &PL_sv_undef");
2858 {
2859 SV * trailers;
2860 IV RETVAL;
2861 0 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 0 0 0
2862  
2863 0 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 0 0
2864 0 trailers = &PL_sv_undef;
2865 else {
2866 0 trailers = ST(0)
2867 ;
2868 }
2869 #line 95 "./xs/abi.xs"
2870 RETVAL = hm_abi_st_stream_close_trailers(aTHX_ trailers);
2871 #line 2872 "Hyperman.c"
2872 0 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 0 0
2873 0 ST(0) = TARG;
2874 }
2875 0 XSRETURN(1);
2876 }
2877  
2878  
2879 XS_EUPXS(XS_Hyperman__abi_stream_abort); /* prototype to pass -Wmissing-prototypes */
2880 1 XS_EUPXS(XS_Hyperman__abi_stream_abort)
2881 {
2882 1 dVAR; dXSARGS;
2883 1 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 1 1
2884 0 croak_xs_usage(cv, "");
2885 {
2886 IV RETVAL;
2887 1 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 1 0 1
2888 #line 105 "./xs/abi.xs"
2889 RETVAL = hm_abi_st_stream_do_abort(aTHX);
2890 #line 2891 "Hyperman.c"
2891 1 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 1 1
2892 1 ST(0) = TARG;
2893 }
2894 1 XSRETURN(1);
2895 }
2896  
2897  
2898 XS_EUPXS(XS_Hyperman__abi_stream_read); /* prototype to pass -Wmissing-prototypes */
2899 9 XS_EUPXS(XS_Hyperman__abi_stream_read)
2900 {
2901 9 dVAR; dXSARGS;
2902 9 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 9 9
2903 0 croak_xs_usage(cv, "");
2904 {
2905 IV RETVAL;
2906 9 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 9 0 9
2907 #line 114 "./xs/abi.xs"
2908 RETVAL = hm_abi_st_stream_read(aTHX);
2909 #line 2910 "Hyperman.c"
2910 9 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 9 9
2911 9 ST(0) = TARG;
2912 }
2913 9 XSRETURN(1);
2914 }
2915  
2916  
2917 XS_EUPXS(XS_Hyperman__abi_stream_rx); /* prototype to pass -Wmissing-prototypes */
2918 9 XS_EUPXS(XS_Hyperman__abi_stream_rx)
2919 {
2920 9 dVAR; dXSARGS;
2921 9 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 9 9
2922 0 croak_xs_usage(cv, "");
2923 PERL_UNUSED_VAR(ax); /* -Wall */
2924 9 ▶ SP -= items;
Branch: 1 branch
BranchTrueFalseTotal
SP -= items; 0 9 9
2925 {
2926 #line 122 "./xs/abi.xs"
2927 EXTEND(SP, 3);
2928 mPUSHi(HM_ABI_ST_SH_RXN);
2929 mPUSHi(HM_ABI_ST_SH_RXLEN);
2930 mPUSHp(HM_ABI_ST_SH_RX, (STRLEN)HM_ABI_ST_SH_RXLEN);
2931 #line 2932 "Hyperman.c"
2932 9 PUTBACK;
2933 9 return;
2934 }
2935 }
2936  
2937  
2938 XS_EUPXS(XS_Hyperman__abi_stream_produce); /* prototype to pass -Wmissing-prototypes */
2939 1 XS_EUPXS(XS_Hyperman__abi_stream_produce)
2940 {
2941 1 dVAR; dXSARGS;
2942 1 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 1 1
2943 0 croak_xs_usage(cv, "n");
2944 {
2945 1 IV n = (IV)SvIV(ST(0))
2946 ;
2947 #line 135 "./xs/abi.xs"
2948 hm_abi_st_stream_produce(aTHX_ n);
2949 #line 2950 "Hyperman.c"
2950 }
2951 1 XSRETURN_EMPTY;
2952 }
2953  
2954  
2955 XS_EUPXS(XS_Hyperman__abi_stream_state); /* prototype to pass -Wmissing-prototypes */
2956 7 XS_EUPXS(XS_Hyperman__abi_stream_state)
2957 {
2958 7 dVAR; dXSARGS;
2959 7 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 7 7
2960 0 croak_xs_usage(cv, "");
2961 PERL_UNUSED_VAR(ax); /* -Wall */
2962 7 ▶ SP -= items;
Branch: 1 branch
BranchTrueFalseTotal
SP -= items; 0 7 7
2963 {
2964 #line 143 "./xs/abi.xs"
2965 EXTEND(SP, 5);
2966 mPUSHi(HM_ABI_ST_SH ? 1 : 0);
2967 mPUSHi(HM_ABI_ST_SH_ABORTS);
2968 mPUSHi(HM_ABI_ST_SH_DRAINS);
2969 mPUSHi(HM_ABI_ST_SH_WRITES);
2970 mPUSHi(HM_ABI_ST_SH_FULLS);
2971 #line 2972 "Hyperman.c"
2972 7 PUTBACK;
2973 7 return;
2974 }
2975 }
2976  
2977  
2978 /* INCLUDE: Returning to 'Hyperman.xs' from 'xs/abi.xs' */
2979  
2980  
2981 /* INCLUDE: Including 'xs/bus.xs' from 'Hyperman.xs' */
2982  
2983  
2984 XS_EUPXS(XS_Hyperman_bus_init); /* prototype to pass -Wmissing-prototypes */
2985 4 XS_EUPXS(XS_Hyperman_bus_init)
2986 {
2987 4 dVAR; dXSARGS;
2988 4 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 4 4
2989 0 croak_xs_usage(cv, "class, ...");
2990 {
2991 4 SV * class = ST(0)
2992 ;
2993 IV RETVAL;
2994 4 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 4 0 4
2995 #line 32 "./xs/bus.xs"
2996 {
2997 UV slots = 0, slot_size = 0, groups = 0, wakers = 0;
2998 int i, err = 0;
2999 PERL_UNUSED_VAR(class);
3000 for (i = 1; i + 1 < items; i += 2) {
3001 const char *k = SvPV_nolen(ST(i));
3002 if (strEQ(k, "slots")) slots = SvUV(ST(i + 1));
3003 else if (strEQ(k, "slot_size")) slot_size = SvUV(ST(i + 1));
3004 else if (strEQ(k, "groups")) groups = SvUV(ST(i + 1));
3005 else if (strEQ(k, "wakers")) wakers = SvUV(ST(i + 1));
3006 }
3007 PERL_UNUSED_VAR(groups);
3008 hm_sa_open(aTHX_ NULL, 0,
3009 hm_sa_bytes(0, 0, (unsigned)slots, (unsigned)slot_size));
3010 (void)hm_sa_bus_open((uint32_t)slots, (uint32_t)slot_size, &err);
3011 /* The wakeup descriptors go with the ring and for the same reason:
3012 * made before any fork, or a worker's poke reaches nobody. run()
3013 * sizes this from the worker count. */
3014 (void)hm_sa_bus_wake_init((uint32_t)(wakers ? wakers : 8));
3015 RETVAL = hm_sa_bus_live() ? 1 : 0; /* # uncoverable condition left count:1 class:ignore_covered_err */
3016 }
3017 #line 3018 "Hyperman.c"
3018 4 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 4 4
3019 4 ST(0) = TARG;
3020 }
3021 4 XSRETURN(1);
3022 }
3023  
3024  
3025 XS_EUPXS(XS_Hyperman_bus_live); /* prototype to pass -Wmissing-prototypes */
3026 1 XS_EUPXS(XS_Hyperman_bus_live)
3027 {
3028 1 dVAR; dXSARGS;
3029 1 ▶ if (items < 0 || items > 1)
Branch: 2 branches
BranchTrueFalseTotal
if (items < 0 || items > 1) 1 0 1
if (items < 0 || items > 1) 0 1 1
3030 0 croak_xs_usage(cv, "class = &PL_sv_undef");
3031 {
3032 SV * class;
3033 IV RETVAL;
3034 1 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 1 0 1
3035  
3036 1 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 1 1
3037 0 class = &PL_sv_undef;
3038 else {
3039 1 class = ST(0)
3040 ;
3041 }
3042 #line 68 "./xs/bus.xs"
3043 PERL_UNUSED_VAR(class);
3044 RETVAL = hm_sa_bus_live() ? 1 : 0; /* # uncoverable condition left count:1 class:ignore_covered_err */
3045 #line 3046 "Hyperman.c"
3046 1 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 1 1
3047 1 ST(0) = TARG;
3048 }
3049 1 XSRETURN(1);
3050 }
3051  
3052  
3053 XS_EUPXS(XS_Hyperman_publish); /* prototype to pass -Wmissing-prototypes */
3054 21503 XS_EUPXS(XS_Hyperman_publish)
3055 {
3056 21503 dVAR; dXSARGS;
3057 21503 ▶ if (items != 3)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 3) 0 21503 21503
3058 0 croak_xs_usage(cv, "class, topic, payload");
3059 {
3060 21503 SV * class = ST(0)
3061 ;
3062 21503 SV * topic = ST(1)
3063 ;
3064 21503 SV * payload = ST(2)
3065 ;
3066 IV RETVAL;
3067 21503 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 21503 0 21503
3068 #line 93 "./xs/bus.xs"
3069 {
3070 STRLEN tl, pl;
3071 const char *t = SvPV_const(topic, tl);
3072 const char *p = SvPV_const(payload, pl);
3073 int r = hm_sa_bus_publish(t, (uint32_t)tl, p, (uint32_t)pl);
3074 PERL_UNUSED_VAR(class);
3075 RETVAL = (r == HM_BUS_OK) ? 1 : (r == HM_BUS_LOCAL) ? 0 : -1; /* # uncoverable condition left count:2 class:ignore_covered_err */
3076 }
3077 #line 3078 "Hyperman.c"
3078 21503 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 21474 29 21503
3079 21503 ST(0) = TARG;
3080 }
3081 21503 XSRETURN(1);
3082 }
3083  
3084  
3085 XS_EUPXS(XS_Hyperman_bus_reset); /* prototype to pass -Wmissing-prototypes */
3086 5 XS_EUPXS(XS_Hyperman_bus_reset)
3087 {
3088 5 dVAR; dXSARGS;
3089 5 ▶ if (items < 0 || items > 1)
Branch: 2 branches
BranchTrueFalseTotal
if (items < 0 || items > 1) 5 0 5
if (items < 0 || items > 1) 0 5 5
3090 0 croak_xs_usage(cv, "class = &PL_sv_undef");
3091 {
3092 SV * class;
3093 IV RETVAL;
3094 5 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 5 0 5
3095  
3096 5 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 5 5
3097 0 class = &PL_sv_undef;
3098 else {
3099 5 class = ST(0)
3100 ;
3101 }
3102 #line 119 "./xs/bus.xs"
3103 PERL_UNUSED_VAR(class);
3104 hm_sa_bus_reset_cursors();
3105 RETVAL = (IV)hm_sa_bus_seq();
3106 #line 3107 "Hyperman.c"
3107 5 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 5 5
3108 5 ST(0) = TARG;
3109 }
3110 5 XSRETURN(1);
3111 }
3112  
3113  
3114 XS_EUPXS(XS_Hyperman_receive); /* prototype to pass -Wmissing-prototypes */
3115 6 XS_EUPXS(XS_Hyperman_receive)
3116 {
3117 6 dVAR; dXSARGS;
3118 6 ▶ if (items < 0 || items > 1)
Branch: 2 branches
BranchTrueFalseTotal
if (items < 0 || items > 1) 6 0 6
if (items < 0 || items > 1) 0 6 6
3119 0 croak_xs_usage(cv, "class = &PL_sv_undef");
3120 PERL_UNUSED_VAR(ax); /* -Wall */
3121 6 SP -= items;
3122 {
3123 SV * class;
3124  
3125 6 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 6 6
3126 0 class = &PL_sv_undef;
3127 else {
3128 6 class = ST(0)
3129 ;
3130 }
3131 #line 136 "./xs/bus.xs"
3132 {
3133 AV *out = (AV *)sv_2mortal((SV *)newAV());
3134 SSize_t i, n;
3135 PERL_UNUSED_VAR(class);
3136 (void)hm_sa_bus_drain(&hm_sa_recv_cur, hm_bus_perl_collect, out);
3137 n = av_len(out) + 1;
3138 EXTEND(SP, n);
3139 for (i = 0; i < n; i++) {
3140 SV **e = av_fetch(out, i, 0);
3141 PUSHs(e && *e ? sv_2mortal(newSVsv(*e)) : &PL_sv_undef);
3142 }
3143 }
3144 #line 3145 "Hyperman.c"
3145 6 PUTBACK;
3146 6 return;
3147 }
3148 }
3149  
3150  
3151 XS_EUPXS(XS_Hyperman_bus_gaps); /* prototype to pass -Wmissing-prototypes */
3152 3 XS_EUPXS(XS_Hyperman_bus_gaps)
3153 {
3154 3 dVAR; dXSARGS;
3155 3 ▶ if (items < 0 || items > 1)
Branch: 2 branches
BranchTrueFalseTotal
if (items < 0 || items > 1) 3 0 3
if (items < 0 || items > 1) 0 3 3
3156 0 croak_xs_usage(cv, "class = &PL_sv_undef");
3157 {
3158 SV * class;
3159 IV RETVAL;
3160 3 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 3 0 3
3161  
3162 3 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 3 3
3163 0 class = &PL_sv_undef;
3164 else {
3165 3 class = ST(0)
3166 ;
3167 }
3168 #line 169 "./xs/bus.xs"
3169 PERL_UNUSED_VAR(class);
3170 RETVAL = (IV)(hm_sa_bus_gaps_of(hm_sa_recv_cur)
3171 + hm_sa_bus_gaps_of(hm_sa_disp_cur));
3172 #line 3173 "Hyperman.c"
3173 3 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 3 3
3174 3 ST(0) = TARG;
3175 }
3176 3 XSRETURN(1);
3177 }
3178  
3179  
3180 XS_EUPXS(XS_Hyperman_claim); /* prototype to pass -Wmissing-prototypes */
3181 7 XS_EUPXS(XS_Hyperman_claim)
3182 {
3183 7 dVAR; dXSARGS;
3184 7 ▶ if (items < 2 || items > 3)
Branch: 2 branches
BranchTrueFalseTotal
if (items < 2 || items > 3) 7 0 7
if (items < 2 || items > 3) 0 7 7
3185 0 croak_xs_usage(cv, "class, topic, group = &PL_sv_undef");
3186 PERL_UNUSED_VAR(ax); /* -Wall */
3187 7 SP -= items;
3188 {
3189 7 SV * class = ST(0)
3190 ;
3191 7 SV * topic = ST(1)
3192 ;
3193 SV * group;
3194  
3195 7 ▶ if (items < 3)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 3) 0 7 7
3196 0 group = &PL_sv_undef;
3197 else {
3198 7 group = ST(2)
3199 ;
3200 }
3201 #line 202 "./xs/bus.xs"
3202 {
3203 AV *out = (AV *)sv_2mortal((SV *)newAV());
3204 STRLEN tl, gl;
3205 const char *t = SvPV_const(topic, tl);
3206 const char *g = SvOK(group) ? SvPV_const(group, gl) : (gl = tl, t); /* # uncoverable condition right count:1 class:ignore_covered_err */
3207 sa_group_h *gh = hm_sa_bus_group(t, (uint32_t)tl, g, (uint32_t)gl);
3208 SSize_t i, n;
3209 PERL_UNUSED_VAR(class);
3210 if (!gh) XSRETURN_EMPTY; /* no ring, or the table is full */
3211 (void)hm_sa_bus_claim(gh, hm_bus_perl_collect, out);
3212 n = av_len(out) + 1;
3213 EXTEND(SP, n);
3214 for (i = 0; i < n; i++) {
3215 SV **e = av_fetch(out, i, 0);
3216 PUSHs(e && *e ? sv_2mortal(newSVsv(*e)) : &PL_sv_undef);
3217 }
3218 }
3219 #line 3220 "Hyperman.c"
3220 7 PUTBACK;
3221 7 return;
3222 }
3223 }
3224  
3225  
3226 XS_EUPXS(XS_Hyperman_subscribe); /* prototype to pass -Wmissing-prototypes */
3227 10 XS_EUPXS(XS_Hyperman_subscribe)
3228 {
3229 10 dVAR; dXSARGS;
3230 10 ▶ if (items < 3)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 3) 0 10 10
3231 0 croak_xs_usage(cv, "class, topic, cb, ...");
3232 {
3233 10 SV * class = ST(0)
3234 ;
3235 10 SV * topic = ST(1)
3236 ;
3237 10 SV * cb = ST(2)
3238 ;
3239 IV RETVAL;
3240 10 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 10 0 10
3241 #line 245 "./xs/bus.xs"
3242 {
3243 STRLEN tl, gl = 0;
3244 const char *t = SvPV_const(topic, tl);
3245 const char *g = NULL;
3246 int i, id;
3247 PERL_UNUSED_VAR(class);
3248 if (!(SvROK(cb) && SvTYPE(SvRV(cb)) == SVt_PVCV)) /* # uncoverable condition left count:2 class:ignore_covered_err */
3249 croak("Hyperman->subscribe: need a code reference");
3250 for (i = 3; i + 1 < items; i += 2) {
3251 const char *k = SvPV_nolen(ST(i));
3252 if (strEQ(k, "group") && SvOK(ST(i + 1)))
3253 g = SvPV_const(ST(i + 1), gl);
3254 }
3255 id = hm_sa_bus_subscribe(t, (uint32_t)tl, g, (uint32_t)gl,
3256 hm_bus_perl_deliver, NULL);
3257 if (id < 0) XSRETURN_IV(-1);
3258 if (hm_bus_perl_subs[id]) SvREFCNT_dec(hm_bus_perl_subs[id]);
3259 hm_bus_perl_subs[id] = newSVsv(cb);
3260 hm_bus_subs[id].ud = (void *)hm_bus_perl_subs[id];
3261 RETVAL = id;
3262 }
3263 #line 3264 "Hyperman.c"
3264 9 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 9 9
3265 9 ST(0) = TARG;
3266 }
3267 9 XSRETURN(1);
3268 }
3269  
3270  
3271 XS_EUPXS(XS_Hyperman_unsubscribe); /* prototype to pass -Wmissing-prototypes */
3272 6 XS_EUPXS(XS_Hyperman_unsubscribe)
3273 {
3274 6 dVAR; dXSARGS;
3275 6 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 6 6
3276 0 croak_xs_usage(cv, "class, id");
3277 {
3278 6 SV * class = ST(0)
3279 ;
3280 6 IV id = (IV)SvIV(ST(1))
3281 ;
3282 IV RETVAL;
3283 6 ▶ dXSTARG;
Branch: 2 branches
BranchTrueFalseTotal
dXSTARG; 6 0 6
dXSTARG; 6 0 6
3284 #line 282 "./xs/bus.xs"
3285 {
3286 PERL_UNUSED_VAR(class);
3287 if (id >= 0 && id < HM_BUS_SUBS && hm_bus_perl_subs[id]) {
3288 SvREFCNT_dec(hm_bus_perl_subs[id]);
3289 hm_bus_perl_subs[id] = NULL;
3290 }
3291 RETVAL = hm_sa_bus_unsubscribe((int)id);
3292 }
3293 #line 3294 "Hyperman.c"
3294 6 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 2 4 6
3295 6 ST(0) = TARG;
3296 }
3297 6 XSRETURN(1);
3298 }
3299  
3300  
3301 XS_EUPXS(XS_Hyperman_dispatch); /* prototype to pass -Wmissing-prototypes */
3302 6 XS_EUPXS(XS_Hyperman_dispatch)
3303 {
3304 6 dVAR; dXSARGS;
3305 6 ▶ if (items < 0 || items > 1)
Branch: 2 branches
BranchTrueFalseTotal
if (items < 0 || items > 1) 6 0 6
if (items < 0 || items > 1) 0 6 6
3306 0 croak_xs_usage(cv, "class = &PL_sv_undef");
3307 {
3308 SV * class;
3309 IV RETVAL;
3310 6 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 6 0 6
3311  
3312 6 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 6 6
3313 0 class = &PL_sv_undef;
3314 else {
3315 6 class = ST(0)
3316 ;
3317 }
3318 #line 307 "./xs/bus.xs"
3319 PERL_UNUSED_VAR(class);
3320 RETVAL = (IV)hm_sa_bus_dispatch();
3321 #line 3322 "Hyperman.c"
3322 6 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 6 6
3323 6 ST(0) = TARG;
3324 }
3325 6 XSRETURN(1);
3326 }
3327  
3328  
3329 XS_EUPXS(XS_Hyperman_bus_waker_take); /* prototype to pass -Wmissing-prototypes */
3330 1 XS_EUPXS(XS_Hyperman_bus_waker_take)
3331 {
3332 1 dVAR; dXSARGS;
3333 1 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 1 1
3334 0 croak_xs_usage(cv, "class, idx");
3335 {
3336 1 SV * class = ST(0)
3337 ;
3338 1 IV idx = (IV)SvIV(ST(1))
3339 ;
3340 IV RETVAL;
3341 1 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 1 0 1
3342 #line 323 "./xs/bus.xs"
3343 PERL_UNUSED_VAR(class);
3344 RETVAL = hm_sa_bus_waker_take((int)idx);
3345 #line 3346 "Hyperman.c"
3346 1 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 1 1
3347 1 ST(0) = TARG;
3348 }
3349 1 XSRETURN(1);
3350 }
3351  
3352  
3353 XS_EUPXS(XS_Hyperman_bus_waker_drained); /* prototype to pass -Wmissing-prototypes */
3354 1 XS_EUPXS(XS_Hyperman_bus_waker_drained)
3355 {
3356 1 dVAR; dXSARGS;
3357 1 ▶ if (items < 0 || items > 1)
Branch: 2 branches
BranchTrueFalseTotal
if (items < 0 || items > 1) 1 0 1
if (items < 0 || items > 1) 0 1 1
3358 0 croak_xs_usage(cv, "class = &PL_sv_undef");
3359 {
3360 SV * class;
3361  
3362 1 ▶ if (items < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 1) 0 1 1
3363 0 class = &PL_sv_undef;
3364 else {
3365 1 class = ST(0)
3366 ;
3367 }
3368 #line 335 "./xs/bus.xs"
3369 PERL_UNUSED_VAR(class);
3370 hm_sa_bus_waker_drained();
3371 #line 3372 "Hyperman.c"
3372 }
3373 1 XSRETURN_EMPTY;
3374 }
3375  
3376  
3377 XS_EUPXS(XS_Hyperman_bus_stats); /* prototype to pass -Wmissing-prototypes */
3378 5 XS_EUPXS(XS_Hyperman_bus_stats)
3379 {
3380 5 dVAR; dXSARGS;
3381 5 ▶ if (items < 1 || items > 2)
Branch: 2 branches
BranchTrueFalseTotal
if (items < 1 || items > 2) 5 0 5
if (items < 1 || items > 2) 0 5 5
3382 0 croak_xs_usage(cv, "class, group = &PL_sv_undef");
3383 PERL_UNUSED_VAR(ax); /* -Wall */
3384 5 SP -= items;
3385 {
3386 5 SV * class = ST(0)
3387 ;
3388 SV * group;
3389  
3390 5 ▶ if (items < 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) 2 3 5
3391 2 group = &PL_sv_undef;
3392 else {
3393 3 group = ST(1)
3394 ;
3395 }
3396 #line 349 "./xs/bus.xs"
3397 {
3398 PERL_UNUSED_VAR(class);
3399 EXTEND(SP, 6);
3400 mPUSHp("published", 9); mPUSHu((UV)hm_sa_bus_published());
3401 /* Both cursors, for the reason bus_gaps says. */
3402 mPUSHp("gaps", 4); mPUSHu((UV)(hm_sa_bus_gaps_of(hm_sa_recv_cur)
3403 + hm_sa_bus_gaps_of(hm_sa_disp_cur)));
3404 if (SvOK(group)) {
3405 STRLEN gl;
3406 const char *g = SvPV_const(group, gl);
3407 sa_group_h *gh = hm_sa_bus_group(g, (uint32_t)gl, g, (uint32_t)gl);
3408 mPUSHp("group_gaps", 10);
3409 mPUSHu(gh ? (UV)hm_sa_bus_group_gaps(gh) : 0); /* # uncoverable condition right count:1 class:ignore_covered_err */
3410 }
3411 }
3412 #line 3413 "Hyperman.c"
3413 5 PUTBACK;
3414 5 return;
3415 }
3416 }
3417  
3418  
3419 /* INCLUDE: Returning to 'Hyperman.xs' from 'xs/bus.xs' */
3420  
3421  
3422 /* INCLUDE: Including 'xs/quic.xs' from 'Hyperman.xs' */
3423  
3424  
3425 XS_EUPXS(XS_Hyperman__quic_cid_selftest); /* prototype to pass -Wmissing-prototypes */
3426 0 XS_EUPXS(XS_Hyperman__quic_cid_selftest)
3427 {
3428 0 dVAR; dXSARGS;
3429 0 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 0 0
3430 0 croak_xs_usage(cv, "");
3431 {
3432 IV RETVAL;
3433 0 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 0 0 0
3434 #line 18 "./xs/quic.xs"
3435 RETVAL = hm_quic_cid_selftest(); /* # uncoverable statement class:ignore_covered_err */
3436 #line 3437 "Hyperman.c"
3437 0 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 0 0
3438 0 ST(0) = TARG;
3439 }
3440 0 XSRETURN(1);
3441 }
3442  
3443  
3444 XS_EUPXS(XS_Hyperman__quic_heap_selftest); /* prototype to pass -Wmissing-prototypes */
3445 0 XS_EUPXS(XS_Hyperman__quic_heap_selftest)
3446 {
3447 0 dVAR; dXSARGS;
3448 0 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 0 0
3449 0 croak_xs_usage(cv, "");
3450 {
3451 IV RETVAL;
3452 0 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 0 0 0
3453 #line 32 "./xs/quic.xs"
3454 RETVAL = hm_quic_heap_selftest(); /* # uncoverable statement class:ignore_covered_err */
3455 #line 3456 "Hyperman.c"
3456 0 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 0 0
3457 0 ST(0) = TARG;
3458 }
3459 0 XSRETURN(1);
3460 }
3461  
3462  
3463 XS_EUPXS(XS_Hyperman__quic_src_selftest); /* prototype to pass -Wmissing-prototypes */
3464 0 XS_EUPXS(XS_Hyperman__quic_src_selftest)
3465 {
3466 0 dVAR; dXSARGS;
3467 0 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 0 0
3468 0 croak_xs_usage(cv, "");
3469 {
3470 IV RETVAL;
3471 0 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 0 0 0
3472 #line 43 "./xs/quic.xs"
3473 RETVAL = hm_quic_src_selftest(); /* # uncoverable statement class:ignore_covered_err */
3474 #line 3475 "Hyperman.c"
3475 0 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 0 0
3476 0 ST(0) = TARG;
3477 }
3478 0 XSRETURN(1);
3479 }
3480  
3481  
3482 XS_EUPXS(XS_Hyperman__quic_token_selftest); /* prototype to pass -Wmissing-prototypes */
3483 0 XS_EUPXS(XS_Hyperman__quic_token_selftest)
3484 {
3485 0 dVAR; dXSARGS;
3486 0 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 0 0
3487 0 croak_xs_usage(cv, "");
3488 {
3489 IV RETVAL;
3490 0 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 0 0 0
3491 #line 55 "./xs/quic.xs"
3492 RETVAL = hm_quic_token_selftest(); /* # uncoverable statement class:ignore_covered_err */
3493 #line 3494 "Hyperman.c"
3494 0 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 0 0
3495 0 ST(0) = TARG;
3496 }
3497 0 XSRETURN(1);
3498 }
3499  
3500  
3501 XS_EUPXS(XS_Hyperman__quic_decode_selftest); /* prototype to pass -Wmissing-prototypes */
3502 0 XS_EUPXS(XS_Hyperman__quic_decode_selftest)
3503 {
3504 0 dVAR; dXSARGS;
3505 0 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 0 0
3506 0 croak_xs_usage(cv, "pkt");
3507 PERL_UNUSED_VAR(ax); /* -Wall */
3508 0 SP -= items;
3509 {
3510 0 SV * pkt = ST(0)
3511 ;
3512 #line 69 "./xs/quic.xs"
3513 STRLEN len;
3514 const unsigned char *p;
3515 int rv = -1; /* # uncoverable statement class:ignore_covered_err */
3516 uint32_t ver = 0; /* # uncoverable statement class:ignore_covered_err */
3517 size_t dlen = 0, slen = 0; /* # uncoverable statement class:ignore_covered_err */
3518 #line 3519 "Hyperman.c"
3519 #line 75 "./xs/quic.xs"
3520 p = (const unsigned char *)SvPV(pkt, len); /* # uncoverable statement class:ignore_covered_err */
3521 hm_quic_decode_probe(p, (size_t)len, &rv, &ver, &dlen, &slen); /* # uncoverable statement class:ignore_covered_err */
3522 EXTEND(SP, 4); /* # uncoverable statement class:ignore_covered_err */
3523 mPUSHi(rv); /* # uncoverable statement class:ignore_covered_err */
3524 mPUSHu(ver); /* # uncoverable statement class:ignore_covered_err */
3525 mPUSHu((UV)dlen); /* # uncoverable statement class:ignore_covered_err */
3526 mPUSHu((UV)slen); /* # uncoverable statement class:ignore_covered_err */
3527 #line 3528 "Hyperman.c"
3528 0 PUTBACK;
3529 0 return;
3530 }
3531 }
3532  
3533  
3534 /* INCLUDE: Returning to 'Hyperman.xs' from 'xs/quic.xs' */
3535  
3536 #ifdef __cplusplus
3537 extern "C" {
3538 #endif
3539 XS_EXTERNAL(boot_Hyperman); /* prototype to pass -Wmissing-prototypes */
3540 149 XS_EXTERNAL(boot_Hyperman)
3541 {
3542 #if PERL_VERSION_LE(5, 21, 5)
3543 dVAR; dXSARGS;
3544 #else
3545 149 dVAR; dXSBOOTARGSXSAPIVERCHK;
3546 #endif
3547 #if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
3548 char* file = __FILE__;
3549 #else
3550 149 const char* file = __FILE__;
3551 #endif
3552  
3553 PERL_UNUSED_VAR(file);
3554  
3555 PERL_UNUSED_VAR(cv); /* -W */
3556 PERL_UNUSED_VAR(items); /* -W */
3557 #if PERL_VERSION_LE(5, 21, 5)
3558 XS_VERSION_BOOTCHECK;
3559 # ifdef XS_APIVERSION_BOOTCHECK
3560 XS_APIVERSION_BOOTCHECK;
3561 # endif
3562 #endif
3563  
3564 {
3565 CV * cv;
3566  
3567 149 newXS_deffile("Hyperman::run", XS_Hyperman_run);
3568 149 newXS_deffile("Hyperman::timer", XS_Hyperman_timer);
3569 149 newXS_deffile("Hyperman::io_ready", XS_Hyperman_io_ready);
3570 149 newXS_deffile("Hyperman::stats", XS_Hyperman_stats);
3571 149 newXS_deffile("Hyperman::has_http2", XS_Hyperman_has_http2);
3572 149 newXS_deffile("Hyperman::has_http3", XS_Hyperman_has_http3);
3573 149 newXS_deffile("Hyperman::quic_library", XS_Hyperman_quic_library);
3574 149 newXS_deffile("Hyperman::_accepts_gzip", XS_Hyperman__accepts_gzip);
3575 149 newXS_deffile("Hyperman::_gzip", XS_Hyperman__gzip);
3576 149 newXS_deffile("Hyperman::has_compression", XS_Hyperman_has_compression);
3577 149 newXS_deffile("Hyperman::has_tls", XS_Hyperman_has_tls);
3578 149 newXS_deffile("Hyperman::has_ktls", XS_Hyperman_has_ktls);
3579 149 newXS_deffile("Hyperman::tls_library", XS_Hyperman_tls_library);
3580 149 newXS_deffile("Hyperman::tls_reload", XS_Hyperman_tls_reload);
3581 149 newXS_deffile("Hyperman::loop", XS_Hyperman_loop);
3582 149 newXS_deffile("Hyperman::detach", XS_Hyperman_detach);
3583 149 newXS_deffile("Hyperman::stream", XS_Hyperman_stream);
3584 149 newXS_deffile("Hyperman::deny_add", XS_Hyperman_deny_add);
3585 149 newXS_deffile("Hyperman::deny_remove", XS_Hyperman_deny_remove);
3586 149 newXS_deffile("Hyperman::pool_stats", XS_Hyperman_pool_stats);
3587 149 newXS_deffile("Hyperman::leader", XS_Hyperman_leader);
3588 149 newXS_deffile("Hyperman::distinct_clients", XS_Hyperman_distinct_clients);
3589 149 newXS_deffile("Hyperman::arena", XS_Hyperman_arena);
3590 149 newXS_deffile("Hyperman::deny_check", XS_Hyperman_deny_check);
3591 149 newXS_deffile("Hyperman::ratelimit_hit", XS_Hyperman_ratelimit_hit);
3592 149 newXS_deffile("Hyperman::on_worker_start", XS_Hyperman_on_worker_start);
3593 149 newXS_deffile("Hyperman::_proxy_selftest", XS_Hyperman__proxy_selftest);
3594 149 newXS_deffile("Hyperman::_croak_sv_selftest", XS_Hyperman__croak_sv_selftest);
3595 149 newXS_deffile("Hyperman::Future::new", XS_Hyperman__Future_new);
3596 149 cv = newXS_deffile("Hyperman::Future::AWAIT_DONE", XS_Hyperman__Future_done);
3597 149 XSANY.any_i32 = 1;
3598 149 cv = newXS_deffile("Hyperman::Future::done", XS_Hyperman__Future_done);
3599 149 XSANY.any_i32 = 0;
3600 149 cv = newXS_deffile("Hyperman::Future::AWAIT_FAIL", XS_Hyperman__Future_fail);
3601 149 XSANY.any_i32 = 1;
3602 149 cv = newXS_deffile("Hyperman::Future::fail", XS_Hyperman__Future_fail);
3603 149 XSANY.any_i32 = 0;
3604 149 cv = newXS_deffile("Hyperman::Future::AWAIT_NEW_DONE", XS_Hyperman__Future_done_future);
3605 149 XSANY.any_i32 = 1;
3606 149 cv = newXS_deffile("Hyperman::Future::done_future", XS_Hyperman__Future_done_future);
3607 149 XSANY.any_i32 = 0;
3608 149 cv = newXS_deffile("Hyperman::Future::AWAIT_NEW_FAIL", XS_Hyperman__Future_fail_future);
3609 149 XSANY.any_i32 = 1;
3610 149 cv = newXS_deffile("Hyperman::Future::fail_future", XS_Hyperman__Future_fail_future);
3611 149 XSANY.any_i32 = 0;
3612 149 newXS_deffile("Hyperman::Future::cancel", XS_Hyperman__Future_cancel);
3613 149 cv = newXS_deffile("Hyperman::Future::AWAIT_IS_READY", XS_Hyperman__Future_is_ready);
3614 149 XSANY.any_i32 = 1;
3615 149 cv = newXS_deffile("Hyperman::Future::is_ready", XS_Hyperman__Future_is_ready);
3616 149 XSANY.any_i32 = 0;
3617 149 newXS_deffile("Hyperman::Future::is_done", XS_Hyperman__Future_is_done);
3618 149 newXS_deffile("Hyperman::Future::is_failed", XS_Hyperman__Future_is_failed);
3619 149 cv = newXS_deffile("Hyperman::Future::AWAIT_IS_CANCELLED", XS_Hyperman__Future_is_cancelled);
3620 149 XSANY.any_i32 = 1;
3621 149 cv = newXS_deffile("Hyperman::Future::is_cancelled", XS_Hyperman__Future_is_cancelled);
3622 149 XSANY.any_i32 = 0;
3623 149 newXS_deffile("Hyperman::Future::AWAIT_CLONE", XS_Hyperman__Future_AWAIT_CLONE);
3624 149 cv = newXS_deffile("Hyperman::Future::AWAIT_ON_READY", XS_Hyperman__Future_on_ready);
3625 149 XSANY.any_i32 = 1;
3626 149 cv = newXS_deffile("Hyperman::Future::on_ready", XS_Hyperman__Future_on_ready);
3627 149 XSANY.any_i32 = 0;
3628 149 cv = newXS_deffile("Hyperman::Future::AWAIT_CHAIN_CANCEL", XS_Hyperman__Future_on_cancel);
3629 149 XSANY.any_i32 = 2;
3630 149 cv = newXS_deffile("Hyperman::Future::AWAIT_ON_CANCEL", XS_Hyperman__Future_on_cancel);
3631 149 XSANY.any_i32 = 1;
3632 149 cv = newXS_deffile("Hyperman::Future::on_cancel", XS_Hyperman__Future_on_cancel);
3633 149 XSANY.any_i32 = 0;
3634 149 cv = newXS_deffile("Hyperman::Future::on_done", XS_Hyperman__Future_on_done);
3635 149 XSANY.any_i32 = 0;
3636 149 cv = newXS_deffile("Hyperman::Future::on_fail", XS_Hyperman__Future_on_done);
3637 149 XSANY.any_i32 = 1;
3638 149 newXS_deffile("Hyperman::Future::await", XS_Hyperman__Future_await);
3639 149 cv = newXS_deffile("Hyperman::Future::AWAIT_GET", XS_Hyperman__Future_get);
3640 149 XSANY.any_i32 = 3;
3641 149 cv = newXS_deffile("Hyperman::Future::AWAIT_WAIT", XS_Hyperman__Future_get);
3642 149 XSANY.any_i32 = 2;
3643 149 cv = newXS_deffile("Hyperman::Future::get", XS_Hyperman__Future_get);
3644 149 XSANY.any_i32 = 0;
3645 149 cv = newXS_deffile("Hyperman::Future::result", XS_Hyperman__Future_get);
3646 149 XSANY.any_i32 = 1;
3647 149 newXS_deffile("Hyperman::Future::failure", XS_Hyperman__Future_failure);
3648 149 newXS_deffile("Hyperman::Future::_values", XS_Hyperman__Future__values);
3649 149 cv = newXS_deffile("Hyperman::Future::else", XS_Hyperman__Future_then);
3650 149 XSANY.any_i32 = 1;
3651 149 cv = newXS_deffile("Hyperman::Future::then", XS_Hyperman__Future_then);
3652 149 XSANY.any_i32 = 0;
3653 149 newXS_deffile("Hyperman::Future::followed_by", XS_Hyperman__Future_followed_by);
3654 149 newXS_deffile("Hyperman::Future::transform", XS_Hyperman__Future_transform);
3655 149 newXS_deffile("Hyperman::Future::_set_upstream", XS_Hyperman__Future__set_upstream);
3656 149 cv = newXS_deffile("Hyperman::Future::needs_all", XS_Hyperman__Future_wait_all);
3657 149 XSANY.any_i32 = 2;
3658 149 cv = newXS_deffile("Hyperman::Future::needs_any", XS_Hyperman__Future_wait_all);
3659 149 XSANY.any_i32 = 3;
3660 149 cv = newXS_deffile("Hyperman::Future::wait_all", XS_Hyperman__Future_wait_all);
3661 149 XSANY.any_i32 = 0;
3662 149 cv = newXS_deffile("Hyperman::Future::wait_any", XS_Hyperman__Future_wait_all);
3663 149 XSANY.any_i32 = 1;
3664 149 newXS_deffile("Hyperman::Future::as_cpan_future", XS_Hyperman__Future_as_cpan_future);
3665 149 newXS_deffile("Hyperman::Future::from_future", XS_Hyperman__Future_from_future);
3666 149 newXS_deffile("Hyperman::Loop::new", XS_Hyperman__Loop_new);
3667 149 newXS_deffile("Hyperman::Loop::run", XS_Hyperman__Loop_run);
3668 149 newXS_deffile("Hyperman::Loop::run_until", XS_Hyperman__Loop_run_until);
3669 149 newXS_deffile("Hyperman::Loop::stop", XS_Hyperman__Loop_stop);
3670 149 newXS_deffile("Hyperman::Loop::watch_io", XS_Hyperman__Loop_watch_io);
3671 149 newXS_deffile("Hyperman::Loop::unwatch_io", XS_Hyperman__Loop_unwatch_io);
3672 149 newXS_deffile("Hyperman::Loop::timer", XS_Hyperman__Loop_timer);
3673 149 newXS_deffile("Hyperman::Loop::timer_f", XS_Hyperman__Loop_timer_f);
3674 149 cv = newXS_deffile("Hyperman::Loop::readable_f", XS_Hyperman__Loop_readable_f);
3675 149 XSANY.any_i32 = 0;
3676 149 cv = newXS_deffile("Hyperman::Loop::writable_f", XS_Hyperman__Loop_readable_f);
3677 149 XSANY.any_i32 = 1;
3678 149 newXS_deffile("Hyperman::Loop::defer", XS_Hyperman__Loop_defer);
3679 149 newXS_deffile("Hyperman::Loop::install_await", XS_Hyperman__Loop_install_await);
3680 149 newXS_deffile("Hyperman::Loop::backend", XS_Hyperman__Loop_backend);
3681 149 newXS_deffile("Hyperman::Loop::DESTROY", XS_Hyperman__Loop_DESTROY);
3682 149 newXS_deffile("Hyperman::Writer::write", XS_Hyperman__Writer_write);
3683 149 newXS_deffile("Hyperman::Writer::DESTROY", XS_Hyperman__Writer_DESTROY);
3684 149 newXS_deffile("Hyperman::Writer::close", XS_Hyperman__Writer_close);
3685 149 newXS_deffile("Hyperman::Writer::abort", XS_Hyperman__Writer_abort);
3686 149 newXS_deffile("Hyperman::Event::Kqueue::available", XS_Hyperman__Event__Kqueue_available);
3687 149 newXS_deffile("Hyperman::Event::Epoll::available", XS_Hyperman__Event__Epoll_available);
3688 149 newXS_deffile("Hyperman::Event::Poll::available", XS_Hyperman__Event__Poll_available);
3689 149 newXS_deffile("Hyperman::Event::IOUring::available", XS_Hyperman__Event__IOUring_available);
3690 149 newXS_deffile("Hyperman::_abi_ptr", XS_Hyperman__abi_ptr);
3691 149 newXS_deffile("Hyperman::_abi_selftest", XS_Hyperman__abi_selftest);
3692 149 newXS_deffile("Hyperman::_abi_version", XS_Hyperman__abi_version);
3693 149 newXS_deffile("Hyperman::_abi_worker_hook_install", XS_Hyperman__abi_worker_hook_install);
3694 149 newXS_deffile("Hyperman::_abi_worker_hook_state", XS_Hyperman__abi_worker_hook_state);
3695 149 newXS_deffile("Hyperman::_abi_stream_open", XS_Hyperman__abi_stream_open);
3696 149 newXS_deffile("Hyperman::_abi_stream_write", XS_Hyperman__abi_stream_write);
3697 149 newXS_deffile("Hyperman::_abi_stream_close", XS_Hyperman__abi_stream_close);
3698 149 newXS_deffile("Hyperman::_abi_stream_close_trailers", XS_Hyperman__abi_stream_close_trailers);
3699 149 newXS_deffile("Hyperman::_abi_stream_abort", XS_Hyperman__abi_stream_abort);
3700 149 newXS_deffile("Hyperman::_abi_stream_read", XS_Hyperman__abi_stream_read);
3701 149 newXS_deffile("Hyperman::_abi_stream_rx", XS_Hyperman__abi_stream_rx);
3702 149 newXS_deffile("Hyperman::_abi_stream_produce", XS_Hyperman__abi_stream_produce);
3703 149 newXS_deffile("Hyperman::_abi_stream_state", XS_Hyperman__abi_stream_state);
3704 149 newXS_deffile("Hyperman::bus_init", XS_Hyperman_bus_init);
3705 149 newXS_deffile("Hyperman::bus_live", XS_Hyperman_bus_live);
3706 149 newXS_deffile("Hyperman::publish", XS_Hyperman_publish);
3707 149 newXS_deffile("Hyperman::bus_reset", XS_Hyperman_bus_reset);
3708 149 newXS_deffile("Hyperman::receive", XS_Hyperman_receive);
3709 149 newXS_deffile("Hyperman::bus_gaps", XS_Hyperman_bus_gaps);
3710 149 newXS_deffile("Hyperman::claim", XS_Hyperman_claim);
3711 149 newXS_deffile("Hyperman::subscribe", XS_Hyperman_subscribe);
3712 149 newXS_deffile("Hyperman::unsubscribe", XS_Hyperman_unsubscribe);
3713 149 newXS_deffile("Hyperman::dispatch", XS_Hyperman_dispatch);
3714 149 newXS_deffile("Hyperman::bus_waker_take", XS_Hyperman_bus_waker_take);
3715 149 newXS_deffile("Hyperman::bus_waker_drained", XS_Hyperman_bus_waker_drained);
3716 149 newXS_deffile("Hyperman::bus_stats", XS_Hyperman_bus_stats);
3717 149 newXS_deffile("Hyperman::_quic_cid_selftest", XS_Hyperman__quic_cid_selftest);
3718 149 newXS_deffile("Hyperman::_quic_heap_selftest", XS_Hyperman__quic_heap_selftest);
3719 149 newXS_deffile("Hyperman::_quic_src_selftest", XS_Hyperman__quic_src_selftest);
3720 149 newXS_deffile("Hyperman::_quic_token_selftest", XS_Hyperman__quic_token_selftest);
3721 149 newXS_deffile("Hyperman::_quic_decode_selftest", XS_Hyperman__quic_decode_selftest);
3722 }
3723  
3724 /* Initialisation Section */
3725  
3726 #line 6 "./xs/hyperman.xs"
3727 hm_fq = newAV();
3728 hm_boot_argv_save(aTHX);
3729 /* Shared::Arena's table, once. NULL when it is absent or too old, and
3730 * every arena door then fails open. */
3731 hm_sa_resolve(aTHX);
3732  
3733 #line 3734 "Hyperman.c"
3734  
3735 /* End of Initialisation Section */
3736  
3737 #if PERL_VERSION_LE(5, 21, 5)
3738 # if PERL_VERSION_GE(5, 9, 0)
3739 if (PL_unitcheckav)
3740 call_list(PL_scopestack_ix, PL_unitcheckav);
3741 # endif
3742 XSRETURN_YES;
3743 #else
3744 149 Perl_xs_boot_epilog(aTHX_ ax);
3745 #endif
3746 149 }
3747  
3748 #ifdef __cplusplus
3749 }
3750 #endif
« xs/abi.xs ↑ Summary include/hyperman/hm_workerhook_perl.h »