From b917a0c0a87a07e2397a3468adf44f33fa329dde Mon Sep 17 00:00:00 2001 From: Mengdong Lin Date: Thu, 19 Nov 2015 03:33:12 -0500 Subject: [PATCH] topology: Quit and show error message on big-endian machines This tool can only support little-endian machines atm. Many codes directly refer to __le32/__le64 variables of ABI objects, so will be broken on big-endian machines. Signed-off-by: Mengdong Lin Signed-off-by: Takashi Iwai --- src/topology/parser.c | 15 +++++++++++++++ src/topology/tplg_local.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/topology/parser.c b/src/topology/parser.c index e6798be9..45462577 100644 --- a/src/topology/parser.c +++ b/src/topology/parser.c @@ -371,10 +371,25 @@ void snd_tplg_verbose(snd_tplg_t *tplg, int verbose) tplg->verbose = verbose; } +static bool is_little_endian(void) +{ +#ifdef __BYTE_ORDER + #if __BYTE_ORDER == __LITTLE_ENDIAN + return true; + #endif +#endif + return false; +} + snd_tplg_t *snd_tplg_new(void) { snd_tplg_t *tplg; + if (!is_little_endian()) { + SNDERR("error: cannot support big-endian machines\n"); + return NULL; + } + tplg = calloc(1, sizeof(snd_tplg_t)); if (!tplg) return NULL; diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h index 06cb1005..e66d7f4e 100644 --- a/src/topology/tplg_local.h +++ b/src/topology/tplg_local.h @@ -12,6 +12,8 @@ #include #include +#include +#include #include #include "local.h" -- 2.47.3