summaryrefslogtreecommitdiff
path: root/config.guess
diff options
context:
space:
mode:
authorTorbjorn Granlund <torbjorng@google.com>2016-01-13 20:52:57 +0100
committerTorbjorn Granlund <torbjorng@google.com>2016-01-13 20:52:57 +0100
commita4be9cd9ce45296494de9677931e4971cde9240d (patch)
treec2fad40bbc41a1c186c0449f8afc8d12fb99c42a /config.guess
parentb2b895075376e3ab081fa11a986414b063a468e0 (diff)
downloadgmp-a4be9cd9ce45296494de9677931e4971cde9240d.tar.gz
Reorder and generalise ppc code.
Diffstat (limited to 'config.guess')
-rwxr-xr-xconfig.guess82
1 files changed, 34 insertions, 48 deletions
diff --git a/config.guess b/config.guess
index 744e11e49..3fb921926 100755
--- a/config.guess
+++ b/config.guess
@@ -3,7 +3,7 @@
# GMP config.guess wrapper.
-# Copyright 2000-2006, 2008, 2011-2015 Free Software Foundation, Inc.
+# Copyright 2000-2006, 2008, 2011-2016 Free Software Foundation, Inc.
#
# This file is part of the GNU MP Library.
#
@@ -377,41 +377,43 @@ rs6000-*-* | powerpc*-*-*)
# (as noted below). But the man page says the command is still "under
# development", so it doesn't seem wise to use it just yet, not while
# there's an alternative.
- #
+
+ # Grep the /proc/cpuinfo pseudo-file.
+ # Anything unrecognised is ignored, since of course we mustn't spit out
+ # a cpu type config.sub doesn't know.
+ if test -z "$exact_cpu" && test -f /proc/cpuinfo; then
+ x=`grep "^cpu[ ]" /proc/cpuinfo | head -n 1`
+ x=`echo $x | sed -n 's/^cpu[ ]*:[ ]*\([A-Za-z0-9]*\).*/\1/p'`
+ x=`echo $x | sed 's/PPC//'`
+ case $x in
+ 601) exact_cpu="power" ;;
+ 603ev) exact_cpu="powerpc603e" ;;
+ 604ev5) exact_cpu="powerpc604e" ;;
+ 970??) exact_cpu="powerpc970" ;;
+ 603 | 603e | 604 | 604e | 750 | 821 | 860)
+ exact_cpu="powerpc$x" ;;
+ POWER[4-9]*)
+ exact_cpu=`echo $x | sed -e "s;POWER;power;" -e "s;[a-zA-Z]*$;;"` ;;
+ esac
+ fi
+
# Try to read the PVR. mfpvr is a protected instruction, NetBSD, MacOS
# and AIX don't allow it in user mode, but the Linux kernel does.
#
- # Using explicit bytes for mfpvr avoids worrying about assembler syntax
- # and underscores. "char"s are used instead of "int"s to avoid worrying
- # whether sizeof(int)==4 or if it's the right endianness.
- #
# Note this is no good on AIX, since a C function there is the address of
# a function descriptor, not actual code. But this doesn't matter since
# AIX doesn't allow mfpvr anyway.
#
- eval $set_cc_for_build
- cat >$dummy.c <<\EOF
+ if test -z "$exact_cpu"; then
+ eval $set_cc_for_build
+ cat >$dummy.c <<\EOF
#include <stdio.h>
-struct {
- int n; /* force 4-byte alignment */
- char a[8];
-} getpvr = {
- 0,
- {
- 0x7c, 0x7f, 0x42, 0xa6, /* mfpvr r3 */
- 0x4e, 0x80, 0x00, 0x20, /* blr */
- }
-};
int
main ()
{
- unsigned (*fun)();
unsigned pvr;
- /* a separate "fun" variable is necessary for gcc 2.95.2 on MacOS,
- it gets a compiler error on a combined cast and call */
- fun = (unsigned (*)()) getpvr.a;
- pvr = (*fun) ();
+ asm ("mfpvr %0" : "=r" (pvr));
switch (pvr >> 16) {
case 0x0001: puts ("powerpc601"); break;
@@ -424,6 +426,8 @@ main ()
case 0x000a: puts ("powerpc604e"); break; /* 604ev5 */
case 0x000c: puts ("powerpc7400"); break;
case 0x0041: puts ("powerpc630"); break;
+ case 0x003f: puts ("power7"); break;
+ case 0x004b: puts ("power8"); break;
case 0x0050: puts ("powerpc860"); break;
case 0x8000: puts ("powerpc7450"); break;
case 0x8001: puts ("powerpc7455"); break;
@@ -434,34 +438,16 @@ main ()
return 0;
}
EOF
- if ($CC_FOR_BUILD $dummy.c -o $dummy) >/dev/null 2>&1; then
- # This style construct is needed on AIX 4.3 to suppress the SIGILL error
- # from (*fun)(). Using $SHELL -c $dummy 2>/dev/null doesn't work.
- { x=`$dummy`; } 2>/dev/null
- if test -n "$x"; then
- exact_cpu=$x
+ if ($CC_FOR_BUILD $dummy.c -o $dummy) >/dev/null 2>&1; then
+ # This style construct is needed on AIX 4.3 to suppress the SIGILL error
+ # from (*fun)(). Using $SHELL -c $dummy 2>/dev/null doesn't work.
+ { x=`$dummy`; } 2>/dev/null
+ if test -n "$x"; then
+ exact_cpu=$x
+ fi
fi
fi
- # Grep the linux kernel /proc/cpuinfo pseudo-file.
- # Anything unrecognised is ignored, since of course we mustn't spit out
- # a cpu type config.sub doesn't know.
- if test -z "$exact_cpu" && test -f /proc/cpuinfo; then
- x=`grep "^cpu[ ]" /proc/cpuinfo | head -n 1`
- x=`echo $x | sed -n 's/^cpu[ ]*:[ ]*\([A-Za-z0-9]*\).*/\1/p'`
- x=`echo $x | sed 's/PPC//'`
- case $x in
- 601) exact_cpu="power" ;;
- 603ev) exact_cpu="powerpc603e" ;;
- 604ev5) exact_cpu="powerpc604e" ;;
- 970??) exact_cpu="powerpc970" ;;
- 603 | 603e | 604 | 604e | 750 | 821 | 860)
- exact_cpu="powerpc$x" ;;
- POWER[4-9]*)
- exact_cpu=`echo $x | sed -e "s;POWER;power;" -e "s;[a-zA-Z]*$;;"` ;;
- esac
- fi
-
if test -z "$exact_cpu"; then
# On AIX, try looking at _system_configuration. This is present in
# version 4 at least.