Signed-off-by: Serge Gautherie winehq-git_serge_180711@gautherie.fr --- dlls/msvcrt/math.c | 9 +++++---- dlls/ucrtbase/tests/misc.c | 13 +++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c index 2e91547..ae4a267 100644 --- a/dlls/msvcrt/math.c +++ b/dlls/msvcrt/math.c @@ -2114,11 +2114,12 @@ MSVCRT_ldiv_t CDECL MSVCRT_ldiv(MSVCRT_long num, MSVCRT_long denom) /********************************************************************* * lldiv (MSVCR100.@) */ -MSVCRT_lldiv_t* CDECL MSVCRT_lldiv(MSVCRT_lldiv_t *ret, - MSVCRT_longlong num, MSVCRT_longlong denom) +MSVCRT_lldiv_t CDECL MSVCRT_lldiv(MSVCRT_longlong num, MSVCRT_longlong denom) { - ret->quot = num / denom; - ret->rem = num % denom; + MSVCRT_lldiv_t ret; + + ret.quot = num / denom; + ret.rem = num % denom;
return ret; } diff --git a/dlls/ucrtbase/tests/misc.c b/dlls/ucrtbase/tests/misc.c index cd100cf..3bc020d 100644 --- a/dlls/ucrtbase/tests/misc.c +++ b/dlls/ucrtbase/tests/misc.c @@ -520,12 +520,17 @@ static void test__sopen_s(void)
static void test_lldiv(void) { - static lldiv_t* (CDECL *p_lldiv)(lldiv_t*,LONGLONG,LONGLONG) = (void*)lldiv; lldiv_t r;
- p_lldiv(&r, (LONGLONG)0x111 << 32 | 0x222, (LONGLONG)1 << 32); - ok(r.quot == 0x111, "quot = %s\n", wine_dbgstr_longlong(r.quot)); - ok(r.rem == 0x222, "rem = %s\n", wine_dbgstr_longlong(r.rem)); + /* 64bit / 8bit = _60bit quotient_ */ + r = lldiv(0x69CF00120033E78A, 0x30); + ok(r.quot == 0x02345000600114D2, "quot = %s\n", wine_dbgstr_longlong(r.quot)); + ok(r.rem == 0x2A, "rem = %s\n", wine_dbgstr_longlong(r.rem)); + + /* 64bit / 56bit = _52bit remainder_ */ + r = lldiv(0x243A56789ABCDEF0, (LONGLONG)0x12 << 48); + ok(r.quot == 0x0203, "quot = %s\n", wine_dbgstr_longlong(r.quot)); + ok(r.rem == 0x000456789ABCDEF0, "rem = %s\n", wine_dbgstr_longlong(r.rem)); }
static void test_isblank(void)
Hi Serge,
On 7/10/20 9:17 PM, Serge Gautherie wrote:
static void test_lldiv(void) {
static lldiv_t* (CDECL *p_lldiv)(lldiv_t*,LONGLONG,LONGLONG) = (void*)lldiv; lldiv_t r;
p_lldiv(&r, (LONGLONG)0x111 << 32 | 0x222, (LONGLONG)1 << 32);
ok(r.quot == 0x111, "quot = %s\n", wine_dbgstr_longlong(r.quot));
ok(r.rem == 0x222, "rem = %s\n", wine_dbgstr_longlong(r.rem));
Please don't remove old test (the way how the function is called needs to be changed but the arguments can be preserved).
- /* 64bit / 8bit = _60bit quotient_ */
This comment is not really needed, please remove it.
- r = lldiv(0x69CF00120033E78A, 0x30);
I'm not sure if it's still the case but we were avoiding LONGLONG constants for compatibility reasons. That's why the tests were using (ULONGLONG)0x... << 32 | 0x... to compute the values.
Thanks, Piotr