Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenbyteorder.h
Go to the documentation of this file.
00001 #ifndef _I386_BYTEORDER_H 00002 #define _I386_BYTEORDER_H 00003 00004 //#include "types.h" 00005 #include "compiler.h" 00006 00007 #ifdef __GNUC__ 00008 00009 /* For avoiding bswap on i386 */ 00010 //#ifdef __KERNEL__ 00011 //#include <linux/config.h> 00012 //#endif 00013 00014 static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x) 00015 { 00016 #ifdef CONFIG_X86_BSWAP 00017 __asm__("bswap %0" : "=r" (x) : "0" (x)); 00018 #else 00019 __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */ 00020 "rorl $16,%0\n\t" /* swap words */ 00021 "xchgb %b0,%h0" /* swap higher bytes */ 00022 :"=q" (x) 00023 : "0" (x)); 00024 #endif 00025 return x; 00026 } 00027 00028 static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 val) 00029 { 00030 union { 00031 struct { __u32 a,b; } s; 00032 __u64 u; 00033 } v; 00034 v.u = val; 00035 #ifdef CONFIG_X86_BSWAP 00036 asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1" 00037 : "=r" (v.s.a), "=r" (v.s.b) 00038 : "0" (v.s.a), "1" (v.s.b)); 00039 #else 00040 v.s.a = ___arch__swab32(v.s.a); 00041 v.s.b = ___arch__swab32(v.s.b); 00042 asm("xchgl %0,%1" : "=r" (v.s.a), "=r" (v.s.b) : "0" (v.s.a), "1" (v.s.b)); 00043 #endif 00044 return v.u; 00045 } 00046 00047 /* Do not define swab16. Gcc is smart enough to recognize "C" version and 00048 convert it into rotation or exhange. */ 00049 00050 #define __arch__swab64(x) ___arch__swab64(x) 00051 #define __arch__swab32(x) ___arch__swab32(x) 00052 00053 #define __BYTEORDER_HAS_U64__ 00054 00055 #endif /* __GNUC__ */ 00056 00057 //#include "little_endian.h" 00058 00059 #endif /* _I386_BYTEORDER_H */ Generated on Sat May 26 2012 04:35:04 for ReactOS by
1.7.6.1
|