msvcrt: Added lldiv implementation.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2017-02-20 17:43:32 +01:00 committed by Alexandre Julliard
parent 3be9f9d036
commit 60c98caa94
9 changed files with 41 additions and 6 deletions

View File

@ -22,7 +22,7 @@
@ cdecl labs(long) ucrtbase.labs
@ cdecl ldiv(long long) ucrtbase.ldiv
@ cdecl -ret64 llabs(int64) ucrtbase.llabs
@ stub lldiv
@ cdecl lldiv(int64 int64) ucrtbase.lldiv
@ cdecl qsort(ptr long long ptr) ucrtbase.qsort
@ cdecl qsort_s(ptr long long ptr ptr) ucrtbase.qsort_s
@ cdecl rand() ucrtbase.rand

View File

@ -1733,7 +1733,7 @@
@ cdecl ldexp(double long) MSVCRT_ldexp
@ cdecl ldiv(long long) MSVCRT_ldiv
@ cdecl -ret64 llabs(int64) MSVCRT_llabs
@ stub lldiv
@ cdecl lldiv(int64 int64) MSVCRT_lldiv
@ cdecl localeconv() MSVCRT_localeconv
@ cdecl log(double) MSVCRT_log
@ cdecl -arch=arm,x86_64 logf(float) MSVCRT_logf

View File

@ -2091,7 +2091,7 @@
@ cdecl ldexp(double long) MSVCRT_ldexp
@ cdecl ldiv(long long) MSVCRT_ldiv
@ cdecl -ret64 llabs(int64) MSVCRT_llabs
@ stub lldiv
@ cdecl lldiv(int64 int64) MSVCRT_lldiv
@ cdecl localeconv() MSVCRT_localeconv
@ cdecl log(double) MSVCRT_log
@ cdecl -arch=arm,x86_64 logf(float) MSVCRT_logf

View File

@ -2247,7 +2247,7 @@
@ cdecl lgammaf(float) MSVCR120_lgammaf
@ cdecl lgammal(double) MSVCR120_lgammal
@ cdecl -ret64 llabs(int64) MSVCRT_llabs
@ stub lldiv
@ cdecl lldiv(int64 int64) MSVCRT_lldiv
@ cdecl -ret64 llrint(double) MSVCR120_llrint
@ cdecl -ret64 llrintf(float) MSVCR120_llrintf
@ cdecl -ret64 llrintl(double) MSVCR120_llrintl

View File

@ -1910,7 +1910,7 @@
@ cdecl lgammaf(float) msvcr120.lgammaf
@ cdecl lgammal(double) msvcr120.lgammal
@ cdecl -ret64 llabs(int64) msvcr120.llabs
@ stub lldiv
@ cdecl lldiv(int64 int64) msvcr120.lldiv
@ cdecl -ret64 llrint(double) msvcr120.llrint
@ cdecl -ret64 llrintf(float) msvcr120.llrintf
@ cdecl -ret64 llrintl(double) msvcr120.llrintl

View File

@ -1844,6 +1844,19 @@ MSVCRT_ldiv_t CDECL MSVCRT_ldiv(MSVCRT_long num, MSVCRT_long denom)
}
#endif /* ifdef __i386__ */
/*********************************************************************
* lldiv (MSVCRT.@)
*/
MSVCRT_lldiv_t CDECL MSVCRT_lldiv(MSVCRT_longlong num, MSVCRT_longlong denom)
{
MSVCRT_lldiv_t ret;
ret.quot = num / denom;
ret.rem = num % denom;
return ret;
}
#ifdef __i386__
/*********************************************************************

View File

@ -448,6 +448,11 @@ typedef struct MSVCRT__ldiv_t {
MSVCRT_long rem; /* remainder */
} MSVCRT_ldiv_t;
typedef struct MSVCRT__lldiv_t {
MSVCRT_longlong quot; /* quotient */
MSVCRT_longlong rem; /* remainder */
} MSVCRT_lldiv_t;
struct MSVCRT__heapinfo {
int* _pentry;
MSVCRT_size_t _size;

View File

@ -67,6 +67,11 @@ typedef struct MSVCRT__onexit_table_t
MSVCRT__onexit_t *_end;
} MSVCRT__onexit_table_t;
typedef struct MSVCRT__lldiv_t {
LONGLONG quot; /* quotient */
LONGLONG rem; /* remainder */
} MSVCRT_lldiv_t;
static int (CDECL *p_initialize_onexit_table)(MSVCRT__onexit_table_t *table);
static int (CDECL *p_register_onexit_function)(MSVCRT__onexit_table_t *table, MSVCRT__onexit_t func);
static int (CDECL *p_execute_onexit_table)(MSVCRT__onexit_table_t *table);
@ -80,6 +85,7 @@ static int (CDECL *p__ltoa_s)(LONG, char*, size_t, int);
static char* (CDECL *p__get_narrow_winmain_command_line)(void);
static int (CDECL *p_sopen_dispatch)(const char *, int, int, int, int *, int);
static int (CDECL *p_sopen_s)(int *, const char *, int, int, int);
static MSVCRT_lldiv_t (CDECL *p_lldiv)(LONGLONG,LONGLONG);
static void test__initialize_onexit_table(void)
{
@ -373,6 +379,7 @@ static BOOL init(void)
p__get_narrow_winmain_command_line = (void*)GetProcAddress(GetModuleHandleA("ucrtbase.dll"), "_get_narrow_winmain_command_line");
p_sopen_dispatch = (void*)GetProcAddress(module, "_sopen_dispatch");
p_sopen_s = (void*)GetProcAddress(module, "_sopen_s");
p_lldiv = (void*)GetProcAddress(module, "lldiv");
return TRUE;
}
@ -444,6 +451,15 @@ static void test__sopen_s(void)
free(tempf);
}
static void test_lldiv(void)
{
MSVCRT_lldiv_t r;
r = p_lldiv((LONGLONG)0x111 << 32 | 0x222, (LONGLONG)1 << 32);
ok(r.quot == 0x111, "quot = %x%08x\n", (INT32)(r.quot >> 32), (UINT32)r.quot);
ok(r.rem == 0x222, "rem = %x%08x\n", (INT32)(r.rem >> 32), (UINT32)r.rem);
}
START_TEST(misc)
{
int arg_c;
@ -466,4 +482,5 @@ START_TEST(misc)
test__get_narrow_winmain_command_line(arg_v[0]);
test__sopen_dispatch();
test__sopen_s();
test_lldiv();
}

View File

@ -2381,7 +2381,7 @@
@ cdecl lgammaf(float) MSVCR120_lgammaf
@ cdecl lgammal(double) MSVCR120_lgammal
@ cdecl -ret64 llabs(int64) MSVCRT_llabs
@ stub lldiv
@ cdecl lldiv(int64 int64) MSVCRT_lldiv
@ cdecl -ret64 llrint(double) MSVCR120_llrint
@ cdecl -ret64 llrintf(float) MSVCR120_llrintf
@ cdecl -ret64 llrintl(double) MSVCR120_llrintl