Codebase list alsa-lib / cebe0fe
tplg: fix the unaligned_get32/put32 helpers for big endian Signed-off-by: Jaroslav Kysela <perex@perex.cz> Jaroslav Kysela 3 years ago
1 changed file(s) with 8 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
1515
1616 #include "local.h"
1717 #include "list.h"
18 #include "bswap.h"
1819 #include "topology.h"
1920
2021 #include <sound/type_compat.h>
232233 extern struct tplg_table tplg_table[];
233234 extern unsigned int tplg_table_items;
234235
235 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ && __SIZEOF_INT__ == 4
236 #if __SIZEOF_INT__ == 4
236237 static inline unsigned int unaligned_get32(void *src)
237238 {
238239 unsigned int ret;
239240 memcpy(&ret, src, sizeof(ret));
241 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
242 ret = bswap_32(ret);
243 #endif
240244 return ret;
241245 }
242246 static inline void unaligned_put32(void *dst, unsigned int val)
243247 {
248 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
249 val = bswap_32(val);
250 #endif
244251 memcpy(dst, &val, sizeof(val));
245252 }
246253 #endif