LPM.c

filter: Statementstmt 74.4% 64 / 86 Branchbran 46.1% 12 / 26 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 67.8% 76 / 112 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« const-xs.inc ↑ Summary lpm_lib.c »
1 /*
2 * This file was generated automatically by ExtUtils::ParseXS version 3.63 from the
3 * contents of LPM.xs. Do not edit this file, edit LPM.xs instead.
4 *
5 * ANY CHANGES MADE HERE WILL BE LOST!
6 *
7 */
8  
9 #line 1 "LPM.xs"
10 #include "EXTERN.h"
11 #include "perl.h"
12 #include "XSUB.h"
13  
14 #include "ppport.h"
15  
16 #include "const-c.inc"
17 #include "lpm_lib.h"
18  
19 #line 20 "LPM.c"
20 #ifndef PERL_UNUSED_VAR
21 # define PERL_UNUSED_VAR(var) if (0) var = var
22 #endif
23  
24 #ifndef dVAR
25 # define dVAR dNOOP
26 #endif
27  
28  
29 /* This stuff is not part of the API! You have been warned. */
30 #ifndef PERL_VERSION_DECIMAL
31 # define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
32 #endif
33 #ifndef PERL_DECIMAL_VERSION
34 # define PERL_DECIMAL_VERSION \
35 PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
36 #endif
37 #ifndef PERL_VERSION_GE
38 # define PERL_VERSION_GE(r,v,s) \
39 (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
40 #endif
41 #ifndef PERL_VERSION_LE
42 # define PERL_VERSION_LE(r,v,s) \
43 (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
44 #endif
45  
46 /* XS_INTERNAL is the explicit static-linkage variant of the default
47 * XS macro.
48 *
49 * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
50 * "static", ie. it exports XSUB symbols. You probably don't want that
51 * for anything but the BOOT XSUB.
52 *
53 * See XSUB.h in core!
54 */
55  
56  
57 /* TODO: This might be compatible further back than 5.10.0. */
58 #if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
59 # undef XS_EXTERNAL
60 # undef XS_INTERNAL
61 # if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
62 # define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
63 # define XS_INTERNAL(name) static XSPROTO(name)
64 # endif
65 # if defined(__SYMBIAN32__)
66 # define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
67 # define XS_INTERNAL(name) EXPORT_C static XSPROTO(name)
68 # endif
69 # ifndef XS_EXTERNAL
70 # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
71 # define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
72 # define XS_INTERNAL(name) static void name(pTHX_ CV* cv __attribute__unused__)
73 # else
74 # ifdef __cplusplus
75 # define XS_EXTERNAL(name) extern "C" XSPROTO(name)
76 # define XS_INTERNAL(name) static XSPROTO(name)
77 # else
78 # define XS_EXTERNAL(name) XSPROTO(name)
79 # define XS_INTERNAL(name) static XSPROTO(name)
80 # endif
81 # endif
82 # endif
83 #endif
84  
85 /* perl >= 5.10.0 && perl <= 5.15.1 */
86  
87  
88 /* The XS_EXTERNAL macro is used for functions that must not be static
89 * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
90 * macro defined, the best we can do is assume XS is the same.
91 * Dito for XS_INTERNAL.
92 */
93 #ifndef XS_EXTERNAL
94 # define XS_EXTERNAL(name) XS(name)
95 #endif
96 #ifndef XS_INTERNAL
97 # define XS_INTERNAL(name) XS(name)
98 #endif
99  
100 /* Now, finally, after all this mess, we want an ExtUtils::ParseXS
101 * internal macro that we're free to redefine for varying linkage due
102 * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
103 * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
104 */
105  
106 #undef XS_EUPXS
107 #if defined(PERL_EUPXS_ALWAYS_EXPORT)
108 # define XS_EUPXS(name) XS_EXTERNAL(name)
109 #else
110 /* default to internal */
111 # define XS_EUPXS(name) XS_INTERNAL(name)
112 #endif
113  
114 #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
115 #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
116  
117 /* prototype to pass -Wmissing-prototypes */
118 static void
119 S_croak_xs_usage(const CV *const cv, const char *const params);
120  
121 static void
122 S_croak_xs_usage(const CV *const cv, const char *const params)
123 {
124 const GV *const gv = CvGV(cv);
125  
126 PERL_ARGS_ASSERT_CROAK_XS_USAGE;
127  
128 if (gv) {
129 const char *const gvname = GvNAME(gv);
130 const HV *const stash = GvSTASH(gv);
131 const char *const hvname = stash ? HvNAME(stash) : NULL;
132  
133 if (hvname)
134 Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
135 else
136 Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
137 } else {
138 /* Pants. I don't think that it should be possible to get here. */
139 Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
140 }
141 }
142 #undef PERL_ARGS_ASSERT_CROAK_XS_USAGE
143  
144 #define croak_xs_usage S_croak_xs_usage
145  
146 #endif
147  
148 /* NOTE: the prototype of newXSproto() is different in versions of perls,
149 * so we define a portable version of newXSproto()
150 */
151 #ifdef newXS_flags
152 #define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
153 #else
154 #define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
155 #endif /* !defined(newXS_flags) */
156  
157 #if PERL_VERSION_LE(5, 21, 5)
158 # define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
159 #else
160 # define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
161 #endif
162  
163 /* simple backcompat versions of the TARGx() macros with no optimisation */
164 #ifndef TARGi
165 # define TARGi(iv, do_taint) sv_setiv_mg(TARG, iv)
166 # define TARGu(uv, do_taint) sv_setuv_mg(TARG, uv)
167 # define TARGn(nv, do_taint) sv_setnv_mg(TARG, nv)
168 #endif
169  
170 #line 171 "LPM.c"
171  
172 /* INCLUDE: Including 'const-xs.inc' from 'LPM.xs' */
173  
174  
175 XS_EUPXS(XS_Net__IP__LPM_constant); /* prototype to pass -Wmissing-prototypes */
176 0 XS_EUPXS(XS_Net__IP__LPM_constant)
177 {
178 0 dVAR; dXSARGS;
179 0 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 0 0
180 0 croak_xs_usage(cv, "sv");
181 PERL_UNUSED_VAR(ax); /* -Wall */
182 0 ▶ SP -= items;
Branch: 1 branch
BranchTrueFalseTotal
SP -= items; 0 0 0
183 {
184 #line 4 "./const-xs.inc"
185 #ifdef dXSTARG
186 dXSTARG; /* Faster if we have it. */
187 #else
188 dTARGET;
189 #endif
190 STRLEN len;
191 int type;
192 /* IV iv; Uncomment this if you need to return IVs */
193 /* NV nv; Uncomment this if you need to return NVs */
194 /* const char *pv; Uncomment this if you need to return PVs */
195 #line 196 "LPM.c"
196 0 SV * sv = ST(0)
197 ;
198 0 const char * s = SvPV(sv, len);
199 #line 18 "./const-xs.inc"
200 type = constant(aTHX_ s, len);
201 /* Return 1 or 2 items. First is error message, or undef if no error.
202 Second, if present, is found value */
203 switch (type) {
204 case PERL_constant_NOTFOUND:
205 sv =
206 sv_2mortal(newSVpvf("%s is not a valid Net::IP:LPM macro", s));
207 PUSHs(sv);
208 break;
209 case PERL_constant_NOTDEF:
210 sv = sv_2mortal(newSVpvf(
211 "Your vendor has not defined Net::IP:LPM macro %s, used",
212 s));
213 PUSHs(sv);
214 break;
215 /* Uncomment this if you need to return IVs
216 case PERL_constant_ISIV:
217 EXTEND(SP, 2);
218 PUSHs(&PL_sv_undef);
219 PUSHi(iv);
220 break; */
221 /* Uncomment this if you need to return NOs
222 case PERL_constant_ISNO:
223 EXTEND(SP, 2);
224 PUSHs(&PL_sv_undef);
225 PUSHs(&PL_sv_no);
226 break; */
227 /* Uncomment this if you need to return NVs
228 case PERL_constant_ISNV:
229 EXTEND(SP, 2);
230 PUSHs(&PL_sv_undef);
231 PUSHn(nv);
232 break; */
233 /* Uncomment this if you need to return PVs
234 case PERL_constant_ISPV:
235 EXTEND(SP, 2);
236 PUSHs(&PL_sv_undef);
237 PUSHp(pv, strlen(pv));
238 break; */
239 /* Uncomment this if you need to return PVNs
240 case PERL_constant_ISPVN:
241 EXTEND(SP, 2);
242 PUSHs(&PL_sv_undef);
243 PUSHp(pv, iv);
244 break; */
245 /* Uncomment this if you need to return SVs
246 case PERL_constant_ISSV:
247 EXTEND(SP, 2);
248 PUSHs(&PL_sv_undef);
249 PUSHs(sv);
250 break; */
251 /* Uncomment this if you need to return UNDEFs
252 case PERL_constant_ISUNDEF:
253 break; */
254 /* Uncomment this if you need to return UVs
255 case PERL_constant_ISUV:
256 EXTEND(SP, 2);
257 PUSHs(&PL_sv_undef);
258 PUSHu((UV)iv);
259 break; */
260 /* Uncomment this if you need to return YESs
261 case PERL_constant_ISYES:
262 EXTEND(SP, 2);
263 PUSHs(&PL_sv_undef);
264 PUSHs(&PL_sv_yes);
265 break; */
266 default:
267 sv = sv_2mortal(newSVpvf(
268 "Unexpected return type %d while processing Net::IP:LPM macro %s, used",
269 type, s));
270 PUSHs(sv);
271 }
272 #line 273 "LPM.c"
273 0 PUTBACK;
274 0 return;
275 }
276 }
277  
278  
279 /* INCLUDE: Returning to 'LPM.xs' from 'const-xs.inc' */
280  
281  
282 XS_EUPXS(XS_Net__IP__LPM_lpm_init); /* prototype to pass -Wmissing-prototypes */
283 26 XS_EUPXS(XS_Net__IP__LPM_lpm_init)
284 {
285 26 dVAR; dXSARGS;
286 26 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 26 26
287 0 croak_xs_usage(cv, "");
288 {
289 int RETVAL;
290 26 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 26 0 26
291  
292 26 RETVAL = lpm_init();
293 26 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 23 3 26
294 26 ST(0) = TARG;
295 }
296 26 XSRETURN(1);
297 }
298  
299  
300 XS_EUPXS(XS_Net__IP__LPM_lpm_add_raw); /* prototype to pass -Wmissing-prototypes */
301 458954 XS_EUPXS(XS_Net__IP__LPM_lpm_add_raw)
302 {
303 458954 dVAR; dXSARGS;
304 458954 ▶ if (items != 4)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 4) 0 458954 458954
305 0 croak_xs_usage(cv, "handle, prefix, prefix_len, value");
306 {
307 458954 int handle = (int)SvIV(ST(0))
308 ;
309 458954 SV * prefix = ST(1)
310 ;
311 458954 IV prefix_len = (IV)SvIV(ST(2))
312 ;
313 458954 SV * value = ST(3)
314 ;
315 int RETVAL;
316 458954 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 458954 0 458954
317  
318 458954 RETVAL = lpm_add_raw(handle, prefix, prefix_len, value);
319 458948 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 458945 3 458948
320 458948 ST(0) = TARG;
321 }
322 458948 XSRETURN(1);
323 }
324  
325  
326 XS_EUPXS(XS_Net__IP__LPM_lpm_lookup_raw); /* prototype to pass -Wmissing-prototypes */
327 18000245 XS_EUPXS(XS_Net__IP__LPM_lpm_lookup_raw)
328 {
329 18000245 dVAR; dXSARGS;
330 18000245 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 18000245 18000245
331 0 croak_xs_usage(cv, "handle, addr");
332 {
333 18000245 int handle = (int)SvIV(ST(0))
334 ;
335 18000245 SV * addr = ST(1)
336 ;
337 SV * RETVAL;
338  
339 18000245 RETVAL = lpm_lookup_raw(handle, addr);
340 18000245 RETVAL = sv_2mortal(RETVAL);
341 18000245 ST(0) = RETVAL;
342 }
343 18000245 XSRETURN(1);
344 }
345  
346  
347 XS_EUPXS(XS_Net__IP__LPM_lpm_info); /* prototype to pass -Wmissing-prototypes */
348 1 XS_EUPXS(XS_Net__IP__LPM_lpm_info)
349 {
350 1 dVAR; dXSARGS;
351 1 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 1 1
352 0 croak_xs_usage(cv, "handle");
353 {
354 1 int handle = (int)SvIV(ST(0))
355 ;
356 SV * RETVAL;
357  
358 1 RETVAL = lpm_info(handle);
359 1 RETVAL = sv_2mortal(RETVAL);
360 1 ST(0) = RETVAL;
361 }
362 1 XSRETURN(1);
363 }
364  
365  
366 XS_EUPXS(XS_Net__IP__LPM_lpm_dump); /* prototype to pass -Wmissing-prototypes */
367 3 XS_EUPXS(XS_Net__IP__LPM_lpm_dump)
368 {
369 3 dVAR; dXSARGS;
370 3 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 3 3
371 0 croak_xs_usage(cv, "handle");
372 {
373 3 int handle = (int)SvIV(ST(0))
374 ;
375 SV * RETVAL;
376  
377 3 RETVAL = lpm_dump(handle);
378 3 RETVAL = sv_2mortal(RETVAL);
379 3 ST(0) = RETVAL;
380 }
381 3 XSRETURN(1);
382 }
383  
384  
385 XS_EUPXS(XS_Net__IP__LPM_lpm_finish); /* prototype to pass -Wmissing-prototypes */
386 0 XS_EUPXS(XS_Net__IP__LPM_lpm_finish)
387 {
388 0 dVAR; dXSARGS;
389 0 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 0 0
390 0 croak_xs_usage(cv, "handle");
391 {
392 0 int handle = (int)SvIV(ST(0))
393 ;
394  
395 0 lpm_finish(handle);
396 }
397 0 XSRETURN_EMPTY;
398 }
399  
400  
401 XS_EUPXS(XS_Net__IP__LPM_lpm_destroy); /* prototype to pass -Wmissing-prototypes */
402 26 XS_EUPXS(XS_Net__IP__LPM_lpm_destroy)
403 {
404 26 dVAR; dXSARGS;
405 26 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 26 26
406 0 croak_xs_usage(cv, "handle");
407 {
408 26 int handle = (int)SvIV(ST(0))
409 ;
410  
411 26 lpm_destroy(handle);
412 }
413 26 XSRETURN_EMPTY;
414 }
415  
416 #ifdef __cplusplus
417 extern "C" {
418 #endif
419 XS_EXTERNAL(boot_Net__IP__LPM); /* prototype to pass -Wmissing-prototypes */
420 3 XS_EXTERNAL(boot_Net__IP__LPM)
421 {
422 #if PERL_VERSION_LE(5, 21, 5)
423 dVAR; dXSARGS;
424 #else
425 3 dVAR; dXSBOOTARGSXSAPIVERCHK;
426 #endif
427 #if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
428 char* file = __FILE__;
429 #else
430 3 const char* file = __FILE__;
431 #endif
432  
433 PERL_UNUSED_VAR(file);
434  
435 PERL_UNUSED_VAR(cv); /* -W */
436 PERL_UNUSED_VAR(items); /* -W */
437 #if PERL_VERSION_LE(5, 21, 5)
438 XS_VERSION_BOOTCHECK;
439 # ifdef XS_APIVERSION_BOOTCHECK
440 XS_APIVERSION_BOOTCHECK;
441 # endif
442 #endif
443  
444 3 newXS_deffile("Net::IP::LPM::constant", XS_Net__IP__LPM_constant);
445 3 newXS_deffile("Net::IP::LPM::lpm_init", XS_Net__IP__LPM_lpm_init);
446 3 newXS_deffile("Net::IP::LPM::lpm_add_raw", XS_Net__IP__LPM_lpm_add_raw);
447 3 newXS_deffile("Net::IP::LPM::lpm_lookup_raw", XS_Net__IP__LPM_lpm_lookup_raw);
448 3 newXS_deffile("Net::IP::LPM::lpm_info", XS_Net__IP__LPM_lpm_info);
449 3 newXS_deffile("Net::IP::LPM::lpm_dump", XS_Net__IP__LPM_lpm_dump);
450 3 newXS_deffile("Net::IP::LPM::lpm_finish", XS_Net__IP__LPM_lpm_finish);
451 3 newXS_deffile("Net::IP::LPM::lpm_destroy", XS_Net__IP__LPM_lpm_destroy);
452 #if PERL_VERSION_LE(5, 21, 5)
453 # if PERL_VERSION_GE(5, 9, 0)
454 if (PL_unitcheckav)
455 call_list(PL_scopestack_ix, PL_unitcheckav);
456 # endif
457 XSRETURN_YES;
458 #else
459 3 Perl_xs_boot_epilog(aTHX_ ax);
460 #endif
461 3 }
462  
463 #ifdef __cplusplus
464 }
465 #endif
« const-xs.inc ↑ Summary lpm_lib.c »