From e24e6eb278f601fcb7ea5086ec5c8dbf38008eae Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Mon, 16 Apr 2012 18:11:37 +0200 Subject: [PATCH] msvcr90: Added _byteswap_{ushort,ulong,uint64} implementation. --- dlls/msvcr100/msvcr100.spec | 6 +++--- dlls/msvcr80/msvcr80.spec | 6 +++--- dlls/msvcr90/msvcr90.c | 25 +++++++++++++++++++++++++ dlls/msvcr90/msvcr90.spec | 6 +++--- dlls/msvcr90/tests/msvcr90.c | 14 ++++++++++++++ 5 files changed, 48 insertions(+), 9 deletions(-) diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec index ade980c7279..bf3a0687ccf 100644 --- a/dlls/msvcr100/msvcr100.spec +++ b/dlls/msvcr100/msvcr100.spec @@ -517,9 +517,9 @@ @ cdecl _beep(long long) msvcrt._beep @ cdecl _beginthread(ptr long ptr) msvcrt._beginthread @ cdecl _beginthreadex(ptr long ptr ptr long ptr) msvcrt._beginthreadex -@ stub _byteswap_uint64 -@ stub _byteswap_ulong -@ stub _byteswap_ushort +@ cdecl _byteswap_uint64(int64) msvcr90._byteswap_uint64 +@ cdecl _byteswap_ulong(long) msvcr90._byteswap_ulong +@ cdecl _byteswap_ushort(long) msvcr90._byteswap_ushort @ cdecl _c_exit() msvcrt._c_exit @ cdecl _cabs(long) msvcrt._cabs @ cdecl _callnewh(long) msvcrt._callnewh diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec index d4d7a86df63..86863598c9f 100644 --- a/dlls/msvcr80/msvcr80.spec +++ b/dlls/msvcr80/msvcr80.spec @@ -356,9 +356,9 @@ @ cdecl _beep(long long) msvcrt._beep @ cdecl _beginthread(ptr long ptr) msvcrt._beginthread @ cdecl _beginthreadex(ptr long ptr ptr long ptr) msvcrt._beginthreadex -@ stub _byteswap_uint64 -@ stub _byteswap_ulong -@ stub _byteswap_ushort +@ cdecl _byteswap_uint64(int64) msvcr90._byteswap_uint64 +@ cdecl _byteswap_ulong(long) msvcr90._byteswap_ulong +@ cdecl _byteswap_ushort(long) msvcr90._byteswap_ushort @ cdecl _c_exit() msvcrt._c_exit @ cdecl _cabs(long) msvcrt._cabs @ cdecl _callnewh(long) msvcrt._callnewh diff --git a/dlls/msvcr90/msvcr90.c b/dlls/msvcr90/msvcr90.c index 663dd372be9..2caf60dac2b 100644 --- a/dlls/msvcr90/msvcr90.c +++ b/dlls/msvcr90/msvcr90.c @@ -366,3 +366,28 @@ int CDECL MSVCR90__vswprintf_p(wchar_t *buffer, size_t length, const wchar_t *fo { return _vswprintf_p_l(buffer, length, format, NULL, args); } + +/********************************************************************* + * _byteswap_ushort (MSVCR90.@) + */ +unsigned short CDECL _byteswap_ushort(unsigned short s) +{ + return (s<<8) + (s>>8); +} + +/********************************************************************* + * _byteswap_ulong (MSVCR90.@) + */ +unsigned long CDECL _byteswap_ulong(unsigned long l) +{ + return (l<<24) + ((l<<8)&0xFF0000) + ((l>>8)&0xFF00) + (l>>24); +} + +/********************************************************************* + * _byteswap_uint64 (MSVCR90.@) + */ +unsigned __int64 CDECL _byteswap_uint64(unsigned __int64 i) +{ + return (i<<56) + ((i&0xFF00)<<40) + ((i&0xFF0000)<<24) + ((i&0xFF000000)<<8) + + ((i>>8)&0xFF000000) + ((i>>24)&0xFF0000) + ((i>>40)&0xFF00) + (i>>56); +} diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec index 70bc2b39e24..6aefe206920 100644 --- a/dlls/msvcr90/msvcr90.spec +++ b/dlls/msvcr90/msvcr90.spec @@ -348,9 +348,9 @@ @ cdecl _beep(long long) msvcrt._beep @ cdecl _beginthread(ptr long ptr) msvcrt._beginthread @ cdecl _beginthreadex(ptr long ptr ptr long ptr) msvcrt._beginthreadex -@ stub _byteswap_uint64 -@ stub _byteswap_ulong -@ stub _byteswap_ushort +@ cdecl _byteswap_uint64(int64) +@ cdecl _byteswap_ulong(long) +@ cdecl _byteswap_ushort(long) @ cdecl _c_exit() msvcrt._c_exit @ cdecl _cabs(long) msvcrt._cabs @ cdecl _callnewh(long) msvcrt._callnewh diff --git a/dlls/msvcr90/tests/msvcr90.c b/dlls/msvcr90/tests/msvcr90.c index 09b4a40c2b9..dc15472d918 100644 --- a/dlls/msvcr90/tests/msvcr90.c +++ b/dlls/msvcr90/tests/msvcr90.c @@ -109,6 +109,7 @@ static int (__cdecl *p_fileno)(FILE*); static int (__cdecl *p_feof)(FILE*); static int (__cdecl *p_ferror)(FILE*); static int (__cdecl *p_flsbuf)(int, FILE*); +static unsigned long (__cdecl *p_byteswap_ulong)(unsigned long); /* type info */ @@ -286,6 +287,7 @@ static BOOL init(void) SET(p_feof, "feof"); SET(p_ferror, "ferror"); SET(p_flsbuf, "_flsbuf"); + SET(p_byteswap_ulong, "_byteswap_ulong"); if (sizeof(void *) == 8) { SET(p_type_info_name_internal_method, "?_name_internal_method@type_info@@QEBAPEBDPEAU__type_info_node@@@Z"); @@ -1137,6 +1139,17 @@ static void test_nonblocking_file_access(void) p_unlink("test_file"); } +static void test_byteswap(void) +{ + unsigned long ret; + + ret = p_byteswap_ulong(0x12345678); + ok(ret == 0x78563412, "ret = %lx\n", ret); + + ret = p_byteswap_ulong(0); + ok(ret == 0, "ret = %lx\n", ret); +} + START_TEST(msvcr90) { if(!init()) @@ -1159,4 +1172,5 @@ START_TEST(msvcr90) test_getptd(); test__vswprintf_l(); test_nonblocking_file_access(); + test_byteswap(); }