3 # GMP config.guess wrapper.
6 # Copyright 2000-2006, 2008, 2011-2014 Free Software Foundation, Inc.
8 # This file is part of the GNU MP Library.
10 # The GNU MP Library is free software; you can redistribute it and/or modify
11 # it under the terms of either:
13 # * the GNU Lesser General Public License as published by the Free
14 # Software Foundation; either version 3 of the License, or (at your
15 # option) any later version.
19 # * the GNU General Public License as published by the Free Software
20 # Foundation; either version 2 of the License, or (at your option) any
23 # or both in parallel, as here.
25 # The GNU MP Library is distributed in the hope that it will be useful, but
26 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
27 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
30 # You should have received copies of the GNU General Public License and the
31 # GNU Lesser General Public License along with the GNU MP Library. If not,
32 # see https://www.gnu.org/licenses/.
37 # Print the host system CPU-VENDOR-OS.
39 # configfsf.guess is run and its guess then sharpened up to take advantage
40 # of the finer grained CPU types that GMP knows.
43 # Expect to find configfsf.guess in the same directory as this config.guess
44 configfsf_guess
="`echo \"$0\" | sed 's/config.guess$/configfsf.guess/'`"
45 if test "$configfsf_guess" = "$0"; then
46 echo "Cannot derive configfsf.guess from $0" 1>&2
49 if test -f "$configfsf_guess"; then
52 echo "$configfsf_guess not found" 1>&2
56 # Setup a $SHELL with which to run configfsf.guess, using the same
57 # $CONFIG_SHELL or /bin/sh as autoconf does when running config.guess
58 SHELL
=${CONFIG_SHELL-/bin/sh}
60 # Identify ourselves on --version, --help or errors
62 echo "(GNU MP wrapped config.guess)"
63 $SHELL $configfsf_guess "$@"
67 guess_full
=`$SHELL $configfsf_guess`
72 guess_cpu
=`echo "$guess_full" | sed 's/-.*$//'`
73 guess_rest
=`echo "$guess_full" | sed 's/^[^-]*//'`
77 # -------------------------------------------------------------------------
78 # The following should look at the current guess and probe the system to
79 # establish a better guess in exact_cpu. Leave exact_cpu empty if probes
80 # can't be done, or don't work.
82 # When a number of probes are done, test -z "$exact_cpu" can be used instead
83 # of putting each probe under an "else" of the preceeding. That can stop
84 # the code getting horribly nested and marching off the right side of the
87 # Note that when a compile-and-link is done in one step we need to remove .o
88 # files, since lame C compilers generate these even when not asked.
91 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a
92 # compiler to aid in system detection is discouraged as it requires
93 # temporary files to be created and, as you can see below, it is a
94 # headache to deal with in a portable fashion.
96 # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
97 # use `HOST_CC' if defined, but it is deprecated.
99 # Portable tmp directory creation inspired by the Autoconf team.
102 trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
103 trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
105 { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
106 { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
107 { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
108 { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
110 tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy $dummy.core ${dummy}0.s" ;
111 case $CC_FOR_BUILD,$HOST_CC,$CC in
112 ,,) echo "int x;" > $dummy.c ;
113 for c in cc gcc c89 c99 ; do
114 if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
115 CC_FOR_BUILD="$c"; break ;
118 if test x"$CC_FOR_BUILD" = x ; then
119 CC_FOR_BUILD=no_compiler_found ;
122 ,,*) CC_FOR_BUILD=$CC ;;
123 ,*,*) CC_FOR_BUILD=$HOST_CC ;;
124 esac ; set_cc_for_build= ;'
127 case "$guess_full" in
130 eval $set_cc_for_build
131 # configfsf.guess detects exact alpha cpu types for OSF and GNU/Linux, but
132 # not for *BSD and other systems. We try to get an exact type for any
133 # plain "alpha" it leaves.
135 # configfsf.guess used to have a block of code not unlike this, but these
136 # days does its thing with Linux kernel /proc/cpuinfo or OSF psrinfo.
138 cat <<EOF >${dummy}0.s
141 .byte 37,100,45,37,120,10,0 # "%d-%x\n"
147 .frame \$30,16,\$26,0
150 .long 0x47e03d91 # implver \$17
152 .long 0x47e20c21 # amask \$2,\$1
161 $CC_FOR_BUILD ${dummy}0.s
-o $dummy 2>/dev
/null
162 if test "$?" = 0 ; then
164 0-0) exact_cpu
=alpha
;;
165 1-0) exact_cpu
=alphaev5
;;
166 1-1) exact_cpu
=alphaev56
;;
167 1-101) exact_cpu
=alphapca56
;;
168 2-303) exact_cpu
=alphaev6
;;
169 2-307) exact_cpu
=alphaev67
;;
170 2-1307) exact_cpu
=alphaev68
;;
176 cpu_code
=`sed -n 's/^CPU part.*\(0x.*\)$/\1/p' /proc/cpuinfo 2>/dev/null`
178 0xa10 |
0xa11 |
0xb11) # v4 strongarm/sa1100
181 0x920 |
0x922 |
0x940) # v4
182 exact_cpu
="arm9tdmi";;
183 0x210 |
0x290 |
0x2d0 | \
184 0x212 |
0x292 |
0x2d2 | \
185 0x411) exact_cpu
="armxscale";; # v5 pxa2xx
186 0x926 |
0x946 |
0x966 |
0x968) # v5te/v5tej
188 0xa20 |
0xa22 |
0xa26) # v5te
190 0xb02) exact_cpu
="arm11mpcore";; # v6
191 0xb36) exact_cpu
="arm1136";; # v6
192 0xb56) exact_cpu
="arm1156";; # v6t2
193 0xb76) exact_cpu
="arm1176";; # v6
194 0xc05) exact_cpu
="armcortexa5";; # v7a
195 0xc07) exact_cpu
="armcortexa7";; # v7a
196 0xc08) exact_cpu
="armcortexa8";; # v7a
197 0xc09) exact_cpu
="armcortexa9";; # v7a
198 0xc0f) exact_cpu
="armcortexa15";; # v7a
199 0xc14) exact_cpu
="armcortexr4";; # v7r
200 0xc15) exact_cpu
="armcortexr5";; # v7r
201 0xc23) exact_cpu
="armcortexm3";; # v7m
203 exact_cpu
="${exact_cpu}`sed -n 's;^Features.*\(neon\).*;\1;p' /proc/cpuinfo 2>/dev/null`"
207 eval $set_cc_for_build
208 # CPUID[3] bits 24 to 31 is the processor family. itanium2 is documented
209 # as 0x1f, plain itanium has been seen returning 0x07 on two systems, but
210 # haven't found any documentation on it as such.
212 # Defining both getcpuid and _getcpuid lets us ignore whether the system
213 # expects underscores or not.
215 # "unsigned long long" is always 64 bits, in fact on hpux in ilp32 mode
216 # (which is the default there), it's the only 64-bit type.
218 cat >${dummy}0.s
<<EOF
223 mov r8 = CPUID[r32] ;;
224 br.ret.sptk.many rp ;;
229 mov r8 = CPUID[r32] ;;
230 br.ret.sptk.many rp ;;
235 unsigned long long getcpuid ();
239 if (getcpuid(0LL) == 0x49656E69756E6547LL && getcpuid(1LL) == 0x6C65746ELL)
242 switch ((getcpuid(3LL) >> 24) & 0xFF) {
243 case 0x07: puts ("itanium"); break;
244 case 0x1F: puts ("itanium2"); break; /* McKinley, Madison */
245 case 0x20: puts ("itanium2"); break; /* Montecito */
251 if $CC_FOR_BUILD ${dummy}0.s
$dummy.c
-o $dummy >/dev
/null
2>&1; then
257 # IRIX 6 and up always has a 64-bit mips cpu
262 eval $set_cc_for_build
263 # NetBSD (and presumably other *BSD) "sysctl hw.model" gives for example
264 # hw.model = Apple Macintosh Quadra 610 (68040)
265 exact_cpu
=`(sysctl hw.model) 2>/dev/null | sed -n 's/^.*\(680[012346]0\).*$/m\1/p'`
266 if test -z "$exact_cpu"; then
267 # Linux kernel 2.2 gives for example "CPU: 68020" (tabs in between).
268 exact_cpu
=`sed -n 's/^CPU:.*\(680[012346]0\).*$/m\1/p' /proc/cpuinfo 2>/dev/null`
270 if test -z "$exact_cpu"; then
271 # Try: movel #0,%d0; rts
272 # This is to check the compiler and our asm code works etc, before
273 # assuming failures below indicate cpu characteristics.
274 # .byte is used to avoid problems with assembler syntax variations.
275 # For testing, provoke failures by adding "illegal" possibly as
277 cat >${dummy}0.s
<<EOF
287 if ($CC_FOR_BUILD ${dummy}0.s
-o $dummy && $dummy) >/dev
/null
2>&1; then
289 # $SHELL -c is used to execute $dummy below, since ($dummy)
290 # 2>/dev/null still prints the SIGILL message on some shells.
294 cat >${dummy}0.s
<<EOF
301 .byte 0x4e, 0x74, 0x00, 0x00
303 if $CC_FOR_BUILD ${dummy}0.s
-o $dummy >/dev
/null
2>&1; then
304 $SHELL -c $dummy >/dev
/null
2>&1
305 if test $?
!= 0; then
306 exact_cpu
=m68000
# because rtd didn't work
311 if test -z "$exact_cpu"; then
315 # Another possibility for identifying 68000 and 68010 is the
316 # different value stored by "movem a0,(a0)+"
317 cat >${dummy}0.s
<<EOF
327 if $CC_FOR_BUILD ${dummy}0.s
-o $dummy >/dev
/null
2>&1; then
328 $SHELL -c $dummy >/dev
/null
2>&1
329 if test $?
!= 0; then
330 exact_cpu
=m68010
# because trapf didn't work
335 if test -z "$exact_cpu"; then
336 # Try: bfffo %d1{0:31},%d0
339 cat >${dummy}0.s
<<EOF
345 .byte 0xED, 0xC1, 0x00, 0x1F
349 if $CC_FOR_BUILD ${dummy}0.s
-o $dummy >/dev
/null
2>&1; then
350 $SHELL -c $dummy >/dev
/null
2>&1
351 if test $?
!= 0; then
352 exact_cpu
=m68360
# cpu32, because bfffo didn't work
357 if test -z "$exact_cpu"; then
358 # FIXME: Now we know 68020 or up, but how to detect 030, 040 and 060?
363 if test -z "$exact_cpu"; then
364 case "$guess_full" in
365 *-*-next* |
*-*-openstep*) # NeXTs are 68020 or better
372 rs6000-
*-* | powerpc
*-*-*)
373 # Enhancement: On MacOS the "machine" command prints for instance
374 # "ppc750". Interestingly on powerpc970-apple-darwin6.8.5 it prints
375 # "ppc970" where there's no actual #define for 970 from NXGetLocalArchInfo
376 # (as noted below). But the man page says the command is still "under
377 # development", so it doesn't seem wise to use it just yet, not while
378 # there's an alternative.
380 # Try to read the PVR. mfpvr is a protected instruction, NetBSD, MacOS
381 # and AIX don't allow it in user mode, but the Linux kernel does.
383 # Using explicit bytes for mfpvr avoids worrying about assembler syntax
384 # and underscores. "char"s are used instead of "int"s to avoid worrying
385 # whether sizeof(int)==4 or if it's the right endianness.
387 # Note this is no good on AIX, since a C function there is the address of
388 # a function descriptor, not actual code. But this doesn't matter since
389 # AIX doesn't allow mfpvr anyway.
391 eval $set_cc_for_build
395 int n
; /* force
4-byte alignment
*/
400 0x7c, 0x7f, 0x42, 0xa6, /* mfpvr r3
*/
401 0x4e, 0x80, 0x00, 0x20, /* blr
*/
410 /* a separate
"fun" variable is necessary
for gcc
2.95.2 on MacOS
,
411 it gets a compiler error on a combined cast and call
*/
412 fun
= (unsigned
(*)()) getpvr.a
;
416 case 0x0001: puts
("powerpc601"); break;
417 case 0x0003: puts
("powerpc603"); break;
418 case 0x0004: puts
("powerpc604"); break;
419 case 0x0006: puts
("powerpc603e"); break;
420 case 0x0007: puts
("powerpc603e"); break; /* 603ev
*/
421 case 0x0008: puts
("powerpc750"); break;
422 case 0x0009: puts
("powerpc604e"); break;
423 case 0x000a: puts
("powerpc604e"); break; /* 604ev5
*/
424 case 0x000c: puts
("powerpc7400"); break;
425 case 0x0041: puts
("powerpc630"); break;
426 case 0x0050: puts
("powerpc860"); break;
427 case 0x8000: puts
("powerpc7450"); break;
428 case 0x8001: puts
("powerpc7455"); break;
429 case 0x8002: puts
("powerpc7457"); break;
430 case 0x8003: puts
("powerpc7447"); break; /* really
7447A
*/
431 case 0x800c: puts
("powerpc7410"); break;
436 if ($CC_FOR_BUILD $dummy.c
-o $dummy) >/dev
/null
2>&1; then
437 # This style construct is needed on AIX 4.3 to suppress the SIGILL error
438 # from (*fun)(). Using $SHELL -c $dummy 2>/dev/null doesn't work.
439 { x
=`$dummy`; } 2>/dev
/null
440 if test -n "$x"; then
445 # Grep the linux kernel /proc/cpuinfo pseudo-file.
446 # Anything unrecognised is ignored, since of course we mustn't spit out
447 # a cpu type config.sub doesn't know.
448 if test -z "$exact_cpu" && test -f /proc
/cpuinfo
; then
449 x
=`grep "^cpu[ ]" /proc/cpuinfo | head -n 1`
450 x
=`echo $x | sed -n 's/^cpu[ ]*:[ ]*\([A-Za-z0-9]*\).*/\1/p'`
451 x
=`echo $x | sed 's/PPC//'`
453 601) exact_cpu
="power" ;;
454 603ev
) exact_cpu
="powerpc603e" ;;
455 604ev5
) exact_cpu
="powerpc604e" ;;
456 970??
) exact_cpu
="powerpc970" ;;
457 603 |
603e |
604 |
604e |
750 |
821 |
860)
458 exact_cpu
="powerpc$x" ;;
460 exact_cpu
=`echo $x | sed "s;POWER;power;"` ;;
464 if test -z "$exact_cpu"; then
465 # On AIX, try looking at _system_configuration. This is present in
466 # version 4 at least.
469 #include <sys/systemcfg.h>
473 switch (_system_configuration.implementation) {
474 /* Old versions of AIX don't have all these constants,
475 use ifdef for safety. */
477 case POWER_RS2: puts ("power2"); break;
480 case POWER_601: puts ("power"); break;
483 case POWER_603: puts ("powerpc603"); break;
486 case POWER_604: puts ("powerpc604"); break;
489 case POWER_620: puts ("powerpc620"); break;
492 case POWER_630: puts ("powerpc630"); break;
494 /* Dunno what this is, leave it out for now.
495 case POWER_A35: puts ("powerpca35"); break;
497 /* This is waiting for a bit more info.
498 case POWER_RS64II: puts ("powerpcrs64ii"); break;
501 case POWER_4: puts ("power4"); break;
504 case POWER_5: puts ("power5"); break;
507 case POWER_6: puts ("power6"); break;
510 case POWER_7: puts ("power7"); break;
513 if (_system_configuration.architecture == POWER_RS)
515 else if (_system_configuration.width == 64)
521 if ($CC_FOR_BUILD $dummy.c
-o $dummy) >/dev
/null
2>&1; then
523 if test -n "$x"; then
529 if test -z "$exact_cpu"; then
530 # On MacOS X (or any Mach-O presumably), NXGetLocalArchInfo cpusubtype
531 # can tell us the exact cpu.
534 #include <mach-o/arch.h>
538 const NXArchInfo *a = NXGetLocalArchInfo();
539 if (a->cputype == CPU_TYPE_POWERPC)
541 switch (a->cpusubtype) {
542 /* The following known to Darwin 1.3. */
543 case CPU_SUBTYPE_POWERPC_601: puts ("powerpc601"); break;
544 case CPU_SUBTYPE_POWERPC_602: puts ("powerpc602"); break;
545 case CPU_SUBTYPE_POWERPC_603: puts ("powerpc603"); break;
546 case CPU_SUBTYPE_POWERPC_603e: puts ("powerpc603e"); break;
547 case CPU_SUBTYPE_POWERPC_603ev: puts ("powerpc603e"); break;
548 case CPU_SUBTYPE_POWERPC_604: puts ("powerpc604"); break;
549 case CPU_SUBTYPE_POWERPC_604e: puts ("powerpc604e"); break;
550 case CPU_SUBTYPE_POWERPC_620: puts ("powerpc620"); break;
551 case CPU_SUBTYPE_POWERPC_750: puts ("powerpc750"); break;
552 case CPU_SUBTYPE_POWERPC_7400: puts ("powerpc7400"); break;
553 case CPU_SUBTYPE_POWERPC_7450: puts ("powerpc7450"); break;
554 /* Darwin 6.8.5 doesn't define the following */
555 case 0x8001: puts ("powerpc7455"); break;
556 case 0x8002: puts ("powerpc7457"); break;
557 case 0x8003: puts ("powerpc7447"); break;
558 case 100: puts ("powerpc970"); break;
564 if ($CC_FOR_BUILD $dummy.c
-o $dummy) >/dev
/null
2>&1; then
566 if test -n "$x"; then
573 sparc-
*-* | sparc64-
*-*)
574 # If we can recognise an actual v7 then $exact_cpu is set to "sparc" so as
575 # to short-circuit subsequent tests.
577 # Grep the linux kernel /proc/cpuinfo pseudo-file.
578 # A typical line is "cpu\t\t: TI UltraSparc II (BlackBird)"
579 # See arch/sparc/kernel/cpu.c and arch/sparc64/kernel/cpu.c.
581 if test -f /proc
/cpuinfo
; then
582 if grep 'cpu.*Cypress' /proc
/cpuinfo
>/dev
/null
; then
583 exact_cpu
="sparc" # ie. v7
584 elif grep 'cpu.*Power-UP' /proc
/cpuinfo
>/dev
/null
; then
585 exact_cpu
="sparc" # ie. v7
586 elif grep 'cpu.*HyperSparc' /proc
/cpuinfo
>/dev
/null
; then
588 elif grep 'cpu.*SuperSparc' /proc
/cpuinfo
>/dev
/null
; then
589 exact_cpu
="supersparc"
590 elif grep 'cpu.*MicroSparc' /proc
/cpuinfo
>/dev
/null
; then
591 exact_cpu
="microsparc"
592 elif grep 'cpu.*MB86904' /proc
/cpuinfo
>/dev
/null
; then
593 # actually MicroSPARC-II
595 elif grep 'cpu.*UltraSparc T4' /proc
/cpuinfo
>/dev
/null
; then
596 exact_cpu
="ultrasparct4"
597 elif grep 'cpu.*UltraSparc T3' /proc
/cpuinfo
>/dev
/null
; then
598 exact_cpu
="ultrasparct3"
599 elif grep 'cpu.*UltraSparc T2' /proc
/cpuinfo
>/dev
/null
; then
600 exact_cpu
="ultrasparct2"
601 elif grep 'cpu.*UltraSparc T1' /proc
/cpuinfo
>/dev
/null
; then
602 exact_cpu
="ultrasparct1"
603 elif grep 'cpu.*UltraSparc III' /proc
/cpuinfo
>/dev
/null
; then
604 exact_cpu
="ultrasparc3"
605 elif grep 'cpu.*UltraSparc IIi' /proc
/cpuinfo
>/dev
/null
; then
606 exact_cpu
="ultrasparc2i"
607 elif grep 'cpu.*UltraSparc II' /proc
/cpuinfo
>/dev
/null
; then
608 exact_cpu
="ultrasparc2"
609 elif grep 'cpu.*UltraSparc' /proc
/cpuinfo
>/dev
/null
; then
610 exact_cpu
="ultrasparc"
614 # Need to invoke this for setup of $dummy
615 eval $set_cc_for_build
617 # Grep the output from sysinfo on SunOS.
618 # sysinfo has been seen living in /bin or in /usr/kvm
619 # cpu0 is a "SuperSPARC Model 41 SPARCmodule" CPU
620 # cpu0 is a "75 MHz TI,TMS390Z55" CPU
622 if test -z "$exact_cpu"; then
623 for i
in sysinfo
/usr
/kvm
/sysinfo
; do
624 if $SHELL -c $i 2>/dev
/null
>$dummy; then
625 if grep 'cpu0 is a "SuperSPARC' $dummy >/dev
/null
; then
628 elif grep 'cpu0 is a .*TMS390Z5.' $dummy >/dev
/null
; then
629 # TMS390Z50 and TMS390Z55
637 # Grep the output from prtconf on Solaris.
638 # Use an explicit /usr/sbin, since that directory might not be in a normal
641 # SUNW,UltraSPARC (driver not attached)
642 # SUNW,UltraSPARC-II (driver not attached)
643 # SUNW,UltraSPARC-IIi (driver not attached)
644 # SUNW,UltraSPARC-III+ (driver not attached)
645 # Ross,RT625 (driver not attached)
646 # TI,TMS390Z50 (driver not attached)
648 # /usr/sbin/sysdef prints similar information, but includes all loadable
649 # cpu modules, not just the real cpu.
651 # We first try a plain prtconf, since that is known to work on older systems.
652 # But for newer T1 systems, that doesn't produce any useful output, we need
653 # "prtconf -vp" there.
655 for prtconfopt
in "" "-vp"; do
656 if test -z "$exact_cpu"; then
657 if $SHELL -c "/usr/sbin/prtconf $prtconfopt" 2>/dev
/null
>$dummy; then
658 if grep 'SUNW,UltraSPARC-T3' $dummy >/dev
/null
; then
659 exact_cpu
=ultrasparct3
660 elif grep 'SUNW,UltraSPARC-T2' $dummy >/dev
/null
; then
661 exact_cpu
=ultrasparct2
662 elif grep 'SUNW,UltraSPARC-T1' $dummy >/dev
/null
; then
663 exact_cpu
=ultrasparct1
664 elif grep 'SUNW,UltraSPARC-III' $dummy >/dev
/null
; then
665 exact_cpu
=ultrasparc3
666 elif grep 'SUNW,UltraSPARC-IIi' $dummy >/dev
/null
; then
667 exact_cpu
=ultrasparc2i
668 elif grep 'SUNW,UltraSPARC-II' $dummy >/dev
/null
; then
669 exact_cpu
=ultrasparc2
670 elif grep 'SUNW,UltraSPARC' $dummy >/dev
/null
; then
672 elif grep 'Ross,RT62.' $dummy >/dev
/null
; then
673 # RT620, RT625, RT626 hypersparcs (v8).
675 elif grep 'TI,TMS390Z5.' $dummy >/dev
/null
; then
676 # TMS390Z50 and TMS390Z55
678 elif grep 'TI,TMS390S10' $dummy >/dev
/null
; then
680 elif grep 'FMI,MB86904' $dummy >/dev
/null
; then
681 # actually MicroSPARC-II
688 # Grep the output from sysctl hw.model on sparc or sparc64 *BSD.
689 # Use an explicit /sbin, since that directory might not be in a normal
690 # user's path. Example outputs,
692 # hw.model: Sun Microsystems UltraSparc-IIi
694 if test -z "$exact_cpu"; then
695 if $SHELL -c "/sbin/sysctl hw.model" 2>/dev
/null
>$dummy; then
696 if grep -i 'UltraSparc-T3' $dummy >/dev
/null
; then
697 exact_cpu
=ultrasparct3
698 elif grep -i 'UltraSparc-T2' $dummy >/dev
/null
; then
699 exact_cpu
=ultrasparct2
700 elif grep -i 'UltraSparc-T1' $dummy >/dev
/null
; then
701 exact_cpu
=ultrasparct1
702 elif grep -i 'UltraSparc-III' $dummy >/dev
/null
; then
703 exact_cpu
=ultrasparc3
704 elif grep -i 'UltraSparc-IIi' $dummy >/dev
/null
; then
705 exact_cpu
=ultrasparc2i
706 elif grep -i 'UltraSparc-II' $dummy >/dev
/null
; then
707 exact_cpu
=ultrasparc2
708 elif grep -i 'UltraSparc' $dummy >/dev
/null
; then
710 elif grep 'TMS390Z5.' $dummy >/dev
/null
; then
711 # TMS390Z50 and TMS390Z55
713 elif grep 'TMS390S10' $dummy >/dev
/null
; then
715 elif grep 'MB86904' $dummy >/dev
/null
; then
716 # actually MicroSPARC-II
718 elif grep 'MB86907' $dummy >/dev
/null
; then
724 # sun4m and sun4d are v8s of some sort, sun4u is a v9 of some sort
726 if test -z "$exact_cpu"; then
728 sun4
[md
]) exact_cpu
=sparcv8
;;
729 sun4u
) exact_cpu
=sparcv9
;;
735 # Recognise x86 processors using a tricky cpuid with 4 arguments, repeating
736 # arguments; for x86-64 we effectively pass the 1st in rdx and the 2nd in rcx.
737 # This allows the same asm to work for both standard and Windoze calling
740 i?
86-*-* | amd64-
*-* | x86_64-
*-*)
741 eval $set_cc_for_build
746 #define CPUID(a,b) cpuid(b,a,a,b)
750 unsigned int cpuid (int, char *, char *, int);
754 char vendor_string[13];
755 char dummy_string[12];
757 int family, model, stepping;
758 const char *modelstr;
762 CPUID (vendor_string, 0);
763 vendor_string[12] = 0;
765 fms = CPUID (dummy_string, 1);
767 family = ((fms >> 8) & 0xf) + ((fms >> 20) & 0xff);
768 model = ((fms >> 4) & 0xf) + ((fms >> 12) & 0xf0);
769 stepping = fms & 0xf;
771 modelstr = "$guess_cpu";
773 /**************************************************/
774 /*** WARNING: keep this list in sync with fat.c ***/
775 /**************************************************/
776 if (strcmp (vendor_string, "GenuineIntel") == 0)
781 if (model <= 2) modelstr = "pentium";
782 else if (model >= 4) modelstr = "pentiummmx";
785 if (model <= 1) modelstr = "pentiumpro";
786 else if (model <= 6) modelstr = "pentium2";
787 else if (model <= 8) modelstr = "pentium3";
788 else if (model <= 9) modelstr = "pentiumm";
789 else if (model <= 0x0c) modelstr = "pentium3";
790 else if (model <= 0x0e) modelstr = "pentiumm";
791 else if (model <= 0x19) cpu_64bit = 1, modelstr = "core2";
792 else if (model == 0x1a) cpu_64bit = 1, modelstr = "coreinhm"; /* NHM Gainestown */
793 else if (model == 0x1c) cpu_64bit = 1, modelstr = "atom"; /* Silverthorne */
794 else if (model == 0x1d) cpu_64bit = 1, modelstr = "core2"; /* PNR Dunnington */
795 else if (model == 0x1e) cpu_64bit = 1, modelstr = "coreinhm"; /* NHM Lynnfield/Jasper */
796 else if (model == 0x25) cpu_64bit = 1, modelstr = "coreiwsm"; /* WSM Clarkdale/Arrandale */
797 else if (model == 0x26) cpu_64bit = 1, modelstr = "atom"; /* Lincroft */
798 else if (model == 0x27) cpu_64bit = 1, modelstr = "atom"; /* Saltwell */
799 else if (model == 0x2a) cpu_64bit = 1, modelstr = "coreisbr"; /* SB */
800 else if (model == 0x2c) cpu_64bit = 1, modelstr = "coreiwsm"; /* WSM Gulftown */
801 else if (model == 0x2d) cpu_64bit = 1, modelstr = "coreisbr"; /* SBC-EP */
802 else if (model == 0x2e) cpu_64bit = 1, modelstr = "coreinhm"; /* NHM Beckton */
803 else if (model == 0x2f) cpu_64bit = 1, modelstr = "coreiwsm"; /* WSM Eagleton */
804 else if (model == 0x36) cpu_64bit = 1, modelstr = "atom"; /* Cedarview/Saltwell */
805 else if (model == 0x37) cpu_64bit = 1, modelstr = "coreinhm"; /* Atom Silvermont */
806 else if (model == 0x3a) cpu_64bit = 1, modelstr = "coreisbr"; /* IBR */
807 else if (model == 0x3c) cpu_64bit = 1, modelstr = "coreihwl"; /* Haswell client */
808 else if (model == 0x3d) cpu_64bit = 1, modelstr = "coreibwl"; /* Broadwell */
809 else if (model == 0x3e) cpu_64bit = 1, modelstr = "coreisbr"; /* Ivytown */
810 else if (model == 0x3f) cpu_64bit = 1, modelstr = "coreihwl"; /* Haswell server */
811 else if (model == 0x45) cpu_64bit = 1, modelstr = "coreihwl"; /* Haswell ULT */
812 else if (model == 0x46) cpu_64bit = 1, modelstr = "coreihwl"; /* Crystal Well */
813 else if (model == 0x4d) cpu_64bit = 1, modelstr = "coreinhm"; /* Silvermont/Avoton */
814 else if (model == 0x4f) cpu_64bit = 1, modelstr = "coreibwl"; /* Broadwell server */
815 else if (model == 0x56) cpu_64bit = 1, modelstr = "coreibwl"; /* Broadwell microserver */
816 else cpu_64bit = 1, modelstr = "corei"; /* default */
818 if (strcmp (modelstr, "coreihwl") == 0)
820 /* Some Haswells lack BMI2. Let them appear as Sandybridges for
822 CPUID (dummy_string, 7);
823 if ((dummy_string[0 + 8 / 8] & (1 << (8 % 8))) == 0)
824 modelstr = "coreisbr";
829 cpu_64bit = 1, modelstr = "pentium4";
833 else if (strcmp (vendor_string, "AuthenticAMD") == 0)
838 if (model <= 3) modelstr = "k5";
839 else if (model <= 7) modelstr = "k6";
840 else if (model == 8) modelstr = "k62";
841 else if (model == 9) modelstr = "k63";
842 else if (model == 10) modelstr = "geode";
843 else if (model == 13) modelstr = "k63";
848 case 15: /* K8, K9 */
849 cpu_64bit = 1, modelstr = "k8";
852 cpu_64bit = 1, modelstr = "k10";
854 case 17: /* Hybrid k8/k10, claim k8 */
855 cpu_64bit = 1, modelstr = "k8";
857 case 18: /* Llano, uses K10 core */
858 cpu_64bit = 1, modelstr = "k10";
860 case 19: /* AMD Internal, assume future K10 */
861 cpu_64bit = 1, modelstr = "k10";
863 case 20: /* Bobcat */
864 cpu_64bit = 1, modelstr = "bobcat";
866 case 21: /* Bulldozer */
869 modelstr = "bulldozer";
870 else if (model < 0x20) /* really 2, [0x10-0x20) */
871 modelstr = "piledriver";
872 else if (model < 0x40) /* really [0x30-0x40) */
873 modelstr = "steamroller";
874 else /* really [0x60-0x70) */
875 modelstr = "excavator";
877 case 22: /* Jaguar, an improved bobcat */
878 cpu_64bit = 1, modelstr = "jaguar";
882 else if (strcmp (vendor_string, "CyrixInstead") == 0)
884 /* Should recognize Cyrix' processors too. */
886 else if (strcmp (vendor_string, "CentaurHauls") == 0)
891 if (model < 9) modelstr = "viac3";
892 else if (model < 15) modelstr = "viac32";
893 else cpu_64bit = 1, modelstr = "nano";
898 CPUID (dummy_string, 0x80000001);
899 cpuid_64bit = (dummy_string[7] >> 5) & 1;
901 /* If our cpuid-based CPU identification thinks this is a 32-bit CPU but
902 cpuid claims AMD64 capabilities, then revert to the generic "x86_64".
903 This is of course wrong, but it can happen in some emulators, so this
904 workaround allows for successful 64-bit builds. */
905 if (cpuid_64bit && ! cpu_64bit)
908 printf ("%s", modelstr);
913 # The rcx/ecx zeroing here and in the variant below is needed for the BMI2
916 cat <<EOF >${dummy}0.s
934 if ($CC_FOR_BUILD ${dummy}0.s
$dummy.c
-o $dummy) >/dev
/null
2>&1; then
935 # On 80386 and early 80486 cpuid is not available and will result in a
936 # SIGILL message, hence 2>/dev/null.
938 # On i386-unknown-freebsd4.9, "/bin/sh -c ./dummy" seems to send an
939 # "Illegal instruction (core dumped)" message to stdout, so we test $?
940 # to check if the program run was successful.
942 x
=`$SHELL -c $dummy 2>/dev/null`
943 if test $?
= 0 && test -n "$x"; then
948 cat <<EOF >${dummy}0.s
968 if test -z "$exact_cpu"; then
969 if ($CC_FOR_BUILD ${dummy}0.s
$dummy.c
-o $dummy) >/dev
/null
2>&1; then
970 # On 80386 and early 80486 cpuid is not available and will result in a
971 # SIGILL message, hence 2>/dev/null.
973 # On i386-unknown-freebsd4.9, "/bin/sh -c ./dummy" seems to send an
974 # "Illegal instruction (core dumped)" message to stdout, so we test $?
975 # to check if the program run was successful.
977 x
=`$SHELL -c $dummy 2>/dev/null`
978 if test $?
= 0 && test -n "$x"; then
984 # We need to remove some .o files here since lame C compilers
985 # generate these even when not asked.
989 model
=`grep "^processor 0: version =" /proc/cpuinfo | sed -e 's/.*machine = //'`
991 2064 |
2066) zcpu
="z900" ;;
992 2084 |
2086) zcpu
="z990" ;;
993 2094 |
2096) zcpu
="z9" ;;
994 2097 |
2098) zcpu
="z10" ;;
995 2817 |
2818 |
*) zcpu
="z196" ;;
997 case "$guess_full" in
998 s390x-
*-*) exact_cpu
=${zcpu} ;;
999 s390-
*-*) exact_cpu
=${zcpu}esa
;;
1007 # -------------------------------------------------------------------------
1008 # Use an exact cpu, if possible
1010 if test -n "$exact_cpu"; then
1011 echo "$exact_cpu$guess_rest"