j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
Author: mcayland Date: Fri Nov 6 16:06:27 2015 New Revision: 1355 URL: http://tracker.coreboot.org/trac/openbios/changeset/1355
Log: switch-arch: factorize code to compute architecture properties.
Put in two functions code that computes if given architecture is big endian or not, and the size of long (32bit or 64bit).
Signed-off-by: Laurent Vivier laurent@vivier.eu Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
Modified: trunk/openbios-devel/config/scripts/switch-arch
Modified: trunk/openbios-devel/config/scripts/switch-arch ============================================================================== --- trunk/openbios-devel/config/scripts/switch-arch Fri Nov 6 16:06:25 2015 (r1354) +++ trunk/openbios-devel/config/scripts/switch-arch Fri Nov 6 16:06:27 2015 (r1355) @@ -17,48 +17,44 @@ exit 0 fi
-crosscflags() +is_bigendian() { - host=$1 - target=$2 + cpu=$1
- if test "$host" = "powerpc" -o "$host" = "ppc" \ - -o "$host" = "mips" -o "$host" = "s390" \ - -o "$host" = "sparc32" -o "$host" = "sparc64" \ - -o "$host" = "m68k" -o "$host" = "armv4b"; then - hostbigendian="yes" + if test "$cpu" = "powerpc" -o "$cpu" = "ppc" \ + -o "$cpu" = "powerpc64" -o "$cpu" = "ppc64" \ + -o "$cpu" = "mips" -o "$cpu" = "s390" \ + -o "$cpu" = "sparc32" -o "$cpu" = "sparc64" \ + -o "$cpu" = "m68k" -o "$cpu" = "armv4b"; then + echo yes else - hostbigendian="no" + echo no fi +}
-# host long bits test - if test "$host" = "sparc64" -o "$host" = "ia64" \ - -o "$host" = "amd64" -o "$host" = "x86_64" \ - -o "$host" = "alpha"; then - hostlongbits="64" +longbits() +{ + cpu=$1 + if test "$cpu" = "sparc64" -o "$cpu" = "ia64" \ + -o "$cpu" = "amd64" -o "$cpu" = "x86_64" \ + -o "$cpu" = "powerpc64" -o "$cpu" = "ppc64" \ + -o "$cpu" = "alpha"; then + echo 64 else - hostlongbits="32" + echo 32 fi +}
- if test "$target" = "powerpc" -o "$target" = "ppc" \ - -o "$target" = "powerpc64" -o "$target" = "ppc64" \ - -o "$target" = "mips" -o "$target" = "s390" \ - -o "$target" = "sparc32" -o "$target" = "sparc64" \ - -o "$target" = "m68k" -o "$target" = "armv4b"; then - targetbigendian="yes" - else - targetbigendian="no" - fi +crosscflags() +{ + host=$1 + target=$2
-# target long bits test - if test "$target" = "sparc64" -o "$target" = "ia64" \ - -o "$target" = "amd64" -o "$target" = "x86_64" \ - -o "$target" = "powerpc64" -o "$target" = "ppc64" \ - -o "$target" = "alpha"; then - targetlongbits="64" - else - targetlongbits="32" - fi + hostbigendian=$(is_bigendian $host) + hostlongbits=$(longbits $host) + + targetbigendian=$(is_bigendian $target) + targetlongbits=$(longbits $target)
if test "$targetbigendian" = "$hostbigendian"; then cflags="-USWAP_ENDIANNESS"