From: mengdong.lin@linux.intel.com
To: alsa-devel@alsa-project.org
Cc: Mengdong Lin <mengdong.lin@linux.intel.com>,
tiwai@suse.de, mengdong.lin@intel.com, vinod.koul@intel.com,
liam.r.girdwood@intel.com, subhransu.s.prusty@intel.com
Subject: [PATCH v2 2/2] topology: Quit and show error message on big-endian machines
Date: Thu, 19 Nov 2015 03:33:12 -0500 [thread overview]
Message-ID: <61e90290970cd46a60fd17159bcbb1250938cbe1.1447921888.git.mengdong.lin@linux.intel.com> (raw)
In-Reply-To: <cover.1447921888.git.mengdong.lin@linux.intel.com>
From: Mengdong Lin <mengdong.lin@linux.intel.com>
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 <mengdong.lin@linux.intel.com>
diff --git a/src/topology/parser.c b/src/topology/parser.c
index 18bb9c7..2048733 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 06cb100..e66d7f4 100644
--- a/src/topology/tplg_local.h
+++ b/src/topology/tplg_local.h
@@ -12,6 +12,8 @@
#include <limits.h>
#include <stdint.h>
+#include <stdbool.h>
+#include <endian.h>
#include <linux/types.h>
#include "local.h"
--
2.5.0
next prev parent reply other threads:[~2015-11-19 8:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-19 8:32 [PATCH v2 0/2] topology: fix some gcc warnings mengdong.lin
2015-11-19 8:33 ` [PATCH v2 1/2] topology: Not compare a for loop iterator with ABI __le32 variables mengdong.lin
2015-11-19 8:33 ` mengdong.lin [this message]
2015-11-19 10:23 ` [PATCH v2 0/2] topology: fix some gcc warnings Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=61e90290970cd46a60fd17159bcbb1250938cbe1.1447921888.git.mengdong.lin@linux.intel.com \
--to=mengdong.lin@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=liam.r.girdwood@intel.com \
--cc=mengdong.lin@intel.com \
--cc=subhransu.s.prusty@intel.com \
--cc=tiwai@suse.de \
--cc=vinod.koul@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).