From 229cc0166ceefbd49fffd788c2565ab5727c0257 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Thu, 3 Aug 2017 07:17:57 +0900 Subject: [PATCH] define macro for emscripten --- include/mcl/gmp_util.hpp | 3 +++ include/mcl/op.hpp | 4 ++++ include/mcl/vint.hpp | 4 ++++ test/bn_test.cpp | 6 +++--- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/mcl/gmp_util.hpp b/include/mcl/gmp_util.hpp index 84b74d5..b9ae3c5 100644 --- a/include/mcl/gmp_util.hpp +++ b/include/mcl/gmp_util.hpp @@ -22,6 +22,9 @@ #pragma warning(disable : 4512) #pragma warning(disable : 4146) #endif +#ifdef __EMSCRIPTEN__ + #define MCL_USE_VINT +#endif #ifdef MCL_USE_VINT #include typedef mcl::Vint mpz_class; diff --git a/include/mcl/op.hpp b/include/mcl/op.hpp index 9e02058..b5d7045 100644 --- a/include/mcl/op.hpp +++ b/include/mcl/op.hpp @@ -11,6 +11,10 @@ #ifndef MCL_MAX_BIT_SIZE #define MCL_MAX_BIT_SIZE 521 #endif +#ifdef __EMSCRIPTEN__ + #define MCL_DONT_USE_XBYAK + #define MCL_DONT_USE_OPENSSL +#endif #if !defined(MCL_DONT_USE_XBYAK) && (defined(_WIN64) || defined(__x86_64__)) #define MCL_USE_XBYAK #endif diff --git a/include/mcl/vint.hpp b/include/mcl/vint.hpp index fda212e..9ac7e3f 100644 --- a/include/mcl/vint.hpp +++ b/include/mcl/vint.hpp @@ -14,6 +14,10 @@ #include #include +#ifdef __EMSCRIPTEN__ + #define MCL_VINT_64BIT_PORTABLE +#endif + #ifndef MCL_SIZEOF_UNIT #if defined(CYBOZU_OS_BIT) && (CYBOZU_OS_BIT == 32) #define MCL_SIZEOF_UNIT 4 diff --git a/test/bn_test.cpp b/test/bn_test.cpp index 2ce7ba0..8637d29 100644 --- a/test/bn_test.cpp +++ b/test/bn_test.cpp @@ -252,10 +252,10 @@ void testPairing(const G1& P, const G2& Q, const char *eStr) Fp12 e = e1, ea; G1 Pa; G2 Qa; -#if MCL_SIZEOF_UNIT == 8 - const int count = 1000; -#else +#if defined(__EMSCRIPTEN__) || MCL_SIZEOF_UNIT == 4 const int count = 100; +#else + const int count = 1000; #endif mpz_class a; cybozu::XorShift rg;