~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/asm-i386/byteorder.h

Version: ~ [ linux-6.0-rc6 ] ~ [ linux-5.19.10 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.69 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.144 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.214 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.259 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.294 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.329 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #ifndef _I386_BYTEORDER_H
  2 #define _I386_BYTEORDER_H
  3 
  4 #include <asm/types.h>
  5 
  6 #ifdef __GNUC__
  7 
  8 /* For avoiding bswap on i386 */
  9 #ifdef __KERNEL__
 10 #include <linux/config.h>
 11 #endif
 12 
 13 static __inline__ __const__ __u32 ___arch__swab32(__u32 x)
 14 {
 15 #ifdef CONFIG_X86_BSWAP
 16         __asm__("bswap %0" : "=r" (x) : "" (x));
 17 #else
 18         __asm__("xchgb %b0,%h0\n\t"     /* swap lower bytes     */
 19                 "rorl $16,%0\n\t"       /* swap words           */
 20                 "xchgb %b0,%h0"         /* swap higher bytes    */
 21                 :"=q" (x)
 22                 : "" (x));
 23 #endif
 24         return x;
 25 }
 26 
 27 /* gcc should generate this for open coded C now too. May be worth switching to 
 28    it because inline assembly cannot be scheduled. -AK */
 29 static __inline__ __const__ __u16 ___arch__swab16(__u16 x)
 30 {
 31         __asm__("xchgb %b0,%h0"         /* swap bytes           */
 32                 : "=q" (x)
 33                 :  "" (x));
 34                 return x;
 35 }
 36 
 37 
 38 static inline __u64 ___arch__swab64(__u64 val) 
 39 { 
 40         union { 
 41                 struct { __u32 a,b; } s;
 42                 __u64 u;
 43         } v;
 44         v.u = val;
 45 #ifdef CONFIG_X86_BSWAP
 46         asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1" 
 47             : "=r" (v.s.a), "=r" (v.s.b) 
 48             : "" (v.s.a), "1" (v.s.b)); 
 49 #else
 50    v.s.a = ___arch__swab32(v.s.a); 
 51         v.s.b = ___arch__swab32(v.s.b); 
 52         asm("xchgl %0,%1" : "=r" (v.s.a), "=r" (v.s.b) : "" (v.s.a), "1" (v.s.b));
 53 #endif
 54         return v.u;     
 55 } 
 56 
 57 #define __arch__swab64(x) ___arch__swab64(x)
 58 #define __arch__swab32(x) ___arch__swab32(x)
 59 #define __arch__swab16(x) ___arch__swab16(x)
 60 
 61 #define __BYTEORDER_HAS_U64__
 62 
 63 #endif /* __GNUC__ */
 64 
 65 #include <linux/byteorder/little_endian.h>
 66 
 67 #endif /* _I386_BYTEORDER_H */
 68 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp