Author: tkreuzer
Date: Fri Aug 19 18:39:47 2011
New Revision: 53321
URL:
http://svn.reactos.org/svn/reactos?rev=53321&view=rev
Log:
[RTL]
- Rename memgen.c to byteswap.c and merge with the implementations from largeint.c, that
were using intrinsics
- Fix amd64 build
Added:
trunk/reactos/lib/rtl/byteswap.c
- copied, changed from r53298, trunk/reactos/lib/rtl/memgen.c
Removed:
trunk/reactos/lib/rtl/memgen.c
Modified:
trunk/reactos/lib/rtl/CMakeLists.txt
trunk/reactos/lib/rtl/heap.c
trunk/reactos/lib/rtl/largeint.c
trunk/reactos/lib/rtl/mem.c
Modified: trunk/reactos/lib/rtl/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/CMakeLists.txt?rev…
==============================================================================
--- trunk/reactos/lib/rtl/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/CMakeLists.txt [iso-8859-1] Fri Aug 19 18:39:47 2011
@@ -14,6 +14,7 @@
avltable.c
bitmap.c
bootdata.c
+ byteswap.c
compress.c
condvar.c
crc32.c
@@ -80,13 +81,11 @@
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
Copied: trunk/reactos/lib/rtl/byteswap.c (from r53298, trunk/reactos/lib/rtl/memgen.c)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/byteswap.c?p2=trun…
==============================================================================
--- trunk/reactos/lib/rtl/memgen.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/byteswap.c [iso-8859-1] Fri Aug 19 18:39:47 2011
@@ -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 @@
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 @@
* @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
}
Modified: trunk/reactos/lib/rtl/heap.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/heap.c?rev=53321&a…
==============================================================================
--- trunk/reactos/lib/rtl/heap.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/heap.c [iso-8859-1] Fri Aug 19 18:39:47 2011
@@ -79,10 +79,6 @@
HEAP_TAIL_FILL,
HEAP_TAIL_FILL
};
-
-
-ULONG NTAPI
-RtlCompareMemoryUlong(PVOID Source, ULONG Length, ULONG Value);
/* FUNCTIONS *****************************************************************/
Modified: trunk/reactos/lib/rtl/largeint.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/largeint.c?rev=533…
==============================================================================
--- trunk/reactos/lib/rtl/largeint.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/largeint.c [iso-8859-1] Fri Aug 19 18:39:47 2011
@@ -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
*/
Modified: trunk/reactos/lib/rtl/mem.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/mem.c?rev=53321&am…
==============================================================================
--- trunk/reactos/lib/rtl/mem.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/mem.c [iso-8859-1] Fri Aug 19 18:39:47 2011
@@ -46,11 +46,11 @@
/*
* @implemented
*/
-ULONG
+SIZE_T
NTAPI
RtlCompareMemoryUlong (
PVOID Source,
- ULONG Length,
+ SIZE_T Length,
ULONG Value
)
/*
@@ -63,8 +63,8 @@
*/
{
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 @@
ptr++;
}
- return (ULONG)((PCHAR)ptr - (PCHAR)Source);
+ return (SIZE_T)((PCHAR)ptr - (PCHAR)Source);
}
Removed: trunk/reactos/lib/rtl/memgen.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/memgen.c?rev=53320…
==============================================================================
--- trunk/reactos/lib/rtl/memgen.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/memgen.c (removed)
@@ -1,77 +1,0 @@
-/* COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS system libraries
- * FILE: lib/rtl/mem.c
- * PURPOSE: Memory functions
- * PROGRAMMER: David Welch (welch(a)mcmail.com)
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <rtl.h>
-
-#define NDEBUG
-#include <debug.h>
-
-#undef RtlUlonglongByteSwap
-#undef RtlUlongByteSwap
-#undef RtlUshortByteSwap
-
-/*************************************************************************
- * RtlUshortByteSwap
- *
- * Swap the bytes of an unsigned short value.
- *
- * NOTES
- * Based on the inline versions in Wine winternl.h
- *
- * @implemented
- */
-USHORT FASTCALL
-RtlUshortByteSwap (IN USHORT Source)
-{
- return (Source >> 8) | (Source << 8);
-}
-
-
-
-/*************************************************************************
- * RtlUlongByteSwap [NTDLL.@]
- *
- * Swap the bytes of an unsigned int value.
- *
- * NOTES
- * Based on the inline versions in Wine winternl.h
- *
- * @implemented
- */
-ULONG
-FASTCALL
-RtlUlongByteSwap(
- IN ULONG Source
-)
-{
- return ((ULONG)RtlUshortByteSwap((USHORT)Source) << 16) |
RtlUshortByteSwap((USHORT)(Source >> 16));
-}
-
-
-/*************************************************************************
- * RtlUlonglongByteSwap
- *
- * Swap the bytes of an unsigned long long value.
- *
- * PARAMS
- * i [I] Value to swap bytes of
- *
- * RETURNS
- * The value with its bytes swapped.
- *
- * @implemented
- */
-ULONGLONG FASTCALL
-RtlUlonglongByteSwap (IN ULONGLONG Source)
-{
- return ((ULONGLONG) RtlUlongByteSwap (Source) << 32) | RtlUlongByteSwap
(Source>>32);
-}
-
-
-/* EOF */