10 #error "__BYTE_ORDER must be defined"
12 #elif __BYTE_ORDER == __BIG_ENDIAN
14 #define le16_to_cpu(x) \
15 ((Uint16)((((Uint16)(x) & 0x00FFU) << 8) | \
16 (((Uint16)(x) & 0xFF00U) >> 8)))
18 #define le32_to_cpu(x) \
19 ((Uint32)((((Uint32)(x) & 0x000000FFU) << 24) | \
20 (((Uint32)(x) & 0x0000FF00U) << 8) | \
21 (((Uint32)(x) & 0x00FF0000U) >> 8) | \
22 (((Uint32)(x) & 0xFF000000U) >> 24)))
24 #define le64_to_cpu(x) \
25 ((Uint64)((((Uint64)(x) & 0x00000000000000FFULL) << 56) | \
26 (((Uint64)(x) & 0x000000000000FF00ULL) << 40) | \
27 (((Uint64)(x) & 0x0000000000FF0000ULL) << 24) | \
28 (((Uint64)(x) & 0x00000000FF000000ULL) << 8) | \
29 (((Uint64)(x) & 0x000000FF00000000ULL) >> 8) | \
30 (((Uint64)(x) & 0x0000FF0000000000ULL) >> 24) | \
31 (((Uint64)(x) & 0x00FF000000000000ULL) >> 40) | \
32 (((Uint64)(x) & 0xFF00000000000000ULL) >> 56)))
34 #define cpu_to_le16(x) (le16_to_cpu(x))
35 #define cpu_to_le32(x) (le32_to_cpu(x))
36 #define cpu_to_le64(x) (le64_to_cpu(x))
38 #else /* __BYTE_ORDER == __LITTLE_ENDIAN */
40 #define le16_to_cpu(x) (x)
41 #define le32_to_cpu(x) (x)
42 #define le64_to_cpu(x) (x)
43 #define cpu_to_le16(x) (x)
44 #define cpu_to_le32(x) (x)
45 #define cpu_to_le64(x) (x)
47 #endif /* __BYTE_ORDER == 0 */
51 #else /* __KERNEL__ */
53 #include <asm/byteorder.h>
54 #include <linux/string.h>
56 #endif /* ! __KERNEL__ */
58 static inline lb_addr
lelb_to_cpu(lb_addr in
)
61 out
.logicalBlockNum
= le32_to_cpu(in
.logicalBlockNum
);
62 out
.partitionReferenceNum
= le16_to_cpu(in
.partitionReferenceNum
);
66 static inline lb_addr
cpu_to_lelb(lb_addr in
)
69 out
.logicalBlockNum
= cpu_to_le32(in
.logicalBlockNum
);
70 out
.partitionReferenceNum
= cpu_to_le16(in
.partitionReferenceNum
);
74 static inline timestamp
lets_to_cpu(timestamp in
)
77 memcpy(&out
, &in
, sizeof(timestamp
));
78 out
.typeAndTimezone
= le16_to_cpu(in
.typeAndTimezone
);
79 out
.year
= le16_to_cpu(in
.year
);
83 static inline long_ad
lela_to_cpu(long_ad in
)
86 out
.extLength
= le32_to_cpu(in
.extLength
);
87 out
.extLocation
= lelb_to_cpu(in
.extLocation
);
91 static inline long_ad
cpu_to_lela(long_ad in
)
94 out
.extLength
= cpu_to_le32(in
.extLength
);
95 out
.extLocation
= cpu_to_lelb(in
.extLocation
);
99 static inline extent_ad
leea_to_cpu(extent_ad in
)
102 out
.extLength
= le32_to_cpu(in
.extLength
);
103 out
.extLocation
= le32_to_cpu(in
.extLocation
);
107 static inline timestamp
cpu_to_lets(timestamp in
)
110 memcpy(&out
, &in
, sizeof(timestamp
));
111 out
.typeAndTimezone
= cpu_to_le16(in
.typeAndTimezone
);
112 out
.year
= cpu_to_le16(in
.year
);
116 #endif /* __UDF_ENDIAN_H */