tplg: fix the unaligned_get32/put32 helpers for big endian
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Jaroslav Kysela
3 years ago
15 | 15 | |
16 | 16 | #include "local.h" |
17 | 17 | #include "list.h" |
18 | #include "bswap.h" | |
18 | 19 | #include "topology.h" |
19 | 20 | |
20 | 21 | #include <sound/type_compat.h> |
232 | 233 | extern struct tplg_table tplg_table[]; |
233 | 234 | extern unsigned int tplg_table_items; |
234 | 235 | |
235 | #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ && __SIZEOF_INT__ == 4 | |
236 | #if __SIZEOF_INT__ == 4 | |
236 | 237 | static inline unsigned int unaligned_get32(void *src) |
237 | 238 | { |
238 | 239 | unsigned int ret; |
239 | 240 | memcpy(&ret, src, sizeof(ret)); |
241 | #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ | |
242 | ret = bswap_32(ret); | |
243 | #endif | |
240 | 244 | return ret; |
241 | 245 | } |
242 | 246 | static inline void unaligned_put32(void *dst, unsigned int val) |
243 | 247 | { |
248 | #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ | |
249 | val = bswap_32(val); | |
250 | #endif | |
244 | 251 | memcpy(dst, &val, sizeof(val)); |
245 | 252 | } |
246 | 253 | #endif |