FakeFloat16.xs

filter: Statementstmt 0.0% 0 / 33 Branchbran 0.0% 0 / 36 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 69 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/Math/FakeFloat16.pm ↑ Summary
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4  
5 0 SV * _itsa(SV * a) {
6 0 ▶ if(SvIOK(a)) {
Branch: 1 branch
BranchTrueFalseTotal
if(SvIOK(a)) { 0 0 0
7 0 return newSVuv(2); /* IV */
8 }
9 0 ▶ if(SvPOK(a)) {
Branch: 1 branch
BranchTrueFalseTotal
if(SvPOK(a)) { 0 0 0
10 0 return newSVuv(4); /* PV */
11 }
12 0 ▶ if(SvNOK(a)) return newSVuv(3); /* NV */
Branch: 1 branch
BranchTrueFalseTotal
if(SvNOK(a)) return newSVuv(3); /* NV */ 0 0 0
13 0 ▶ if(sv_isobject(a)) {
Branch: 1 branch
BranchTrueFalseTotal
if(sv_isobject(a)) { 0 0 0
14 0 ▶ const char* h = HvNAME(SvSTASH(SvRV(a)));
Branch: 6 branches
BranchTrueFalseTotal
const char* h = HvNAME(SvSTASH(SvRV(a))); 0 0 0
const char* h = HvNAME(SvSTASH(SvRV(a))); 0 0 0
const char* h = HvNAME(SvSTASH(SvRV(a))); 0 0 0
const char* h = HvNAME(SvSTASH(SvRV(a))); 0 0 0
const char* h = HvNAME(SvSTASH(SvRV(a))); 0 0 0
const char* h = HvNAME(SvSTASH(SvRV(a))); 0 0 0
15  
16 0 ▶ if(strEQ(h, "Math::MPFR")) return newSVuv(5);
Branch: 1 branch
BranchTrueFalseTotal
if(strEQ(h, "Math::MPFR")) return newSVuv(5); 0 0 0
17 0 ▶ if(strEQ(h, "Math::GMPf")) return newSVuv(6);
Branch: 1 branch
BranchTrueFalseTotal
if(strEQ(h, "Math::GMPf")) return newSVuv(6); 0 0 0
18 0 ▶ if(strEQ(h, "Math::GMPq")) return newSVuv(7);
Branch: 1 branch
BranchTrueFalseTotal
if(strEQ(h, "Math::GMPq")) return newSVuv(7); 0 0 0
19 0 ▶ if(strEQ(h, "Math::FakeFloat16")) return newSVuv(31);
Branch: 1 branch
BranchTrueFalseTotal
if(strEQ(h, "Math::FakeFloat16")) return newSVuv(31); 0 0 0
20 0 croak("The Math::FakeFloat16::_itsa XSub does not accept %s objects.", h);
21 }
22 0 croak("The Math::FakeFloat16::_itsa XSub has been given an invalid argument (probably undefined)");
23 }
24  
25 0 void _unpack_float(SV * in) {
26 0 dXSARGS;
27 int i;
28 char * buff;
29 0 float f = (float)SvNVX(in); /* f == SvNVX(in) */
30 0 void * p = &f;
31  
32 0 Newx(buff, 4, char);
33 0 ▶ if(buff == NULL) croak("Failed to allocate memory (in _unpack_float) inside unpack_f16_hex");
Branch: 1 branch
BranchTrueFalseTotal
if(buff == NULL) croak("Failed to allocate memory (in _unpack_float) inside unpack_f16_hex"); 0 0 0
34  
35 0 sp = mark;
36  
37 #ifdef WE_HAVE_BENDIAN /* Big Endian architecture */
38 for (i = 0; i < 2; i++) {
39 #else
40 0 ▶ for (i = 3; i >= 2; i--) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 3; i >= 2; i--) { 0 0 0
41 #endif
42 0 sprintf(buff, "%02X", ((unsigned char*)p)[i]);
43 0 ▶ XPUSHs(sv_2mortal(newSVpv(buff, 0)));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(newSVpv(buff, 0))); 0 0 0
44 }
45 0 PUTBACK;
46 0 Safefree(buff);
47 0 XSRETURN(2);
48 }
49 MODULE = Math::FakeFloat16 PACKAGE = Math::FakeFloat16
50  
51 PROTOTYPES: DISABLE
52  
53  
54 SV *
55 _itsa (a)
56 SV * a
57  
58 void
59 _unpack_float (in)
60 SV * in
61 PREINIT:
62 I32* temp;
63 PPCODE:
64 0 temp = PL_markstack_ptr++;
65 0 _unpack_float(in);
66 0 ▶ if (PL_markstack_ptr != temp) {
Branch: 1 branch
BranchTrueFalseTotal
if (PL_markstack_ptr != temp) { 0 0 0
67 /* truly void, because dXSARGS not invoked */
68 0 PL_markstack_ptr = temp;
69 0 XSRETURN_EMPTY; /* return empty stack */
70 }
71 /* must have used dXSARGS; list context implied */
72 0 return;
73  
« blib/lib/Math/FakeFloat16.pm ↑ Summary