From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQlnq-0007nf-PX for qemu-devel@nongnu.org; Thu, 20 Mar 2014 18:51:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQlnk-00071X-RC for qemu-devel@nongnu.org; Thu, 20 Mar 2014 18:51:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37441) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQlnk-00071S-Hx for qemu-devel@nongnu.org; Thu, 20 Mar 2014 18:51:04 -0400 Message-ID: <532B70CE.3080106@redhat.com> Date: Thu, 20 Mar 2014 23:50:54 +0100 From: Laszlo Ersek MIME-Version: 1.0 References: <1395350099-14664-1-git-send-email-marcel.a@redhat.com> <532B645B.5020507@redhat.com> <1395353214.21800.6.camel@localhost.localdomain> <532B6B27.2080105@redhat.com> <1395354837.21800.12.camel@localhost.localdomain> In-Reply-To: <1395354837.21800.12.camel@localhost.localdomain> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH for-2.0 V3] tests/acpi-test: do not run iasl on big endian machines List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marcel Apfelbaum Cc: peter.maydell@linaro.org, mst@redhat.com, aik@ozlabs.ru, mjt@tls.msk.ru, qemu-devel@nongnu.org, stefanha@redhat.com, Paolo Bonzini , afaerber@suse.de, rth@twiddle.net On 03/20/14 23:33, Marcel Apfelbaum wrote: > On Thu, 2014-03-20 at 23:26 +0100, Laszlo Ersek wrote: >> On 03/20/14 23:06, Marcel Apfelbaum wrote: >>> On Thu, 2014-03-20 at 22:57 +0100, Paolo Bonzini wrote: >>>> Il 20/03/2014 22:14, Marcel Apfelbaum ha scritto: >>>>> +# All known versions of iasl on BE machines are broken. >>>>> +# TODO: add detection code once a non-broken version makes an appearance. >>>>> +if ($iasl -h > /dev/null 2>&1) && >>>>> + (lscpu | grep "Byte Order" | grep --quiet "Little Endian" ); then >>>> >>>> lscpu is not portable. >>> I am open to suggestions... >>> I'll try to come up with something else. >> >> The printf and od utilities are portable. You can use printf to print a >> character string, and use od to group that character string into >> multibyte integers in the native byte order. >> >> Example: >> >> X=$(printf '\336\255\276\357' | od -A n -t x4) > Hi Laszlo, > Thanks for the help! > > I've seen something like that somewhere, but I didn't quite like it. > I was looking for something more elegant as I was *almost* sure > this kind of solution will not pass the reviews :) > > But maybe I'll try this, let's see what happens, For ultimate pedantry, don't depend on the number and kind of blanks on the left hand side of the output. If you set LC_ALL to POSIX, then only and count as blank; but even that way you should be prepared to see any number of them on the LHS. Probably just use grep: if printf '\336\255\276\357' | od -A n -t x4 | grep -q deadbeef; then printf 'big endian\n' >&2 fi Laszlo