Commit 75cdc3b6 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Don't use div and ldiv function.

parent 5e407cec
......@@ -2059,8 +2059,14 @@ int CDECL MSVCRT__gcvt_s(char *buff, MSVCRT_size_t size, double number, int digi
#ifdef __i386__
unsigned __int64 CDECL MSVCRT_div(int num, int denom)
{
div_t dt = div(num,denom);
return ((unsigned __int64)dt.rem << 32) | (unsigned int)dt.quot;
union {
MSVCRT_div_t div;
unsigned __int64 uint64;
} ret;
ret.div.quot = num / denom;
ret.div.rem = num % denom;
return ret.uint64;
}
#else
/*********************************************************************
......@@ -2070,13 +2076,11 @@ unsigned __int64 CDECL MSVCRT_div(int num, int denom)
*/
MSVCRT_div_t CDECL MSVCRT_div(int num, int denom)
{
div_t dt = div(num,denom);
MSVCRT_div_t ret;
ret.quot = dt.quot;
ret.rem = dt.rem;
return ret;
MSVCRT_div_t ret;
ret.quot = num / denom;
ret.rem = num % denom;
return ret;
}
#endif /* ifdef __i386__ */
......@@ -2089,8 +2093,14 @@ MSVCRT_div_t CDECL MSVCRT_div(int num, int denom)
#ifdef __i386__
unsigned __int64 CDECL MSVCRT_ldiv(MSVCRT_long num, MSVCRT_long denom)
{
ldiv_t ldt = ldiv(num,denom);
return ((unsigned __int64)ldt.rem << 32) | (MSVCRT_ulong)ldt.quot;
union {
MSVCRT_ldiv_t ldiv;
unsigned __int64 uint64;
} ret;
ret.ldiv.quot = num / denom;
ret.ldiv.rem = num % denom;
return ret.uint64;
}
#else
/*********************************************************************
......@@ -2100,13 +2110,11 @@ unsigned __int64 CDECL MSVCRT_ldiv(MSVCRT_long num, MSVCRT_long denom)
*/
MSVCRT_ldiv_t CDECL MSVCRT_ldiv(MSVCRT_long num, MSVCRT_long denom)
{
ldiv_t result = ldiv(num,denom);
MSVCRT_ldiv_t ret;
ret.quot = result.quot;
ret.rem = result.rem;
MSVCRT_ldiv_t ret;
return ret;
ret.quot = num / denom;
ret.rem = num % denom;
return ret;
}
#endif /* ifdef __i386__ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment