Wrote RtlUshotByteSwap RtlUlongByteSwap and RtlUlonglongByteSwap to asm code.

but we need a C api for header to linking it right. Put the asm version to i386 

svn path=/trunk/; revision=23826
This commit is contained in:
Magnus Olsen 2006-08-30 21:17:53 +00:00
parent 73120d4d50
commit 0d6e03c305
7 changed files with 228 additions and 63 deletions

View file

@ -0,0 +1,75 @@
/* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/rtl/mem.c
* PURPOSE: Memory functions
* PROGRAMMER: David Welch (welch@mcmail.com)
*/
/* INCLUDES *****************************************************************/
#include <rtl.h>
#define NDEBUG
#include <debug.h>
#undef RtlUlonglongByteSwap
#undef RtlUlongByteSwap
#undef RtlUshortByteSwap
USHORT UshortByteSwap (IN USHORT Source);
ULONG UlongByteSwap (IN ULONG Source);
ULONGLONG UlonglongByteSwap (IN ULONGLONG Source);
/*************************************************************************
* RtlUshortByteSwap
*
* Swap the bytes of an unsigned short value.
*
*
* @implemented
*/
USHORT FASTCALL
RtlUshortByteSwap (IN USHORT Source)
{
return UshortByteSwap (Source);
}
/*************************************************************************
* RtlUlongByteSwap [NTDLL.@]
*
* Swap the bytes of an unsigned int value.
*
*
* @implemented
*/
ULONG
FASTCALL
RtlUlongByteSwap(
IN ULONG Source
)
{
return UlongByteSwap(Source);
}
/*************************************************************************
* RtlUlonglongByteSwap
*
* Swap the bytes of an unsigned long long value.
*
* PARAMS
* i [I] Value to swap bytes of
*
*
* @implemented
*/
ULONGLONG FASTCALL
RtlUlonglongByteSwap (IN ULONGLONG Source)
{
return UlonglongByteSwap(Source);
}
/* EOF */

View file

@ -0,0 +1,21 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Run-Time Library
* FILE: lib/rtl/i386/RtlUlongByteSwap.S
* PROGRAMER: Magnus Olsen (magnus@greatlord.com)
*/
.globl _UlongByteSwap
.intel_syntax noprefix
/* FUNCTIONS ***************************************************************/
_UlongByteSwap:
push ebp // save base
mov ebp,esp // move stack to base
mov eax,[ebp+8] // load the ULONG
bswap eax // swap the ULONG
pop ebp // restore the base
ret

View file

@ -0,0 +1,23 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Run-Time Library
* FILE: lib/rtl/i386/RtlUlonglongByteSwap.S
* PROGRAMER: Magnus Olsen (magnus@greatlord.com)
*/
.globl _UlonglongByteSwap
.intel_syntax noprefix
/* FUNCTIONS ***************************************************************/
_UlonglongByteSwap:
push ebp // save base
mov ebp,esp // move stack to base
mov edx,[ebp+8] // load the higher part of ULONGLONG
mov eax,[ebp+12] // load the lower part of ULONGLONG
bswap edx // swap the higher part
bswap eax // swap the lower part
pop ebp // restore the base
ret

View file

@ -0,0 +1,22 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Run-Time Library
* FILE: lib/rtl/i386/RtlUlongByteSwap.S
* PROGRAMER: Magnus Olsen (magnus@greatlord.com)
*/
.globl _UshortByteSwap
.intel_syntax noprefix
/* FUNCTIONS ***************************************************************/
_UshortByteSwap:
push ebp // save base
mov ebp,esp // move stack to base
mov eax,[ebp+8] // load the USHORT
bswap eax // swap the USHORT, xchg is slow so we use bswap with rol
rol eax,16 // make it USHORT
pop ebp // restore the base
ret

View file

@ -12,9 +12,6 @@
#define NDEBUG
#include <debug.h>
#undef RtlUlonglongByteSwap
#undef RtlUlongByteSwap
#undef RtlUshortByteSwap
/* FUNCTIONS *****************************************************************/
@ -173,63 +170,4 @@ RtlZeroMemory (
);
}
/*************************************************************************
* 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 */

77
reactos/lib/rtl/memgen.c Normal file
View file

@ -0,0 +1,77 @@
/* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/rtl/mem.c
* PURPOSE: Memory functions
* PROGRAMMER: David Welch (welch@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 */

View file

@ -35,6 +35,10 @@
<file>ftol_asm.s</file>
<file>log_asm.s</file>
<file>random_asm.S</file>
<file>memgeni386.c</file>
<file>rtlushortbyteswap.s</file>
<file>rtlulongbyteswap.s</file>
<file>rtlulonglongbyteswap.s</file>
<file>pow_asm.s</file>
<file>prefetchmemory_asm.s</file>
<file>res_asm.s</file>
@ -42,8 +46,13 @@
<file>sqrt_asm.s</file>
<file>tan_asm.s</file>
<file>zeromemory_asm.s</file>
</directory>
</directory>
</if>
<ifnot property="ARCH" value="i386">
<file>memgen.c</file>
</ifnot>
<file>access.c</file>
<file>acl.c</file>
<file>atom.c</file>