From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55384) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoDXp-00022S-9e for qemu-devel@nongnu.org; Wed, 04 Dec 2013 09:35:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VoDXa-0002w4-Go for qemu-devel@nongnu.org; Wed, 04 Dec 2013 09:35:17 -0500 Received: from e38.co.us.ibm.com ([32.97.110.159]:56990) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VoDXa-0002tH-7V for qemu-devel@nongnu.org; Wed, 04 Dec 2013 09:35:02 -0500 Received: from /spool/local by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 4 Dec 2013 07:35:01 -0700 From: Michael Roth Date: Wed, 4 Dec 2013 08:34:23 -0600 Message-Id: <1386167679-13021-17-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1386167679-13021-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1386167679-13021-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 16/32] configure: detect endian via compile test List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org From: Mike Frysinger This avoids needing to execute a program and keeping an (incomplete) list when cross-compiling. Signed-off-by: Mike Frysinger Reviewed-by: Richard Henderson Tested-by: James Hogan [mips] Message-id: 1372649418-4987-1-git-send-email-vapier@gentoo.org Signed-off-by: Anthony Liguori (cherry picked from commit 61cc919f73ea7ca134c0ac41b748981ad63a253b) Signed-off-by: Michael Roth --- configure | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/configure b/configure index 4cf672d..1399de2 100755 --- a/configure +++ b/configure @@ -1394,39 +1394,27 @@ feature_not_found() { "configure was not able to find it" } -if test -z "$cross_prefix" ; then - # --- # big/little endian test cat > $TMPC << EOF -#include -int main(void) { - volatile uint32_t i=0x01234567; - return (*((uint8_t*)(&i))) == 0x67; +short big_endian[] = { 0x4269, 0x4765, 0x4e64, 0x4961, 0x4e00, 0, }; +short little_endian[] = { 0x694c, 0x7454, 0x654c, 0x6e45, 0x6944, 0x6e41, 0, }; +extern int foo(short *, short *); +int main(int argc, char *argv[]) { + return foo(big_endian, little_endian); } EOF -if compile_prog "" "" ; then -$TMPE && bigendian="yes" -else -echo big/little test failed -fi - -else - -# if cross compiling, cannot launch a program, so make a static guess -case "$cpu" in - arm) - # ARM can be either way; ask the compiler which one we are - if check_define __ARMEB__; then - bigendian=yes +if compile_object ; then + if grep -q BiGeNdIaN $TMPO ; then + bigendian="yes" + elif grep -q LiTtLeEnDiAn $TMPO ; then + bigendian="no" + else + echo big/little test failed fi - ;; - hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64) - bigendian=yes - ;; -esac - +else + echo big/little test failed fi ########################################## -- 1.7.9.5