| 1 |
|
| /*
|
| 2 |
|
| * perl_math_int64.c - This file is in the public domain
|
| 3 |
|
| * Author: "Salvador Fandino <sfandino@yahoo.com>, Dave Rolsky <autarch@urth.org>"
|
| 4 |
|
| *
|
| 5 |
|
| * Generated on: 2016-01-04 10:07:18
|
| 6 |
|
| * Math::Int64 version: 0.54
|
| 7 |
|
| * Module::CAPIMaker version:
|
| 8 |
|
| */
|
| 9 |
|
|
|
| 10 |
|
| #include "EXTERN.h"
|
| 11 |
|
| #include "perl.h"
|
| 12 |
|
| #include "ppport.h"
|
| 13 |
|
|
|
| 14 |
|
| #ifdef __MINGW32__
|
| 15 |
|
| #include <stdint.h>
|
| 16 |
|
| #endif
|
| 17 |
|
|
|
| 18 |
|
| #ifdef _MSC_VER
|
| 19 |
|
| #include <stdlib.h>
|
| 20 |
|
| typedef __int64 int64_t;
|
| 21 |
|
| typedef unsigned __int64 uint64_t;
|
| 22 |
|
| #endif
|
| 23 |
|
|
|
| 24 |
|
| /* you may need to add a typemap for int64_t here if it is not defined
|
| 25 |
|
| by default in your C header files */
|
| 26 |
|
|
|
| 27 |
|
| HV *math_int64_c_api_hash;
|
| 28 |
|
| int math_int64_c_api_min_version;
|
| 29 |
|
| int math_int64_c_api_max_version;
|
| 30 |
|
|
|
| 31 |
|
| int64_t (*math_int64_c_api_SvI64)(pTHX_ SV*);
|
| 32 |
|
| int (*math_int64_c_api_SvI64OK)(pTHX_ SV*);
|
| 33 |
|
| uint64_t (*math_int64_c_api_SvU64)(pTHX_ SV*);
|
| 34 |
|
| int (*math_int64_c_api_SvU64OK)(pTHX_ SV*);
|
| 35 |
|
| SV * (*math_int64_c_api_newSVi64)(pTHX_ int64_t);
|
| 36 |
|
| SV * (*math_int64_c_api_newSVu64)(pTHX_ uint64_t);
|
| 37 |
|
| uint64_t (*math_int64_c_api_randU64)(pTHX);
|
| 38 |
|
|
|
| 39 |
|
| int
|
| 40 |
0 |
| perl_math_int64_load(int required_version) {
|
| 41 |
|
| dTHX;
|
| 42 |
|
| SV **svp;
|
| 43 |
0 |
| eval_pv("require Math::Int64", TRUE);
|
| 44 |
0 |
▶ | if (SvTRUE(ERRSV)) return 0;
|
Branch: 2 branches
| Branch | True | False | Total |
| if (SvTRUE(ERRSV)) return 0;
|
0 |
0 |
0 |
| if (SvTRUE(ERRSV)) return 0;
|
0 |
0 |
0 |
|
| 45 |
|
|
|
| 46 |
0 |
| math_int64_c_api_hash = get_hv("Math::Int64::C_API", 0);
|
| 47 |
0 |
▶ | if (!math_int64_c_api_hash) {
|
Branch: 1 branch
| Branch | True | False | Total |
| if (!math_int64_c_api_hash) {
|
0 |
0 |
0 |
|
| 48 |
0 |
▶ | sv_setpv(ERRSV, "Unable to load Math::Int64 C API");
|
Branch: 1 branch
| Branch | True | False | Total |
| sv_setpv(ERRSV, "Unable to load Math::Int64 C API");
|
0 |
0 |
0 |
|
| 49 |
0 |
▶ | SvSETMAGIC(ERRSV);
|
Branch: 2 branches
| Branch | True | False | Total |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
|
| 50 |
0 |
| return 0;
|
| 51 |
|
| }
|
| 52 |
|
|
|
| 53 |
0 |
| svp = hv_fetch(math_int64_c_api_hash, "min_version", 11, 0);
|
| 54 |
0 |
▶ | if (!svp) svp = hv_fetch(math_int64_c_api_hash, "version", 7, 1);
|
Branch: 1 branch
| Branch | True | False | Total |
| if (!svp) svp = hv_fetch(math_int64_c_api_hash, "version", 7, 1);
|
0 |
0 |
0 |
|
| 55 |
0 |
▶ | if (!svp || !*svp) {
|
Branch: 2 branches
| Branch | True | False | Total |
| if (!svp || !*svp) {
|
0 |
0 |
0 |
| if (!svp || !*svp) {
|
0 |
0 |
0 |
|
| 56 |
0 |
▶ | sv_setpv(ERRSV, "Unable to retrieve C API version for Math::Int64");
|
Branch: 1 branch
| Branch | True | False | Total |
| sv_setpv(ERRSV, "Unable to retrieve C API version for Math::Int64");
|
0 |
0 |
0 |
|
| 57 |
0 |
▶ | SvSETMAGIC(ERRSV);
|
Branch: 2 branches
| Branch | True | False | Total |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
|
| 58 |
0 |
| return 0;
|
| 59 |
|
| }
|
| 60 |
0 |
| math_int64_c_api_min_version = SvIV(*svp);
|
| 61 |
|
|
|
| 62 |
0 |
| svp = hv_fetch(math_int64_c_api_hash, "max_version", 11, 0);
|
| 63 |
0 |
▶ | if (!svp) svp = hv_fetch(math_int64_c_api_hash, "version", 7, 1);
|
Branch: 1 branch
| Branch | True | False | Total |
| if (!svp) svp = hv_fetch(math_int64_c_api_hash, "version", 7, 1);
|
0 |
0 |
0 |
|
| 64 |
0 |
▶ | if (!svp || !*svp) {
|
Branch: 2 branches
| Branch | True | False | Total |
| if (!svp || !*svp) {
|
0 |
0 |
0 |
| if (!svp || !*svp) {
|
0 |
0 |
0 |
|
| 65 |
0 |
▶ | sv_setpv(ERRSV, "Unable to retrieve C API version for Math::Int64");
|
Branch: 1 branch
| Branch | True | False | Total |
| sv_setpv(ERRSV, "Unable to retrieve C API version for Math::Int64");
|
0 |
0 |
0 |
|
| 66 |
0 |
▶ | SvSETMAGIC(ERRSV);
|
Branch: 2 branches
| Branch | True | False | Total |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
|
| 67 |
0 |
| return 0;
|
| 68 |
|
| }
|
| 69 |
0 |
| math_int64_c_api_max_version = SvIV(*svp);
|
| 70 |
|
|
|
| 71 |
0 |
▶ | if ((required_version < math_int64_c_api_min_version) ||
|
Branch: 1 branch
| Branch | True | False | Total |
| if ((required_version < math_int64_c_api_min_version) ||
|
0 |
0 |
0 |
|
| 72 |
0 |
▶ | (required_version > math_int64_c_api_max_version)) {
|
Branch: 1 branch
| Branch | True | False | Total |
| (required_version > math_int64_c_api_max_version)) {
|
0 |
0 |
0 |
|
| 73 |
0 |
▶ | sv_setpvf(ERRSV,
|
Branch: 1 branch
| Branch | True | False | Total |
| sv_setpvf(ERRSV,
|
0 |
0 |
0 |
|
| 74 |
|
| "Math::Int64 C API version mismatch. "
|
| 75 |
|
| "The installed module supports versions %d to %d but %d is required",
|
| 76 |
|
| math_int64_c_api_min_version,
|
| 77 |
|
| math_int64_c_api_max_version,
|
| 78 |
|
| required_version);
|
| 79 |
0 |
▶ | SvSETMAGIC(ERRSV);
|
Branch: 2 branches
| Branch | True | False | Total |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
|
| 80 |
0 |
| return 0;
|
| 81 |
|
| }
|
| 82 |
|
|
|
| 83 |
0 |
| svp = hv_fetch(math_int64_c_api_hash, "SvI64", 5, 0);
|
| 84 |
0 |
▶ | if (!svp || !*svp) {
|
Branch: 2 branches
| Branch | True | False | Total |
| if (!svp || !*svp) {
|
0 |
0 |
0 |
| if (!svp || !*svp) {
|
0 |
0 |
0 |
|
| 85 |
0 |
▶ | sv_setpv(ERRSV, "Unable to fetch pointer 'SvI64' C function from Math::Int64");
|
Branch: 1 branch
| Branch | True | False | Total |
| sv_setpv(ERRSV, "Unable to fetch pointer 'SvI64' C function from Math::Int64");
|
0 |
0 |
0 |
|
| 86 |
0 |
▶ | SvSETMAGIC(ERRSV);
|
Branch: 2 branches
| Branch | True | False | Total |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
|
| 87 |
0 |
| return 0;
|
| 88 |
|
| }
|
| 89 |
0 |
| math_int64_c_api_SvI64 = INT2PTR(void *, SvIV(*svp));
|
| 90 |
0 |
| svp = hv_fetch(math_int64_c_api_hash, "SvI64OK", 7, 0);
|
| 91 |
0 |
▶ | if (!svp || !*svp) {
|
Branch: 2 branches
| Branch | True | False | Total |
| if (!svp || !*svp) {
|
0 |
0 |
0 |
| if (!svp || !*svp) {
|
0 |
0 |
0 |
|
| 92 |
0 |
▶ | sv_setpv(ERRSV, "Unable to fetch pointer 'SvI64OK' C function from Math::Int64");
|
Branch: 1 branch
| Branch | True | False | Total |
| sv_setpv(ERRSV, "Unable to fetch pointer 'SvI64OK' C function from Math::Int64");
|
0 |
0 |
0 |
|
| 93 |
0 |
▶ | SvSETMAGIC(ERRSV);
|
Branch: 2 branches
| Branch | True | False | Total |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
|
| 94 |
0 |
| return 0;
|
| 95 |
|
| }
|
| 96 |
0 |
| math_int64_c_api_SvI64OK = INT2PTR(void *, SvIV(*svp));
|
| 97 |
0 |
| svp = hv_fetch(math_int64_c_api_hash, "SvU64", 5, 0);
|
| 98 |
0 |
▶ | if (!svp || !*svp) {
|
Branch: 2 branches
| Branch | True | False | Total |
| if (!svp || !*svp) {
|
0 |
0 |
0 |
| if (!svp || !*svp) {
|
0 |
0 |
0 |
|
| 99 |
0 |
▶ | sv_setpv(ERRSV, "Unable to fetch pointer 'SvU64' C function from Math::Int64");
|
Branch: 1 branch
| Branch | True | False | Total |
| sv_setpv(ERRSV, "Unable to fetch pointer 'SvU64' C function from Math::Int64");
|
0 |
0 |
0 |
|
| 100 |
0 |
▶ | SvSETMAGIC(ERRSV);
|
Branch: 2 branches
| Branch | True | False | Total |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
|
| 101 |
0 |
| return 0;
|
| 102 |
|
| }
|
| 103 |
0 |
| math_int64_c_api_SvU64 = INT2PTR(void *, SvIV(*svp));
|
| 104 |
0 |
| svp = hv_fetch(math_int64_c_api_hash, "SvU64OK", 7, 0);
|
| 105 |
0 |
▶ | if (!svp || !*svp) {
|
Branch: 2 branches
| Branch | True | False | Total |
| if (!svp || !*svp) {
|
0 |
0 |
0 |
| if (!svp || !*svp) {
|
0 |
0 |
0 |
|
| 106 |
0 |
▶ | sv_setpv(ERRSV, "Unable to fetch pointer 'SvU64OK' C function from Math::Int64");
|
Branch: 1 branch
| Branch | True | False | Total |
| sv_setpv(ERRSV, "Unable to fetch pointer 'SvU64OK' C function from Math::Int64");
|
0 |
0 |
0 |
|
| 107 |
0 |
▶ | SvSETMAGIC(ERRSV);
|
Branch: 2 branches
| Branch | True | False | Total |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
|
| 108 |
0 |
| return 0;
|
| 109 |
|
| }
|
| 110 |
0 |
| math_int64_c_api_SvU64OK = INT2PTR(void *, SvIV(*svp));
|
| 111 |
0 |
| svp = hv_fetch(math_int64_c_api_hash, "newSVi64", 8, 0);
|
| 112 |
0 |
▶ | if (!svp || !*svp) {
|
Branch: 2 branches
| Branch | True | False | Total |
| if (!svp || !*svp) {
|
0 |
0 |
0 |
| if (!svp || !*svp) {
|
0 |
0 |
0 |
|
| 113 |
0 |
▶ | sv_setpv(ERRSV, "Unable to fetch pointer 'newSVi64' C function from Math::Int64");
|
Branch: 1 branch
| Branch | True | False | Total |
| sv_setpv(ERRSV, "Unable to fetch pointer 'newSVi64' C function from Math::Int64");
|
0 |
0 |
0 |
|
| 114 |
0 |
▶ | SvSETMAGIC(ERRSV);
|
Branch: 2 branches
| Branch | True | False | Total |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
|
| 115 |
0 |
| return 0;
|
| 116 |
|
| }
|
| 117 |
0 |
| math_int64_c_api_newSVi64 = INT2PTR(void *, SvIV(*svp));
|
| 118 |
0 |
| svp = hv_fetch(math_int64_c_api_hash, "newSVu64", 8, 0);
|
| 119 |
0 |
▶ | if (!svp || !*svp) {
|
Branch: 2 branches
| Branch | True | False | Total |
| if (!svp || !*svp) {
|
0 |
0 |
0 |
| if (!svp || !*svp) {
|
0 |
0 |
0 |
|
| 120 |
0 |
▶ | sv_setpv(ERRSV, "Unable to fetch pointer 'newSVu64' C function from Math::Int64");
|
Branch: 1 branch
| Branch | True | False | Total |
| sv_setpv(ERRSV, "Unable to fetch pointer 'newSVu64' C function from Math::Int64");
|
0 |
0 |
0 |
|
| 121 |
0 |
▶ | SvSETMAGIC(ERRSV);
|
Branch: 2 branches
| Branch | True | False | Total |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
|
| 122 |
0 |
| return 0;
|
| 123 |
|
| }
|
| 124 |
0 |
| math_int64_c_api_newSVu64 = INT2PTR(void *, SvIV(*svp));
|
| 125 |
0 |
| svp = hv_fetch(math_int64_c_api_hash, "randU64", 7, 0);
|
| 126 |
0 |
▶ | if (!svp || !*svp) {
|
Branch: 2 branches
| Branch | True | False | Total |
| if (!svp || !*svp) {
|
0 |
0 |
0 |
| if (!svp || !*svp) {
|
0 |
0 |
0 |
|
| 127 |
0 |
▶ | sv_setpv(ERRSV, "Unable to fetch pointer 'randU64' C function from Math::Int64");
|
Branch: 1 branch
| Branch | True | False | Total |
| sv_setpv(ERRSV, "Unable to fetch pointer 'randU64' C function from Math::Int64");
|
0 |
0 |
0 |
|
| 128 |
0 |
▶ | SvSETMAGIC(ERRSV);
|
Branch: 2 branches
| Branch | True | False | Total |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
| SvSETMAGIC(ERRSV);
|
0 |
0 |
0 |
|
| 129 |
0 |
| return 0;
|
| 130 |
|
| }
|
| 131 |
0 |
| math_int64_c_api_randU64 = INT2PTR(void *, SvIV(*svp));
|
| 132 |
|
|
|
| 133 |
0 |
| return 1;
|
| 134 |
|
| } |