blob: a839798c8a476876968e6c435069460a55d9252d [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001/****************************************************************************
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
Ben Cheng4b29af02012-03-07 16:14:53 -080014
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080015#include <asm/types.h>
16#include <linux/compiler.h>
Ben Cheng4b29af02012-03-07 16:14:53 -080017
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080018#ifdef __GNUC__
Ben Cheng4b29af02012-03-07 16:14:53 -080019
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080020#ifdef __i386__
Ben Cheng4b29af02012-03-07 16:14:53 -080021
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080022static __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}
Ben Cheng4b29af02012-03-07 16:14:53 -080031
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080032static __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}
Ben Cheng4b29af02012-03-07 16:14:53 -080044
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080045#else
Ben Cheng4b29af02012-03-07 16:14:53 -080046
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080047static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x)
48{
49 __asm__("bswapq %0" : "=r" (x) : "0" (x));
50 return x;
51}
Ben Cheng4b29af02012-03-07 16:14:53 -080052
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080053static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
54{
55 __asm__("bswapl %0" : "=r" (x) : "0" (x));
56 return x;
57}
Ben Cheng4b29af02012-03-07 16:14:53 -080058
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080059#endif
Ben Cheng4b29af02012-03-07 16:14:53 -080060
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080061#define __arch__swab64(x) ___arch__swab64(x)
62#define __arch__swab32(x) ___arch__swab32(x)
Ben Cheng4b29af02012-03-07 16:14:53 -080063
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080064#define __BYTEORDER_HAS_U64__
Ben Cheng4b29af02012-03-07 16:14:53 -080065
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080066#endif
Ben Cheng4b29af02012-03-07 16:14:53 -080067
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080068#include <linux/byteorder/little_endian.h>
Ben Cheng4b29af02012-03-07 16:14:53 -080069
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080070#endif