use _udiv128 for divUint on msvc 2019

update-fork
MITSUNARI Shigeo 5 years ago
parent a004a00952
commit a53b6b7f4c
  1. 4
      include/mcl/vint.hpp
  2. 1
      test/vint_test.cpp

@ -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 #if MCL_SIZEOF_UNIT == 8
inline uint64_t divUnit(uint64_t *pr, uint64_t H, uint64_t L, uint64_t y) 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 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) }; uint32_t py[2] = { uint32_t(y), uint32_t(y >> 32) };
size_t xn = 4; 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]); *pr = make64(r[1], r[0]);
return make64(q[1], q[0]); return make64(q[1], q[0]);
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
#error "divUnit for uint64_t is not supported" return _udiv128(H, L, y, pr);
#else #else
typedef __attribute__((mode(TI))) unsigned int uint128; typedef __attribute__((mode(TI))) unsigned int uint128;
uint128 t = (uint128(H) << 64) | L; uint128 t = (uint128(H) << 64) | L;

@ -9,6 +9,7 @@
#include <cybozu/xorshift.hpp> #include <cybozu/xorshift.hpp>
#ifndef MCL_USE_VINT #ifndef MCL_USE_VINT
#include <gmpxx.h> #include <gmpxx.h>
#include <cybozu/link_mpir.hpp>
#endif #endif
#define PUT(x) std::cout << #x "=" << x << std::endl; #define PUT(x) std::cout << #x "=" << x << std::endl;

Loading…
Cancel
Save