Stefan Roese | 371abe8 | 2009-03-19 15:34:56 +0100 | [diff] [blame^] | 1 | #ifndef _LINUX_UNALIGNED_ACCESS_OK_H |
| 2 | #define _LINUX_UNALIGNED_ACCESS_OK_H |
| 3 | |
| 4 | #include <asm/byteorder.h> |
| 5 | |
| 6 | static inline u16 get_unaligned_le16(const void *p) |
| 7 | { |
| 8 | return le16_to_cpup((__le16 *)p); |
| 9 | } |
| 10 | |
| 11 | static inline u32 get_unaligned_le32(const void *p) |
| 12 | { |
| 13 | return le32_to_cpup((__le32 *)p); |
| 14 | } |
| 15 | |
| 16 | static inline u64 get_unaligned_le64(const void *p) |
| 17 | { |
| 18 | return le64_to_cpup((__le64 *)p); |
| 19 | } |
| 20 | |
| 21 | static inline u16 get_unaligned_be16(const void *p) |
| 22 | { |
| 23 | return be16_to_cpup((__be16 *)p); |
| 24 | } |
| 25 | |
| 26 | static inline u32 get_unaligned_be32(const void *p) |
| 27 | { |
| 28 | return be32_to_cpup((__be32 *)p); |
| 29 | } |
| 30 | |
| 31 | static inline u64 get_unaligned_be64(const void *p) |
| 32 | { |
| 33 | return be64_to_cpup((__be64 *)p); |
| 34 | } |
| 35 | |
| 36 | static inline void put_unaligned_le16(u16 val, void *p) |
| 37 | { |
| 38 | *((__le16 *)p) = cpu_to_le16(val); |
| 39 | } |
| 40 | |
| 41 | static inline void put_unaligned_le32(u32 val, void *p) |
| 42 | { |
| 43 | *((__le32 *)p) = cpu_to_le32(val); |
| 44 | } |
| 45 | |
| 46 | static inline void put_unaligned_le64(u64 val, void *p) |
| 47 | { |
| 48 | *((__le64 *)p) = cpu_to_le64(val); |
| 49 | } |
| 50 | |
| 51 | static inline void put_unaligned_be16(u16 val, void *p) |
| 52 | { |
| 53 | *((__be16 *)p) = cpu_to_be16(val); |
| 54 | } |
| 55 | |
| 56 | static inline void put_unaligned_be32(u32 val, void *p) |
| 57 | { |
| 58 | *((__be32 *)p) = cpu_to_be32(val); |
| 59 | } |
| 60 | |
| 61 | static inline void put_unaligned_be64(u64 val, void *p) |
| 62 | { |
| 63 | *((__be64 *)p) = cpu_to_be64(val); |
| 64 | } |
| 65 | |
| 66 | #endif /* _LINUX_UNALIGNED_ACCESS_OK_H */ |