c/perl_math_int128.c

filter: Statementstmt 63.6% 28 / 44 Branchbran 34.0% 17 / 50 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 47.8% 45 / 94 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« c/perl_math_int64.c ↑ Summary c/tree.c »
1 /*
2 * perl_math_int128.c - This file is in the public domain
3 * Author: Salvador Fandino <sfandino@yahoo.com>, Dave Rolsky <autarch@urth.org>
4 *
5 * Generated on: 2015-03-11 11:04:45
6 * Math::Int128 version: 0.21
7 */
8  
9 #include "EXTERN.h"
10 #include "perl.h"
11 #include "ppport.h"
12  
13 #if ((__GNUC__ == 4) && (__GNUC_MINOR__ < 6))
14  
15 /* workaroung for gcc 4.4/4.5 - see http://gcc.gnu.org/gcc-4.4/changes.html */
16 typedef int int128_t __attribute__ ((__mode__ (TI)));
17 typedef unsigned int uint128_t __attribute__ ((__mode__ (TI)));
18  
19 #else
20  
21 typedef __int128 int128_t;
22 typedef unsigned __int128 uint128_t;
23  
24 #endif
25  
26  
27 HV *math_int128_c_api_hash = NULL;
28 int math_int128_c_api_min_version = 0;
29 int math_int128_c_api_max_version = 0;
30  
31 int128_t (*math_int128_c_api_SvI128)(pTHX_ SV *sv) = NULL;
32 int (*math_int128_c_api_SvI128OK)(pTHX_ SV*) = NULL;
33 int128_t (*math_int128_c_api_SvU128)(pTHX_ SV *sv) = NULL;
34 int (*math_int128_c_api_SvU128OK)(pTHX_ SV*) = NULL;
35 SV * (*math_int128_c_api_newSVi128)(pTHX_ int128_t i128) = NULL;
36 SV * (*math_int128_c_api_newSVu128)(pTHX_ uint128_t u128) = NULL;
37  
38 int
39 18 perl_math_int128_load(int required_version) {
40 dTHX;
41 SV **svp;
42  
43 18 eval_pv("require Math::Int128", TRUE);
44 18 ▶ if (SvTRUE(ERRSV)) return 0;
Branch: 2 branches
BranchTrueFalseTotal
if (SvTRUE(ERRSV)) return 0; 18 0 18
if (SvTRUE(ERRSV)) return 0; 0 18 18
45  
46 18 math_int128_c_api_hash = get_hv("Math::Int128::C_API", 0);
47 18 ▶ if (!math_int128_c_api_hash) {
Branch: 1 branch
BranchTrueFalseTotal
if (!math_int128_c_api_hash) { 0 18 18
48 0 ▶ sv_setpv_mg(ERRSV, "Unable to load Math::Int128 C API");
Branch: 1 branch
BranchTrueFalseTotal
sv_setpv_mg(ERRSV, "Unable to load Math::Int128 C API"); 0 0 0
49 0 return 0;
50 }
51  
52 18 math_int128_c_api_min_version = SvIV(*hv_fetch(math_int128_c_api_hash, "min_version", 11, 1));
53 18 math_int128_c_api_max_version = SvIV(*hv_fetch(math_int128_c_api_hash, "max_version", 11, 1));
54 18 ▶ if ((required_version < math_int128_c_api_min_version) ||
Branch: 1 branch
BranchTrueFalseTotal
if ((required_version < math_int128_c_api_min_version) || 18 0 18
55 18 ▶ (required_version > math_int128_c_api_max_version)) {
Branch: 1 branch
BranchTrueFalseTotal
(required_version > math_int128_c_api_max_version)) { 0 18 18
56 0 ▶ sv_setpvf_mg(ERRSV,
Branch: 1 branch
BranchTrueFalseTotal
sv_setpvf_mg(ERRSV, 0 0 0
57 "Math::Int128 C API version mismatch. "
58 "The installed module supports versions %d to %d but %d is required",
59 math_int128_c_api_min_version,
60 math_int128_c_api_max_version,
61 required_version);
62 0 return 0;
63 }
64  
65 18 svp = hv_fetch(math_int128_c_api_hash, "SvI128", 6, 0);
66 18 ▶ if (!svp || !*svp) {
Branch: 2 branches
BranchTrueFalseTotal
if (!svp || !*svp) { 18 0 18
if (!svp || !*svp) { 0 18 18
67 0 ▶ sv_setpv_mg(ERRSV, "Unable to fetch pointer 'SvI128' C function from Math::Int128");
Branch: 1 branch
BranchTrueFalseTotal
sv_setpv_mg(ERRSV, "Unable to fetch pointer 'SvI128' C function from Math::Int128"); 0 0 0
68 0 return 0;
69 }
70 18 math_int128_c_api_SvI128 = INT2PTR(void *, SvIV(*svp));
71 18 svp = hv_fetch(math_int128_c_api_hash, "SvI128OK", 8, 0);
72 18 ▶ if (!svp || !*svp) {
Branch: 2 branches
BranchTrueFalseTotal
if (!svp || !*svp) { 18 0 18
if (!svp || !*svp) { 0 18 18
73 0 ▶ sv_setpv_mg(ERRSV, "Unable to fetch pointer 'SvI128OK' C function from Math::Int128");
Branch: 1 branch
BranchTrueFalseTotal
sv_setpv_mg(ERRSV, "Unable to fetch pointer 'SvI128OK' C function from Math::Int128"); 0 0 0
74 0 return 0;
75 }
76 18 math_int128_c_api_SvI128OK = INT2PTR(void *, SvIV(*svp));
77 18 svp = hv_fetch(math_int128_c_api_hash, "SvU128", 6, 0);
78 18 ▶ if (!svp || !*svp) {
Branch: 2 branches
BranchTrueFalseTotal
if (!svp || !*svp) { 18 0 18
if (!svp || !*svp) { 0 18 18
79 0 ▶ sv_setpv_mg(ERRSV, "Unable to fetch pointer 'SvU128' C function from Math::Int128");
Branch: 1 branch
BranchTrueFalseTotal
sv_setpv_mg(ERRSV, "Unable to fetch pointer 'SvU128' C function from Math::Int128"); 0 0 0
80 0 return 0;
81 }
82 18 math_int128_c_api_SvU128 = INT2PTR(void *, SvIV(*svp));
83 18 svp = hv_fetch(math_int128_c_api_hash, "SvU128OK", 8, 0);
84 18 ▶ if (!svp || !*svp) {
Branch: 2 branches
BranchTrueFalseTotal
if (!svp || !*svp) { 18 0 18
if (!svp || !*svp) { 0 18 18
85 0 ▶ sv_setpv_mg(ERRSV, "Unable to fetch pointer 'SvU128OK' C function from Math::Int128");
Branch: 1 branch
BranchTrueFalseTotal
sv_setpv_mg(ERRSV, "Unable to fetch pointer 'SvU128OK' C function from Math::Int128"); 0 0 0
86 0 return 0;
87 }
88 18 math_int128_c_api_SvU128OK = INT2PTR(void *, SvIV(*svp));
89 18 svp = hv_fetch(math_int128_c_api_hash, "newSVi128", 9, 0);
90 18 ▶ if (!svp || !*svp) {
Branch: 2 branches
BranchTrueFalseTotal
if (!svp || !*svp) { 18 0 18
if (!svp || !*svp) { 0 18 18
91 0 ▶ sv_setpv_mg(ERRSV, "Unable to fetch pointer 'newSVi128' C function from Math::Int128");
Branch: 1 branch
BranchTrueFalseTotal
sv_setpv_mg(ERRSV, "Unable to fetch pointer 'newSVi128' C function from Math::Int128"); 0 0 0
92 0 return 0;
93 }
94 18 math_int128_c_api_newSVi128 = INT2PTR(void *, SvIV(*svp));
95 18 svp = hv_fetch(math_int128_c_api_hash, "newSVu128", 9, 0);
96 18 ▶ if (!svp || !*svp) {
Branch: 2 branches
BranchTrueFalseTotal
if (!svp || !*svp) { 18 0 18
if (!svp || !*svp) { 0 18 18
97 0 ▶ sv_setpv_mg(ERRSV, "Unable to fetch pointer 'newSVu128' C function from Math::Int128");
Branch: 1 branch
BranchTrueFalseTotal
sv_setpv_mg(ERRSV, "Unable to fetch pointer 'newSVu128' C function from Math::Int128"); 0 0 0
98 0 return 0;
99 }
100 18 math_int128_c_api_newSVu128 = INT2PTR(void *, SvIV(*svp));
101  
102 18 return 1;
103 }
104  
« c/perl_math_int64.c ↑ Summary c/tree.c »