Author: tkreuzer
Date: Wed Jun 23 11:37:39 2010
New Revision: 47831
URL:
http://svn.reactos.org/svn/reactos?rev=47831&view=rev
Log:
[OSKITTCP]
Use RtlUlongByteSwap / RtlUshortByteSwap for byte swapping. They are portable and
intrinsics on x86.
Modified:
trunk/reactos/lib/drivers/oskittcp/include/freebsd/src/sys/machine/endian.h
Modified: trunk/reactos/lib/drivers/oskittcp/include/freebsd/src/sys/machine/endian.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/oskittcp/inclu…
==============================================================================
--- trunk/reactos/lib/drivers/oskittcp/include/freebsd/src/sys/machine/endian.h
[iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/oskittcp/include/freebsd/src/sys/machine/endian.h
[iso-8859-1] Wed Jun 23 11:37:39 2010
@@ -56,61 +56,8 @@
#include <sys/cdefs.h>
#endif
-#ifdef _MSC_VER
-static inline unsigned long __byte_swap_long ( unsigned long i )
-{
- char dst[4];
- char* src = (char*)&i;
- dst[0] = src[3];
- dst[1] = src[2];
- dst[2] = src[1];
- dst[3] = src[0];
- return *(unsigned long*)&dst[0];
-}
-
-static inline unsigned short __byte_swap_word ( unsigned short i )
-{
- char dst[2];
- char* src = (char*)&i;
- dst[0] = src[1];
- dst[1] = src[0];
- return *(unsigned short*)&dst[0];
-}
-#else/*_MSC_VER*/
-#define __word_swap_long(x) \
-({ register u_long __X = (x); \
- __asm ("rorl $16, %1" \
- : "=r" (__X) \
- : "0" (__X)); \
- __X; })
-#if __GNUC__ >= 2
-#define __byte_swap_long(x) \
-__extension__ ({ register u_long __X = (x); \
- __asm ("xchgb %h1, %b1\n\trorl $16, %1\n\txchgb %h1, %b1" \
- : "=q" (__X) \
- : "0" (__X)); \
- __X; })
-#define __byte_swap_word(x) \
-__extension__ ({ register u_short __X = (x); \
- __asm ("xchgb %h1, %b1" \
- : "=q" (__X) \
- : "0" (__X)); \
- __X; })
-#else /* __GNUC__ >= 2 */
-#define __byte_swap_long(x) \
-({ register u_long __X = (x); \
- __asm ("rorw $8, %w1\n\trorl $16, %1\n\trorw $8, %w1" \
- : "=r" (__X) \
- : "0" (__X)); \
- __X; })
-#define __byte_swap_word(x) \
-({ register u_short __X = (x); \
- __asm ("rorw $8, %w1" \
- : "=r" (__X) \
- : "0" (__X)); \
- __X; })
-#endif /* __GNUC__ >= 2 */
-#endif /* _MSC_VER */
+#define __byte_swap_long RtlUlongByteSwap
+#define __byte_swap_word RtlUshortByteSwap
/*
* Macros for network/external number representation conversion.