From 79624a1fec75c1ccfdc00bbe049fe5ffad51639c Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Sat, 1 May 2021 12:26:11 +0900 Subject: [PATCH] config.hpp define const var --- include/mcl/config.hpp | 34 ++++++++++++++++++++++++++++++++++ include/mcl/gmp_util.hpp | 23 +---------------------- include/mcl/vint.hpp | 15 ++------------- 3 files changed, 37 insertions(+), 35 deletions(-) create mode 100644 include/mcl/config.hpp diff --git a/include/mcl/config.hpp b/include/mcl/config.hpp new file mode 100644 index 0000000..fd290e1 --- /dev/null +++ b/include/mcl/config.hpp @@ -0,0 +1,34 @@ +#pragma once +/** + @file + @brief constant macro + @author MITSUNARI Shigeo(@herumi) + @license modified new BSD license + http://opensource.org/licenses/BSD-3-Clause +*/ +#include + +#ifndef MCL_SIZEOF_UNIT + #if defined(CYBOZU_OS_BIT) && (CYBOZU_OS_BIT == 32) + #define MCL_SIZEOF_UNIT 4 + #else + #define MCL_SIZEOF_UNIT 8 + #endif +#endif + +#ifndef MCL_MAX_BIT_SIZE + #define MCL_MAX_BIT_SIZE 512 +#endif + +namespace mcl { + +namespace fp { + +#if MCL_SIZEOF_UNIT == 8 +typedef uint64_t Unit; +#else +typedef uint32_t Unit; +#endif +#define MCL_UNIT_BIT_SIZE (MCL_SIZEOF_UNIT * 8) + +} } // mcl::fp diff --git a/include/mcl/gmp_util.hpp b/include/mcl/gmp_util.hpp index b77c022..87fa6a4 100644 --- a/include/mcl/gmp_util.hpp +++ b/include/mcl/gmp_util.hpp @@ -15,6 +15,7 @@ #include #endif #include +#include #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4616) @@ -27,9 +28,6 @@ #if defined(__EMSCRIPTEN__) || defined(__wasm__) #define MCL_USE_VINT #endif -#ifndef MCL_MAX_BIT_SIZE - #define MCL_MAX_BIT_SIZE 512 -#endif #ifdef MCL_USE_VINT #include typedef mcl::Vint mpz_class; @@ -41,27 +39,8 @@ typedef mcl::Vint mpz_class; #endif #endif -#ifndef MCL_SIZEOF_UNIT - #if defined(CYBOZU_OS_BIT) && (CYBOZU_OS_BIT == 32) - #define MCL_SIZEOF_UNIT 4 - #else - #define MCL_SIZEOF_UNIT 8 - #endif -#endif - namespace mcl { -namespace fp { - -#if MCL_SIZEOF_UNIT == 8 -typedef uint64_t Unit; -#else -typedef uint32_t Unit; -#endif -#define MCL_UNIT_BIT_SIZE (MCL_SIZEOF_UNIT * 8) - -} // mcl::fp - namespace gmp { typedef mpz_class ImplType; diff --git a/include/mcl/vint.hpp b/include/mcl/vint.hpp index 5bf6ec3..7e5accb 100644 --- a/include/mcl/vint.hpp +++ b/include/mcl/vint.hpp @@ -11,6 +11,7 @@ #ifndef CYBOZU_DONT_USE_STRING #include #endif +#include #include #include #include @@ -24,23 +25,11 @@ #error "define MCL_MAX_BIT_SZIE" #endif -#ifndef MCL_SIZEOF_UNIT - #if defined(CYBOZU_OS_BIT) && (CYBOZU_OS_BIT == 32) - #define MCL_SIZEOF_UNIT 4 - #else - #define MCL_SIZEOF_UNIT 8 - #endif -#endif - namespace mcl { namespace vint { -#if MCL_SIZEOF_UNIT == 8 -typedef uint64_t Unit; -#else -typedef uint32_t Unit; -#endif +typedef fp::Unit Unit; template struct RoundUp {