Home | History | Annotate | Download | only in asm
      1 /****************************************************************************
      2  ****************************************************************************
      3  ***
      4  ***   This header was automatically generated from a Linux kernel header
      5  ***   of the same name, to make information necessary for userspace to
      6  ***   call into the kernel available to libc.  It contains only constants,
      7  ***   structures, and macros generated from the original header, and thus,
      8  ***   contains no copyrightable information.
      9  ***
     10  ****************************************************************************
     11  ****************************************************************************/
     12 #ifndef _ASM_X86_BYTEORDER_H
     13 #define _ASM_X86_BYTEORDER_H
     14 
     15 #include <asm/types.h>
     16 #include <linux/compiler.h>
     17 
     18 #ifdef __GNUC__
     19 
     20 #ifdef __i386__
     21 
     22 static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
     23 {
     24  __asm__("xchgb %b0,%h0\n\t"
     25  "rorl $16,%0\n\t"
     26  "xchgb %b0,%h0"
     27  :"=q" (x)
     28  : "0" (x));
     29  return x;
     30 }
     31 
     32 static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 val)
     33 {
     34  union {
     35  struct { __u32 a,b; } s;
     36  __u64 u;
     37  } v;
     38  v.u = val;
     39  v.s.a = ___arch__swab32(v.s.a);
     40  v.s.b = ___arch__swab32(v.s.b);
     41  __asm__("xchgl %0,%1" : "=r" (v.s.a), "=r" (v.s.b) : "0" (v.s.a), "1" (v.s.b));
     42  return v.u;
     43 }
     44 
     45 #else
     46 
     47 static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x)
     48 {
     49  __asm__("bswapq %0" : "=r" (x) : "0" (x));
     50  return x;
     51 }
     52 
     53 static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
     54 {
     55  __asm__("bswapl %0" : "=r" (x) : "0" (x));
     56  return x;
     57 }
     58 
     59 #endif
     60 
     61 #define __arch__swab64(x) ___arch__swab64(x)
     62 #define __arch__swab32(x) ___arch__swab32(x)
     63 
     64 #define __BYTEORDER_HAS_U64__
     65 
     66 #endif
     67 
     68 #include <linux/byteorder/little_endian.h>
     69 
     70 #endif
     71