From 3a2698f9c8dd45b2554a306407ee36c7ddcf8817 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 19 Aug 2011 18:39:47 +0000 Subject: [PATCH] [RTL] - Rename memgen.c to byteswap.c and merge with the implementations from largeint.c, that were using intrinsics - Fix amd64 build svn path=/trunk/; revision=53321 --- reactos/lib/rtl/CMakeLists.txt | 7 +++--- reactos/lib/rtl/{memgen.c => byteswap.c} | 30 +++++++++++++++++------- reactos/lib/rtl/heap.c | 4 ---- reactos/lib/rtl/largeint.c | 29 ----------------------- reactos/lib/rtl/mem.c | 10 ++++---- 5 files changed, 30 insertions(+), 50 deletions(-) rename reactos/lib/rtl/{memgen.c => byteswap.c} (66%) diff --git a/reactos/lib/rtl/CMakeLists.txt b/reactos/lib/rtl/CMakeLists.txt index da0f979d2dd..606f37ea41c 100644 --- a/reactos/lib/rtl/CMakeLists.txt +++ b/reactos/lib/rtl/CMakeLists.txt @@ -14,6 +14,7 @@ list(APPEND SOURCE avltable.c bitmap.c bootdata.c + byteswap.c compress.c condvar.c crc32.c @@ -80,13 +81,11 @@ elseif(ARCH MATCHES amd64) amd64/slist.S amd64/unwind.c amd64/stubs.c - mem.c - memgen.c) + mem.c) elseif(ARCH MATCHES arm) list(APPEND SOURCE arm/debug_asm.S - mem.c - memgen.c) + mem.c) elseif(ARCH MATCHES powerpc) list(APPEND SOURCE powerpc/debug.c diff --git a/reactos/lib/rtl/memgen.c b/reactos/lib/rtl/byteswap.c similarity index 66% rename from reactos/lib/rtl/memgen.c rename to reactos/lib/rtl/byteswap.c index a1e2e9c6ae0..b11715ec86f 100644 --- a/reactos/lib/rtl/memgen.c +++ b/reactos/lib/rtl/byteswap.c @@ -26,10 +26,16 @@ * * @implemented */ -USHORT FASTCALL -RtlUshortByteSwap (IN USHORT Source) +USHORT +FASTCALL +RtlUshortByteSwap( + IN USHORT Source) { - return (Source >> 8) | (Source << 8); +#if defined(_M_IX86) || defined(_M_AMD64) + return _byteswap_ushort(Source); +#else + return (Source >> 8) | (Source << 8); +#endif } @@ -47,10 +53,13 @@ RtlUshortByteSwap (IN USHORT Source) ULONG FASTCALL RtlUlongByteSwap( - IN ULONG Source -) + IN ULONG Source) { - return ((ULONG)RtlUshortByteSwap((USHORT)Source) << 16) | RtlUshortByteSwap((USHORT)(Source >> 16)); +#if defined(_M_IX86) || defined(_M_AMD64) + return _byteswap_ulong(Source); +#else + return ((ULONG)RtlUshortByteSwap((USHORT)Source) << 16) | RtlUshortByteSwap((USHORT)(Source >> 16)); +#endif } @@ -68,9 +77,14 @@ RtlUlongByteSwap( * @implemented */ ULONGLONG FASTCALL -RtlUlonglongByteSwap (IN ULONGLONG Source) +RtlUlonglongByteSwap( + IN ULONGLONG Source) { - return ((ULONGLONG) RtlUlongByteSwap (Source) << 32) | RtlUlongByteSwap (Source>>32); +#if defined(_M_IX86) || defined(_M_AMD64) + return _byteswap_uint64(Source); +#else + return ((ULONGLONG) RtlUlongByteSwap (Source) << 32) | RtlUlongByteSwap (Source>>32); +#endif } diff --git a/reactos/lib/rtl/heap.c b/reactos/lib/rtl/heap.c index 96b9939eb5b..00f63ec3c64 100644 --- a/reactos/lib/rtl/heap.c +++ b/reactos/lib/rtl/heap.c @@ -80,10 +80,6 @@ UCHAR FillPattern[HEAP_ENTRY_SIZE] = HEAP_TAIL_FILL }; - -ULONG NTAPI -RtlCompareMemoryUlong(PVOID Source, ULONG Length, ULONG Value); - /* FUNCTIONS *****************************************************************/ VOID NTAPI diff --git a/reactos/lib/rtl/largeint.c b/reactos/lib/rtl/largeint.c index 5934f8c8449..b0db9367747 100644 --- a/reactos/lib/rtl/largeint.c +++ b/reactos/lib/rtl/largeint.c @@ -18,36 +18,7 @@ #undef RtlUlongByteSwap #undef RtlUshortByteSwap -/* - * @implemented - */ -USHORT -FASTCALL -RtlUshortByteSwap(IN USHORT Source) -{ - return _byteswap_ushort(Source); -} -/* - * @implemented - */ -ULONG -FASTCALL -RtlUlongByteSwap(IN ULONG Source) -{ - return _byteswap_ulong(Source); -} - -/* - * @implemented - */ -ULONGLONG -FASTCALL -RtlUlonglongByteSwap(IN ULONGLONG Source) -{ - return _byteswap_uint64(Source); -} - /* * @implemented */ diff --git a/reactos/lib/rtl/mem.c b/reactos/lib/rtl/mem.c index e5152b5dafd..8f1e413f138 100644 --- a/reactos/lib/rtl/mem.c +++ b/reactos/lib/rtl/mem.c @@ -46,11 +46,11 @@ RtlCompareMemory(IN const VOID *Source1, /* * @implemented */ -ULONG +SIZE_T NTAPI RtlCompareMemoryUlong ( PVOID Source, - ULONG Length, + SIZE_T Length, ULONG Value ) /* @@ -63,8 +63,8 @@ RtlCompareMemoryUlong ( */ { PULONG ptr = (PULONG)Source; - ULONG len = Length / sizeof(ULONG); - ULONG i; + ULONG_PTR len = Length / sizeof(ULONG); + ULONG_PTR i; for (i = 0; i < len; i++) { @@ -73,7 +73,7 @@ RtlCompareMemoryUlong ( ptr++; } - return (ULONG)((PCHAR)ptr - (PCHAR)Source); + return (SIZE_T)((PCHAR)ptr - (PCHAR)Source); }