mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-07-08 04:00:40 +00:00
Fix for MPI divide on MSVC
Resolves multiple platform issues when building bignum.c with Microsoft Visual Studio.
This commit is contained in:
parent
e5049f46d4
commit
6901e50d81
|
@ -136,6 +136,7 @@ typedef uint32_t t_udbl;
|
||||||
defined(__s390x__) || defined(__mips64) ) )
|
defined(__s390x__) || defined(__mips64) ) )
|
||||||
typedef int64_t t_sint;
|
typedef int64_t t_sint;
|
||||||
typedef uint64_t t_uint;
|
typedef uint64_t t_uint;
|
||||||
|
/* mbedtls_t_udbl defined as 128-bit unsigned int */
|
||||||
typedef unsigned int t_udbl __attribute__((mode(TI)));
|
typedef unsigned int t_udbl __attribute__((mode(TI)));
|
||||||
#define POLARSSL_HAVE_UDBL
|
#define POLARSSL_HAVE_UDBL
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1097,6 +1097,12 @@ static t_uint int_div_int(t_uint u1, t_uint u0, t_uint d, t_uint *r)
|
||||||
{
|
{
|
||||||
#if defined(POLARSSL_HAVE_UDBL)
|
#if defined(POLARSSL_HAVE_UDBL)
|
||||||
t_udbl dividend, quotient;
|
t_udbl dividend, quotient;
|
||||||
|
#else
|
||||||
|
const t_uint radix = (t_uint) 1 << biH;
|
||||||
|
const t_uint uint_halfword_mask = ( (t_uint) 1 << biH ) - 1;
|
||||||
|
t_uint d0, d1, q0, q1, rAX, r0, quotient;
|
||||||
|
t_uint u0_msw, u0_lsw;
|
||||||
|
size_t s;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1117,7 +1123,7 @@ static t_uint int_div_int(t_uint u1, t_uint u0, t_uint d, t_uint *r)
|
||||||
quotient = ( (t_udbl) 1 << biL ) - 1;
|
quotient = ( (t_udbl) 1 << biL ) - 1;
|
||||||
|
|
||||||
if( r != NULL )
|
if( r != NULL )
|
||||||
*r = dividend - (quotient * d);
|
*r = (t_uint)( dividend - (quotient * d ) );
|
||||||
|
|
||||||
return (t_uint) quotient;
|
return (t_uint) quotient;
|
||||||
#else
|
#else
|
||||||
|
@ -1138,14 +1144,14 @@ static t_uint int_div_int(t_uint u1, t_uint u0, t_uint d, t_uint *r)
|
||||||
d = d << s;
|
d = d << s;
|
||||||
|
|
||||||
u1 = u1 << s;
|
u1 = u1 << s;
|
||||||
u1 |= (u0 >> (32 - s)) & ( (-s) >> 31);
|
u1 |= ( u0 >> ( biL - s ) ) & ( -(t_sint)s >> ( biL - 1 ) );
|
||||||
u0 = u0 << s;
|
u0 = u0 << s;
|
||||||
|
|
||||||
d1 = d >> biH;
|
d1 = d >> biH;
|
||||||
d0 = d & 0xffff;
|
d0 = d & uint_halfword_mask;
|
||||||
|
|
||||||
u0_msw = u0 >> biH;
|
u0_msw = u0 >> biH;
|
||||||
u0_lsw = u0 & 0xffff;
|
u0_lsw = u0 & uint_halfword_mask;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the first quotient and remainder
|
* Find the first quotient and remainder
|
||||||
|
|
Loading…
Reference in a new issue