mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-23 06:35:31 +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
1285ab5dc2
commit
9803d07a63
|
@ -122,6 +122,7 @@
|
|||
#define MBEDTLS_HAVE_INT64
|
||||
typedef int64_t mbedtls_mpi_sint;
|
||||
typedef uint64_t mbedtls_mpi_uint;
|
||||
/* mbedtls_t_udbl defined as 128-bit unsigned int */
|
||||
typedef unsigned int mbedtls_t_udbl __attribute__((mode(TI)));
|
||||
#define MBEDTLS_HAVE_UDBL
|
||||
#else
|
||||
|
|
|
@ -1221,10 +1221,11 @@ static mbedtls_mpi_uint mbedtls_int_div_int( mbedtls_mpi_uint u1,
|
|||
#if defined(MBEDTLS_HAVE_UDBL)
|
||||
mbedtls_t_udbl dividend, quotient;
|
||||
#else
|
||||
const mbedtls_mpi_uint radix = 1 << biH;
|
||||
const mbedtls_mpi_uint radix = (mbedtls_mpi_uint) 1 << biH;
|
||||
const mbedtls_mpi_uint uint_halfword_mask = ( (mbedtls_mpi_uint) 1 << biH ) - 1;
|
||||
mbedtls_mpi_uint d0, d1, q0, q1, rAX, r0, quotient;
|
||||
mbedtls_mpi_uint u0_msw, u0_lsw;
|
||||
int s;
|
||||
size_t s;
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -1245,7 +1246,7 @@ static mbedtls_mpi_uint mbedtls_int_div_int( mbedtls_mpi_uint u1,
|
|||
quotient = ( (mbedtls_t_udbl) 1 << biL ) - 1;
|
||||
|
||||
if( r != NULL )
|
||||
*r = dividend - (quotient * d);
|
||||
*r = (mbedtls_mpi_uint)( dividend - (quotient * d ) );
|
||||
|
||||
return (mbedtls_mpi_uint) quotient;
|
||||
#else
|
||||
|
@ -1262,14 +1263,14 @@ static mbedtls_mpi_uint mbedtls_int_div_int( mbedtls_mpi_uint u1,
|
|||
d = d << s;
|
||||
|
||||
u1 = u1 << s;
|
||||
u1 |= ( u0 >> ( 32 - s ) ) & ( -s >> 31 );
|
||||
u1 |= ( u0 >> ( biL - s ) ) & ( -(mbedtls_mpi_sint)s >> ( biL - 1 ) );
|
||||
u0 = u0 << s;
|
||||
|
||||
d1 = d >> biH;
|
||||
d0 = d & 0xffff;
|
||||
d0 = d & uint_halfword_mask;
|
||||
|
||||
u0_msw = u0 >> biH;
|
||||
u0_lsw = u0 & 0xffff;
|
||||
u0_lsw = u0 & uint_halfword_mask;
|
||||
|
||||
/*
|
||||
* Find the first quotient and remainder
|
||||
|
|
Loading…
Reference in a new issue