topology: fix the unaligned access

Introduce unaligned_get32/put32 helpers to deal with the
packed structures.

Use the gcc __BYTE_ORDER__ defines for the endian checks.
It may be improved to support other compilation environment.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2020-08-31 14:27:26 +02:00
parent 84c6aeef5c
commit ab73253924
3 changed files with 29 additions and 16 deletions

View file

@ -427,10 +427,8 @@ void snd_tplg_verbose(snd_tplg_t *tplg, int verbose)
static bool is_little_endian(void)
{
#ifdef __BYTE_ORDER
#if __BYTE_ORDER == __LITTLE_ENDIAN
return true;
#endif
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ && __SIZEOF_INT__ == 4
return true;
#endif
return false;
}