1 /* tag: byteorder prototypes
3 * Copyright (C) 2004 Stefan Reinauer
5 * see the file "COPYING" for further information about
6 * the copyright and warranty status of this work.
11 #define __bswap32(x) \
12 ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
13 (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
15 #define __bswap16(x) ((((x) & 0xff00) >> 8) | (((x) & 0x00ff) << 8))
17 #define __bswap64(x) ( (__bswap32( (x) >> 32)) | \
18 (__bswap32((x) & 0xffffffff) << 32) )
20 #ifdef CONFIG_LITTLE_ENDIAN
21 #define __cpu_to_le64(x) ((u64) (x))
22 #define __le64_to_cpu(x) ((u64) (x))
23 #define __cpu_to_le32(x) ((u32) (x))
24 #define __le32_to_cpu(x) ((u32) (x))
25 #define __cpu_to_le16(x) ((u16) (x))
26 #define __le16_to_cpu(x) ((u16) (x))
27 #define __cpu_to_be64(x) (__bswap64((u64) (x)))
28 #define __be64_to_cpu(x) (__bswap64((u64) (x)))
29 #define __cpu_to_be32(x) (__bswap32((u32) (x)))
30 #define __be32_to_cpu(x) (__bswap32((u32) (x)))
31 #define __cpu_to_be16(x) (__bswap16((u16) (x)))
32 #define __be16_to_cpu(x) (__bswap16((u16) (x)))
34 #ifdef CONFIG_BIG_ENDIAN
35 #define __cpu_to_le64(x) (__bswap64((u64) (x)))
36 #define __le64_to_cpu(x) (__bswap64((u64) (x)))
37 #define __cpu_to_le32(x) (__bswap32((u32) (x)))
38 #define __le32_to_cpu(x) (__bswap32((u32) (x)))
39 #define __cpu_to_le16(x) (__bswap16((u16) (x)))
40 #define __le16_to_cpu(x) (__bswap16((u16) (x)))
41 #define __cpu_to_be64(x) ((u64) (x))
42 #define __be64_to_cpu(x) ((u64) (x))
43 #define __cpu_to_be32(x) ((u32) (x))
44 #define __be32_to_cpu(x) ((u32) (x))
45 #define __cpu_to_be16(x) ((u16) (x))
46 #define __be16_to_cpu(x) ((u16) (x))
50 #define __becell_to_cpu(x) (__be32_to_cpu(x))
51 #define __lecell_to_cpu(x) (__le32_to_cpu(x))
52 #define __cpu_to_becell(x) (__cpu_to_be32(x))
53 #define __cpu_to_lecell(x) (__cpu_to_le32(x))
55 #define __becell_to_cpu(x) (__be64_to_cpu(x))
56 #define __lecell_to_cpu(x) (__le64_to_cpu(x))
57 #define __cpu_to_becell(x) (__cpu_to_be64(x))
58 #define __cpu_to_lecell(x) (__cpu_to_le64(x))