mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2026-03-29 07:57:59 -04:00
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:
parent
84c6aeef5c
commit
ab73253924
3 changed files with 29 additions and 16 deletions
|
|
@ -225,6 +225,19 @@ struct tplg_table {
|
|||
extern struct tplg_table tplg_table[];
|
||||
extern unsigned int tplg_table_items;
|
||||
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ && __SIZEOF_INT__ == 4
|
||||
static inline unsigned int unaligned_get32(void *src)
|
||||
{
|
||||
unsigned int ret;
|
||||
memcpy(&ret, src, sizeof(ret));
|
||||
return ret;
|
||||
}
|
||||
static inline void unaligned_put32(void *dst, unsigned int val)
|
||||
{
|
||||
memcpy(dst, &val, sizeof(val));
|
||||
}
|
||||
#endif
|
||||
|
||||
#define tplg_log(tplg, type, pos, fmt, args...) do { \
|
||||
if ((tplg)->verbose) \
|
||||
tplg_log_((tplg), (type), (pos), (fmt), ##args); \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue