8 #error "__BYTE_ORDER must be defined"
10 #elif __BYTE_ORDER == __BIG_ENDIAN
12 #define le16_to_cpu(x) \
13 ((Uint16)((((Uint16)(x) & 0x00FFU) << 8) | \
14 (((Uint16)(x) & 0xFF00U) >> 8)))
16 #define le32_to_cpu(x) \
17 ((Uint32)((((Uint32)(x) & 0x000000FFU) << 24) | \
18 (((Uint32)(x) & 0x0000FF00U) << 8) | \
19 (((Uint32)(x) & 0x00FF0000U) >> 8) | \
20 (((Uint32)(x) & 0xFF000000U) >> 24)))
22 #define le64_to_cpu(x) \
23 ((Uint64)((((Uint64)(x) & 0x00000000000000FFULL) << 56) | \
24 (((Uint64)(x) & 0x000000000000FF00ULL) << 40) | \
25 (((Uint64)(x) & 0x0000000000FF0000ULL) << 24) | \
26 (((Uint64)(x) & 0x00000000FF000000ULL) << 8) | \
27 (((Uint64)(x) & 0x000000FF00000000ULL) >> 8) | \
28 (((Uint64)(x) & 0x0000FF0000000000ULL) >> 24) | \
29 (((Uint64)(x) & 0x00FF000000000000ULL) >> 40) | \
30 (((Uint64)(x) & 0xFF00000000000000ULL) >> 56)))
32 #define cpu_to_le16(x) (le16_to_cpu(x))
33 #define cpu_to_le32(x) (le32_to_cpu(x))
34 #define cpu_to_le64(x) (le64_to_cpu(x))
36 #else /* __BYTE_ORDER == __LITTLE_ENDIAN */
38 #define le16_to_cpu(x) (x)
39 #define le32_to_cpu(x) (x)
40 #define le64_to_cpu(x) (x)
41 #define cpu_to_le16(x) (x)
42 #define cpu_to_le32(x) (x)
43 #define cpu_to_le64(x) (x)
50 #include <linux/string.h>
53 static inline lb_addr
lelb_to_cpu(lb_addr in
)
56 out
.logicalBlockNum
= le32_to_cpu(in
.logicalBlockNum
);
57 out
.partitionReferenceNum
= le16_to_cpu(in
.partitionReferenceNum
);
61 static inline lb_addr
cpu_to_lelb(lb_addr in
)
64 out
.logicalBlockNum
= cpu_to_le32(in
.logicalBlockNum
);
65 out
.partitionReferenceNum
= cpu_to_le16(in
.partitionReferenceNum
);
69 static inline timestamp
lets_to_cpu(timestamp in
)
72 memcpy(&out
, &in
, sizeof(timestamp
));
73 out
.typeAndTimezone
= le16_to_cpu(in
.typeAndTimezone
);
74 out
.year
= le16_to_cpu(in
.year
);
78 static inline long_ad
lela_to_cpu(long_ad in
)
81 out
.extLength
= le32_to_cpu(in
.extLength
);
82 out
.extLocation
= lelb_to_cpu(in
.extLocation
);
86 static inline long_ad
cpu_to_lela(long_ad in
)
89 out
.extLength
= cpu_to_le32(in
.extLength
);
90 out
.extLocation
= cpu_to_lelb(in
.extLocation
);
94 static inline extent_ad
leea_to_cpu(extent_ad in
)
97 out
.extLength
= le32_to_cpu(in
.extLength
);
98 out
.extLocation
= le32_to_cpu(in
.extLocation
);
102 static inline timestamp
cpu_to_lets(timestamp in
)
105 memcpy(&out
, &in
, sizeof(timestamp
));
106 out
.typeAndTimezone
= cpu_to_le16(in
.typeAndTimezone
);
107 out
.year
= cpu_to_le16(in
.year
);
111 #endif /* __UDF_ENDIAN_H */