aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2019-01-12 20:50:59 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2019-01-12 20:50:59 +0800
commiteb315107776a9205c33136f5969f2dd793921041 (patch)
tree88381665b8cb11d5490a7a34fa3647712d583437
parentd8975a2ca3ec0d8f3e95bd6b063e1d63232d129c (diff)
downloadtangerine-mcl-eb315107776a9205c33136f5969f2dd793921041.tar.gz
tangerine-mcl-eb315107776a9205c33136f5969f2dd793921041.tar.zst
tangerine-mcl-eb315107776a9205c33136f5969f2dd793921041.zip
disable cast-function-type warning of g++-8
-rw-r--r--include/mcl/fp.hpp10
-rw-r--r--include/mcl/fp_tower.hpp30
-rw-r--r--include/mcl/op.hpp9
-rw-r--r--src/fp_generator.hpp2
4 files changed, 30 insertions, 21 deletions
diff --git a/include/mcl/fp.hpp b/include/mcl/fp.hpp
index a8e9ac8..ffb4699 100644
--- a/include/mcl/fp.hpp
+++ b/include/mcl/fp.hpp
@@ -132,15 +132,15 @@ public:
}
inv(inv2_, 2);
#ifdef MCL_XBYAK_DIRECT_CALL
- add = (void (*)(FpT& z, const FpT& x, const FpT& y))op_.fp_addA_;
+ add = fp::func_ptr_cast<void (*)(FpT& z, const FpT& x, const FpT& y)>(op_.fp_addA_);
if (add == 0) add = addC;
- sub = (void (*)(FpT& z, const FpT& x, const FpT& y))op_.fp_subA_;
+ sub = fp::func_ptr_cast<void (*)(FpT& z, const FpT& x, const FpT& y)>(op_.fp_subA_);
if (sub == 0) sub = subC;
- neg = (void (*)(FpT& y, const FpT& x))op_.fp_negA_;
+ neg = fp::func_ptr_cast<void (*)(FpT& y, const FpT& x)>(op_.fp_negA_);
if (neg == 0) neg = negC;
- mul = (void (*)(FpT& z, const FpT& x, const FpT& y))op_.fp_mulA_;
+ mul = fp::func_ptr_cast<void (*)(FpT& z, const FpT& x, const FpT& y)>(op_.fp_mulA_);
if (mul == 0) mul = mulC;
- sqr = (void (*)(FpT& y, const FpT& x))op_.fp_sqrA_;
+ sqr = fp::func_ptr_cast<void (*)(FpT& y, const FpT& x)>(op_.fp_sqrA_);
if (sqr == 0) sqr = sqrC;
#endif
*pb = true;
diff --git a/include/mcl/fp_tower.hpp b/include/mcl/fp_tower.hpp
index c68a5c2..96a6edb 100644
--- a/include/mcl/fp_tower.hpp
+++ b/include/mcl/fp_tower.hpp
@@ -151,24 +151,24 @@ public:
{
const mcl::fp::Op& op = Fp::getOp();
#ifdef MCL_XBYAK_DIRECT_CALL
- add = (void (*)(FpDblT&, const FpDblT&, const FpDblT&))op.fpDbl_addA_;
+ add = fp::func_ptr_cast<void (*)(FpDblT&, const FpDblT&, const FpDblT&)>(op.fpDbl_addA_);
if (add == 0) add = addC;
- sub = (void (*)(FpDblT&, const FpDblT&, const FpDblT&))op.fpDbl_subA_;
+ sub = fp::func_ptr_cast<void (*)(FpDblT&, const FpDblT&, const FpDblT&)>(op.fpDbl_subA_);
if (sub == 0) sub = subC;
- mod = (void (*)(Fp&, const FpDblT&))op.fpDbl_modA_;
+ mod = fp::func_ptr_cast<void (*)(Fp&, const FpDblT&)>(op.fpDbl_modA_);
if (mod == 0) mod = modC;
- addPre = (void (*)(FpDblT&, const FpDblT&, const FpDblT&))op.fpDbl_addPre;
+ addPre = fp::func_ptr_cast<void (*)(FpDblT&, const FpDblT&, const FpDblT&)>(op.fpDbl_addPre);
if (addPre == 0) addPre = addPreC;
- subPre = (void (*)(FpDblT&, const FpDblT&, const FpDblT&))op.fpDbl_subPre;
+ subPre = fp::func_ptr_cast<void (*)(FpDblT&, const FpDblT&, const FpDblT&)>(op.fpDbl_subPre);
if (subPre == 0) subPre = subPreC;
#endif
if (op.fpDbl_mulPreA_) {
- mulPre = (void (*)(FpDblT&, const Fp&, const Fp&))op.fpDbl_mulPreA_;
+ mulPre = fp::func_ptr_cast<void (*)(FpDblT&, const Fp&, const Fp&)>(op.fpDbl_mulPreA_);
} else {
mulPre = mulPreC;
}
if (op.fpDbl_sqrPreA_) {
- sqrPre = (void (*)(FpDblT&, const Fp&))op.fpDbl_sqrPreA_;
+ sqrPre = fp::func_ptr_cast<void (*)(FpDblT&, const Fp&)>(op.fpDbl_sqrPreA_);
} else {
sqrPre = sqrPreC;
}
@@ -387,19 +387,19 @@ public:
mcl::fp::Op& op = Fp::op_;
assert(op.xi_a);
#ifdef MCL_XBYAK_DIRECT_CALL
- add = (void (*)(Fp2T& z, const Fp2T& x, const Fp2T& y))op.fp2_addA_;
+ add = fp::func_ptr_cast<void (*)(Fp2T& z, const Fp2T& x, const Fp2T& y)>(op.fp2_addA_);
if (add == 0) add = addC;
- sub = (void (*)(Fp2T& z, const Fp2T& x, const Fp2T& y))op.fp2_subA_;
+ sub = fp::func_ptr_cast<void (*)(Fp2T& z, const Fp2T& x, const Fp2T& y)>(op.fp2_subA_);
if (sub == 0) sub = subC;
- neg = (void (*)(Fp2T& y, const Fp2T& x))op.fp2_negA_;
+ neg = fp::func_ptr_cast<void (*)(Fp2T& y, const Fp2T& x)>(op.fp2_negA_);
if (neg == 0) neg = negC;
- mul = (void (*)(Fp2T& z, const Fp2T& x, const Fp2T& y))op.fp2_mulA_;
+ mul = fp::func_ptr_cast<void (*)(Fp2T& z, const Fp2T& x, const Fp2T& y)>(op.fp2_mulA_);
if (mul == 0) mul = mulC;
- sqr = (void (*)(Fp2T& y, const Fp2T& x))op.fp2_sqrA_;
+ sqr = fp::func_ptr_cast<void (*)(Fp2T& y, const Fp2T& x)>(op.fp2_sqrA_);
if (sqr == 0) sqr = sqrC;
+ mul_xi = fp::func_ptr_cast<void (*)(Fp2T&, const Fp2T&)>(op.fp2_mul_xiA_);
#endif
op.fp2_inv = fp2_invW;
- mul_xi = (void (*)(Fp2T&, const Fp2T&))op.fp2_mul_xiA_;
if (mul_xi == 0) {
if (op.xi_a == 1) {
mul_xi = fp2_mul_xi_1_1iC;
@@ -688,7 +688,7 @@ struct Fp2DblT {
{
const mcl::fp::Op& op = Fp::getOp();
if (op.fp2Dbl_mulPreA_) {
- mulPre = (void (*)(Fp2DblT&, const Fp2&, const Fp2&))op.fp2Dbl_mulPreA_;
+ mulPre = fp::func_ptr_cast<void (*)(Fp2DblT&, const Fp2&, const Fp2&)>(op.fp2Dbl_mulPreA_);
} else {
if (op.isFullBit) {
mulPre = fp2Dbl_mulPreW<true>;
@@ -697,7 +697,7 @@ struct Fp2DblT {
}
}
if (op.fp2Dbl_sqrPreA_) {
- sqrPre = (void (*)(Fp2DblT&, const Fp2&))op.fp2Dbl_sqrPreA_;
+ sqrPre = fp::func_ptr_cast<void (*)(Fp2DblT&, const Fp2&)>(op.fp2Dbl_sqrPreA_);
} else {
if (op.isFullBit) {
sqrPre = fp2Dbl_sqrPreW<true>;
diff --git a/include/mcl/op.hpp b/include/mcl/op.hpp
index a3b482f..ee80c0b 100644
--- a/include/mcl/op.hpp
+++ b/include/mcl/op.hpp
@@ -127,6 +127,15 @@ typedef int (*int2u)(Unit*, const Unit*);
typedef Unit (*u1uII)(Unit*, Unit, Unit);
typedef Unit (*u3u)(Unit*, const Unit*, const Unit*);
+/*
+ disable -Wcast-function-type
+ the number of arguments of some JIT functions is smaller than that of T
+*/
+template<class T, class S>
+T func_ptr_cast(S func)
+{
+ return reinterpret_cast<T>(reinterpret_cast<void*>(func));
+}
struct Block {
const Unit *p; // pointer to original FpT.v_
size_t n;
diff --git a/src/fp_generator.hpp b/src/fp_generator.hpp
index 4e8d15a..a018c03 100644
--- a/src/fp_generator.hpp
+++ b/src/fp_generator.hpp
@@ -376,7 +376,7 @@ private:
op.fp_mulA_ = gen_mul();
prof_.set("Fp_mul", getCurr());
if (op.fp_mulA_) {
- op.fp_mul = reinterpret_cast<void4u>(op.fp_mulA_); // used in toMont/fromMont
+ op.fp_mul = fp::func_ptr_cast<void4u>(op.fp_mulA_); // used in toMont/fromMont
}
op.fp_sqrA_ = gen_sqr();
prof_.set("Fp_sqr", getCurr());