diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-01-10 23:56:42 +0100 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-01-10 23:56:42 +0100 |
commit | 1de8cd3cb9f61e854e743c7210df43db517d4832 (patch) | |
tree | 2b69c5ba5e4094037fa04d0fcb6c4537c222cde8 /arch/sh/include/asm/swab.h | |
parent | 1eb1b3b65dc3e3ffcc6a60e115c085c0c11c1077 (diff) | |
parent | 3d14bdad40315b54470cb7812293d14c8af2bf7d (diff) |
Merge branch 'linus' into x86/cleanups
Diffstat (limited to 'arch/sh/include/asm/swab.h')
-rw-r--r-- | arch/sh/include/asm/swab.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/arch/sh/include/asm/swab.h b/arch/sh/include/asm/swab.h new file mode 100644 index 00000000000..e6931593510 --- /dev/null +++ b/arch/sh/include/asm/swab.h @@ -0,0 +1,60 @@ +#ifndef __ASM_SH_SWAB_H +#define __ASM_SH_SWAB_H + +/* + * Copyright (C) 1999 Niibe Yutaka + * Copyright (C) 2000, 2001 Paolo Alberelli + */ +#include <linux/compiler.h> +#include <linux/types.h> + +#define __SWAB_64_THRU_32__ + +static inline __attribute_const__ __u32 __arch_swab32(__u32 x) +{ + __asm__( +#ifdef __SH5__ + "byterev %0, %0\n\t" + "shari %0, 32, %0" +#else + "swap.b %0, %0\n\t" + "swap.w %0, %0\n\t" + "swap.b %0, %0" +#endif + : "=r" (x) + : "0" (x)); + + return x; +} +#define __arch_swab32 __arch_swab32 + +static inline __attribute_const__ __u16 __arch_swab16(__u16 x) +{ + __asm__( +#ifdef __SH5__ + "byterev %0, %0\n\t" + "shari %0, 32, %0" +#else + "swap.b %0, %0" +#endif + : "=r" (x) + : "0" (x)); + + return x; +} +#define __arch_swab16 __arch_swab16 + +static inline __u64 __arch_swab64(__u64 val) +{ + union { + struct { __u32 a,b; } s; + __u64 u; + } v, w; + v.u = val; + w.s.b = __arch_swab32(v.s.a); + w.s.a = __arch_swab32(v.s.b); + return w.u; +} +#define __arch_swab64 __arch_swab64 + +#endif /* __ASM_SH_SWAB_H */ |