From a53b6b7f4c6b401029c99ffd3154f5868d868a94 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Wed, 4 Mar 2020 09:49:48 +0900 Subject: [PATCH] use _udiv128 for divUint on msvc 2019 --- include/mcl/vint.hpp | 4 ++-- test/vint_test.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/mcl/vint.hpp b/include/mcl/vint.hpp index 40f43b2..13e24e7 100644 --- a/include/mcl/vint.hpp +++ b/include/mcl/vint.hpp @@ -150,7 +150,7 @@ inline uint32_t divUnit(uint32_t *pr, uint32_t H, uint32_t L, uint32_t y) #if MCL_SIZEOF_UNIT == 8 inline uint64_t divUnit(uint64_t *pr, uint64_t H, uint64_t L, uint64_t y) { -#if defined(MCL_VINT_64BIT_PORTABLE) +#if defined(MCL_VINT_64BIT_PORTABLE) || (defined(_MSC_VER) && _MSC_VER < 1920) uint32_t px[4] = { uint32_t(L), uint32_t(L >> 32), uint32_t(H), uint32_t(H >> 32) }; uint32_t py[2] = { uint32_t(y), uint32_t(y >> 32) }; size_t xn = 4; @@ -162,7 +162,7 @@ inline uint64_t divUnit(uint64_t *pr, uint64_t H, uint64_t L, uint64_t y) *pr = make64(r[1], r[0]); return make64(q[1], q[0]); #elif defined(_MSC_VER) - #error "divUnit for uint64_t is not supported" + return _udiv128(H, L, y, pr); #else typedef __attribute__((mode(TI))) unsigned int uint128; uint128 t = (uint128(H) << 64) | L; diff --git a/test/vint_test.cpp b/test/vint_test.cpp index ab37814..39c3688 100644 --- a/test/vint_test.cpp +++ b/test/vint_test.cpp @@ -9,6 +9,7 @@ #include #ifndef MCL_USE_VINT #include +#include #endif #define PUT(x) std::cout << #x "=" << x << std::endl;