Tony SIM | 1d7a894 | 2010-01-28 17:04:55 +0900 | [diff] [blame] | 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_SH_BYTEORDER_H |
| 13 | #define __ASM_SH_BYTEORDER_H |
| 14 | |
| 15 | #include <linux/compiler.h> |
| 16 | #include <linux/types.h> |
| 17 | |
| 18 | static inline __attribute_const__ __u32 ___arch__swab32(__u32 x) |
| 19 | { |
| 20 | __asm__( |
| 21 | #ifdef __SH5__ |
| 22 | "byterev %0, %0\n\t" |
| 23 | "shari %0, 32, %0" |
| 24 | #else |
| 25 | "swap.b %0, %0\n\t" |
| 26 | "swap.w %0, %0\n\t" |
| 27 | "swap.b %0, %0" |
| 28 | #endif |
| 29 | : "=r" (x) |
| 30 | : "0" (x)); |
| 31 | |
| 32 | return x; |
| 33 | } |
| 34 | |
| 35 | static inline __attribute_const__ __u16 ___arch__swab16(__u16 x) |
| 36 | { |
| 37 | __asm__( |
| 38 | #ifdef __SH5__ |
| 39 | "byterev %0, %0\n\t" |
| 40 | "shari %0, 32, %0" |
| 41 | #else |
| 42 | "swap.b %0, %0" |
| 43 | #endif |
| 44 | : "=r" (x) |
| 45 | : "0" (x)); |
| 46 | |
| 47 | return x; |
| 48 | } |
| 49 | |
| 50 | static inline __u64 ___arch__swab64(__u64 val) |
| 51 | { |
| 52 | union { |
| 53 | struct { __u32 a,b; } s; |
| 54 | __u64 u; |
| 55 | } v, w; |
| 56 | v.u = val; |
| 57 | w.s.b = ___arch__swab32(v.s.a); |
| 58 | w.s.a = ___arch__swab32(v.s.b); |
| 59 | return w.u; |
| 60 | } |
| 61 | |
| 62 | #define __arch__swab64(x) ___arch__swab64(x) |
| 63 | #define __arch__swab32(x) ___arch__swab32(x) |
| 64 | #define __arch__swab16(x) ___arch__swab16(x) |
| 65 | |
| 66 | #ifndef __STRICT_ANSI__ |
| 67 | #define __BYTEORDER_HAS_U64__ |
| 68 | #define __SWAB_64_THRU_32__ |
| 69 | #endif |
| 70 | |
| 71 | #ifdef __LITTLE_ENDIAN__ |
| 72 | #include <linux/byteorder/little_endian.h> |
| 73 | #else |
| 74 | #include <linux/byteorder/big_endian.h> |
| 75 | #endif |
| 76 | |
| 77 | #endif |