ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

byteswap.c
Go to the documentation of this file.
00001 /* COPYRIGHT:       See COPYING in the top level directory
00002  * PROJECT:         ReactOS system libraries
00003  * FILE:            lib/rtl/mem.c
00004  * PURPOSE:         Memory functions
00005  * PROGRAMMER:      David Welch (welch@mcmail.com)
00006  */
00007 
00008 /* INCLUDES *****************************************************************/
00009 
00010 #include <rtl.h>
00011 
00012 #define NDEBUG
00013 #include <debug.h>
00014 
00015 #if defined(_M_IX86)
00016 /* RtlUlonglongByteSwap is broken and cannot be done in C on x86 */
00017 #error "Use rtlswap.S!"
00018 #endif
00019 
00020 #undef RtlUlonglongByteSwap
00021 #undef RtlUlongByteSwap
00022 #undef RtlUshortByteSwap
00023 
00024 /*************************************************************************
00025  * RtlUshortByteSwap
00026  *
00027  * Swap the bytes of an unsigned short value.
00028  *
00029  * NOTES
00030  * Based on the inline versions in Wine winternl.h
00031  *
00032  * @implemented
00033  */
00034 USHORT
00035 FASTCALL
00036 RtlUshortByteSwap(
00037     IN USHORT Source)
00038 {
00039 #if defined(_M_AMD64)
00040     return _byteswap_ushort(Source);
00041 #else
00042     return (Source >> 8) | (Source << 8);
00043 #endif
00044 }
00045 
00046 
00047 
00048 /*************************************************************************
00049  * RtlUlongByteSwap    [NTDLL.@]
00050  *
00051  * Swap the bytes of an unsigned int value.
00052  *
00053  * NOTES
00054  * Based on the inline versions in Wine winternl.h
00055  *
00056  * @implemented
00057  */
00058 ULONG
00059 FASTCALL
00060 RtlUlongByteSwap(
00061    IN ULONG Source)
00062 {
00063 #if defined(_M_AMD64)
00064     return _byteswap_ulong(Source);
00065 #else
00066     return ((ULONG)RtlUshortByteSwap((USHORT)Source) << 16) | RtlUshortByteSwap((USHORT)(Source >> 16));
00067 #endif
00068 }
00069 
00070 
00071 /*************************************************************************
00072  * RtlUlonglongByteSwap
00073  *
00074  * Swap the bytes of an unsigned long long value.
00075  *
00076  * PARAMS
00077  *  i [I] Value to swap bytes of
00078  *
00079  * RETURNS
00080  *  The value with its bytes swapped.
00081  *
00082  * @implemented
00083  */
00084 ULONGLONG FASTCALL
00085 RtlUlonglongByteSwap(
00086     IN ULONGLONG Source)
00087 {
00088 #if defined(_M_AMD64)
00089     return _byteswap_uint64(Source);
00090 #else
00091     return ((ULONGLONG) RtlUlongByteSwap (Source) << 32) | RtlUlongByteSwap (Source>>32);
00092 #endif
00093 }
00094 
00095 
00096 /* EOF */

Generated on Sun May 27 2012 04:36:21 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.