From patchwork Mon Jul 1 03:30:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 256001 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 524722C02B4 for ; Mon, 1 Jul 2013 13:30:52 +1000 (EST) Received: from localhost ([::1]:34540 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtUpF-0007wy-Ef for incoming@patchwork.ozlabs.org; Sun, 30 Jun 2013 23:30:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48863) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtUom-0007wq-DQ for qemu-devel@nongnu.org; Sun, 30 Jun 2013 23:30:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UtUol-0000dG-GJ for qemu-devel@nongnu.org; Sun, 30 Jun 2013 23:30:20 -0400 Received: from dev.gentoo.org ([2001:470:ea4a:1:214:c2ff:fe64:b2d3]:47325 helo=smtp.gentoo.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtUol-0000cH-AF for qemu-devel@nongnu.org; Sun, 30 Jun 2013 23:30:19 -0400 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 4DD0633E7AB for ; Mon, 1 Jul 2013 03:30:16 +0000 (UTC) From: Mike Frysinger To: qemu-devel@nongnu.org Date: Sun, 30 Jun 2013 23:30:18 -0400 Message-Id: <1372649418-4987-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.8.2.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 2001:470:ea4a:1:214:c2ff:fe64:b2d3 Subject: [Qemu-devel] [PATCH] configure: detect endian via compile test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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] --- configure | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/configure b/configure index 2206a87..19d0856 100755 --- a/configure +++ b/configure @@ -1386,39 +1386,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 ##########################################