| 1 |
|
| /* |
| 2 |
|
| * perl_math_int64.h - This file is in the public domain |
| 3 |
|
| * |
| 4 |
|
| * Author: Salvador Fandino <sfandino@yahoo.com> |
| 5 |
|
| * Version: 1.2 |
| 6 |
|
| */ |
| 7 |
|
| |
| 8 |
|
| #include "EXTERN.h" |
| 9 |
|
| #include "perl.h" |
| 10 |
|
| #include "ppport.h" |
| 11 |
|
| |
| 12 |
|
| #ifdef __MINGW32__ |
| 13 |
|
| #include <stdint.h> |
| 14 |
|
| #endif |
| 15 |
|
| |
| 16 |
|
| #ifdef _MSC_VER |
| 17 |
|
| #include <stdlib.h> |
| 18 |
|
| typedef __int64 int64_t; |
| 19 |
|
| typedef unsigned __int64 uint64_t; |
| 20 |
|
| #endif |
| 21 |
|
| |
| 22 |
|
| /* you may need to add a typemap for int64_t here if it is not defined |
| 23 |
|
| by default in your C header files */ |
| 24 |
|
| |
| 25 |
|
| HV *math_int64_capi_hash; |
| 26 |
|
| int math_int64_capi_version; |
| 27 |
|
| SV *(*math_int64_capi_newSVi64)(pTHX_ int64_t); |
| 28 |
|
| SV *(*math_int64_capi_newSVu64)(pTHX_ uint64_t); |
| 29 |
|
| int64_t (*math_int64_capi_SvI64)(pTHX_ SV*); |
| 30 |
|
| uint64_t (*math_int64_capi_SvU64)(pTHX_ SV*); |
| 31 |
|
| int (*math_int64_capi_SvI64OK)(pTHX_ SV*); |
| 32 |
|
| int (*math_int64_capi_SvU64OK)(pTHX_ SV*); |
| 33 |
|
| |
| 34 |
|
| #define fetch_ptr(to, name) \ |
| 35 |
|
| svp = hv_fetchs(math_int64_capi_hash, name, 0); \ |
| 36 |
|
| if (!svp || !*svp) Perl_croak(aTHX_ "Unable to fetch pointer for " name " function"); \ |
| 37 |
|
| to = INT2PTR(void *, SvIV(*svp)) |
| 38 |
|
| |
| 39 |
|
| void |
| 40 |
0 |
| math_int64_boot(pTHX_ int version) { |
| 41 |
0 |
| dSP; |
| 42 |
|
| SV **svp; |
| 43 |
0 |
| eval_pv("require Math::Int64", TRUE); |
| 44 |
0 |
▶ | if (SvTRUE(ERRSV)) |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvTRUE(ERRSV)) |
0 |
0 |
0 |
| if (SvTRUE(ERRSV)) |
0 |
0 |
0 |
|
| 45 |
0 |
▶ | Perl_croak(aTHX_ "Unable to load Math::Int64: %s", SvPV_nolen(ERRSV)); |
Branch: 1 branch
| Branch | True | False | Total |
| Perl_croak(aTHX_ "Unable to load Math::Int64: %s", SvPV_nolen(ERRSV)); |
0 |
0 |
0 |
|
| 46 |
|
| |
| 47 |
0 |
| math_int64_capi_hash = get_hv("Math::Int64::C_API", 0); |
| 48 |
0 |
▶ | if (!math_int64_capi_hash) Perl_croak(aTHX_ "Unable to load Math::Int64 C API"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!math_int64_capi_hash) Perl_croak(aTHX_ "Unable to load Math::Int64 C API"); |
0 |
0 |
0 |
|
| 49 |
|
| |
| 50 |
0 |
| math_int64_capi_version = SvIV(*hv_fetchs(math_int64_capi_hash, "version", 1)); |
| 51 |
0 |
▶ | if (math_int64_capi_version < version) |
Branch: 1 branch
| Branch | True | False | Total |
| if (math_int64_capi_version < version) |
0 |
0 |
0 |
|
| 52 |
0 |
| Perl_croak(aTHX_ "Math::Int64 C API version mismatch, expected %d, found %d", |
| 53 |
|
| version, math_int64_capi_version); |
| 54 |
|
| |
| 55 |
0 |
▶ | fetch_ptr(math_int64_capi_newSVi64, "newSVi64"); |
Branch: 2 branches
| Branch | True | False | Total |
| fetch_ptr(math_int64_capi_newSVi64, "newSVi64"); |
0 |
0 |
0 |
| fetch_ptr(math_int64_capi_newSVi64, "newSVi64"); |
0 |
0 |
0 |
|
| 56 |
0 |
▶ | fetch_ptr(math_int64_capi_newSVu64, "newSVu64"); |
Branch: 2 branches
| Branch | True | False | Total |
| fetch_ptr(math_int64_capi_newSVu64, "newSVu64"); |
0 |
0 |
0 |
| fetch_ptr(math_int64_capi_newSVu64, "newSVu64"); |
0 |
0 |
0 |
|
| 57 |
0 |
▶ | fetch_ptr(math_int64_capi_SvI64, "SvI64"); |
Branch: 2 branches
| Branch | True | False | Total |
| fetch_ptr(math_int64_capi_SvI64, "SvI64"); |
0 |
0 |
0 |
| fetch_ptr(math_int64_capi_SvI64, "SvI64"); |
0 |
0 |
0 |
|
| 58 |
0 |
▶ | fetch_ptr(math_int64_capi_SvU64, "SvU64"); |
Branch: 2 branches
| Branch | True | False | Total |
| fetch_ptr(math_int64_capi_SvU64, "SvU64"); |
0 |
0 |
0 |
| fetch_ptr(math_int64_capi_SvU64, "SvU64"); |
0 |
0 |
0 |
|
| 59 |
0 |
▶ | fetch_ptr(math_int64_capi_SvI64OK, "SvI64OK"); |
Branch: 2 branches
| Branch | True | False | Total |
| fetch_ptr(math_int64_capi_SvI64OK, "SvI64OK"); |
0 |
0 |
0 |
| fetch_ptr(math_int64_capi_SvI64OK, "SvI64OK"); |
0 |
0 |
0 |
|
| 60 |
0 |
▶ | fetch_ptr(math_int64_capi_SvU64OK, "SvU64OK"); |
Branch: 2 branches
| Branch | True | False | Total |
| fetch_ptr(math_int64_capi_SvU64OK, "SvU64OK"); |
0 |
0 |
0 |
| fetch_ptr(math_int64_capi_SvU64OK, "SvU64OK"); |
0 |
0 |
0 |
|
| 61 |
0 |
| } |