config.hpp define const var

2merge^2
MITSUNARI Shigeo 4 years ago
parent 1c699118c6
commit 79624a1fec
  1. 34
      include/mcl/config.hpp
  2. 23
      include/mcl/gmp_util.hpp
  3. 15
      include/mcl/vint.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 <cybozu/inttype.hpp>
#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

@ -15,6 +15,7 @@
#include <cybozu/exception.hpp>
#endif
#include <mcl/randgen.hpp>
#include <mcl/config.hpp>
#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 <mcl/vint.hpp>
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;

@ -11,6 +11,7 @@
#ifndef CYBOZU_DONT_USE_STRING
#include <iostream>
#endif
#include <mcl/config.hpp>
#include <mcl/array.hpp>
#include <mcl/util.hpp>
#include <mcl/randgen.hpp>
@ -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<size_t x>
struct RoundUp {

Loading…
Cancel
Save