Specifically, eliminate all uses of implicit function declarations and of old-style function definitions for functions that take arguments.
Many of the C programs embedded in config.guess are only used on very old systems that may never have had an ISO C compiler (other than GCC, which we cannot assume has been installed) so we have to do this carefully. All uses of ‘exit’ are replaced with returning from main, to avoid the question of whether stdlib.h exists. stdio.h is assumed to exist, and assumed to declare ‘puts’ and ‘printf’ on all systems where the compiler objects to implicit function declarations. Wherever possible, uses of printf are demoted to puts, and writing to stdout at all is demoted to exit codes. As discussed in the previous patch, it may not be safe to use ‘void’ at all, but it should be OK to continue *defining* functions that take no arguments as ‘T foo() { … }’ where T is the return type, despite this technically being an old-style function definition. The only place where we had a C function defined to take arguments, those arguments were unnecessary, and in fact an execution check was unnecessary; the whole thing has been replaced with a preprocessor-only check and string manipulation in shell. --- config.guess | 110 ++++++++++++++++++++++++--------------------------- 1 file changed, 51 insertions(+), 59 deletions(-) diff --git a/config.guess b/config.guess index b7f5e24..0ec3a83 100755 --- a/config.guess +++ b/config.guess @@ -4,7 +4,7 @@ # shellcheck disable=SC2006,SC2268 # see below for rationale -timestamp='2024-04-03' +timestamp='2024-04-04' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -534,29 +534,22 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in mips:*:*:UMIPS | mips:*:*:RISCos) set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" -#ifdef __cplusplus -#include <stdio.h> /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif + #include <stdio.h> #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); + SYSTYPE=sysv #endif #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); + SYSTYPE=svr4 #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); + SYSTYPE=bsd #endif - #endif - exit (-1); - } EOF - $CC_FOR_BUILD -o "$dummy" "$dummy.c" && - dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`"$dummy" "$dummyarg"` && + SYSTEM_TYPE=`$CC_FOR_BUILD -E - < "$dummy.c" | + sed -n 's/^ *SYSTYPE *= *//p'` && + SYSTEM_REL=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=mips-mips-riscos${SYSTEM_REL}${SYSTEM_TYPE} && { echo "$SYSTEM_NAME"; exit; } GUESS=mips-mips-riscos$UNAME_RELEASE ;; @@ -633,19 +626,15 @@ EOF set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #include <sys/systemcfg.h> - int main () - { - if (!__power_pc()) - exit(1); - puts("powerpc-ibm-aix3.2.5"); - exit(0); - } + { + return !__power_pc (); + } EOF - if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && "$dummy" then - GUESS=$SYSTEM_NAME + GUESS=powerpc-ibm-aix3.2.5 else GUESS=rs6000-ibm-aix3.2.5 fi @@ -714,9 +703,8 @@ EOF if test "$HP_ARCH" = ""; then set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" - #define _HPUX_SOURCE - #include <stdlib.h> + #include <stdio.h> #include <unistd.h> int @@ -744,7 +732,7 @@ EOF #endif default: puts ("hppa1.0"); break; } - exit (0); + return 0; } EOF (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` @@ -781,6 +769,7 @@ EOF 3050*:HI-UX:*:*) set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" + #include <stdio.h> #include <unistd.h> int main () @@ -793,20 +782,24 @@ EOF { switch (cpu) { - case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; - case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; - default: puts ("hppa-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0"); break; + default: puts ("hppa"); break; } } else if (CPU_IS_HP_MC68K (cpu)) - puts ("m68k-hitachi-hiuxwe2"); - else puts ("unknown-hitachi-hiuxwe2"); - exit (0); + puts ("m68k"); + else puts ("unknown"); + return 0; } EOF - $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && - { echo "$SYSTEM_NAME"; exit; } + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_CPU=`"$dummy"`; then + if [ "$SYSTEM_CPU" != "unknown" ]; then + echo "${SYSTEM_CPU}-hitachi-hiuxwe2" + exit + fi + fi GUESS=unknown-hitachi-hiuxwe2 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) @@ -1611,6 +1604,7 @@ fi # No uname command or uname output not recognized. set_cc_for_build cat > "$dummy.c" <<EOF +#include <stdio.h> #ifdef _SEQUENT_ #include <sys/types.h> #include <sys/utsname.h> @@ -1630,16 +1624,14 @@ main () #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); + puts ("mips-sony-bsd"); return 0; #else #include <sys/param.h> - printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 - "4" + puts ("m68k-sony-newsos4"); return 0; #else - "" + puts ("m68k-sony-newsos"); return 0; #endif - ); exit (0); #endif #endif @@ -1658,26 +1650,26 @@ main () #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); + puts ("ns32k-encore-sysv"); return 0; #else #if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); + puts ("ns32k-encore-mach"); return 0; #else - printf ("ns32k-encore-bsd\n"); exit (0); + puts ("ns32k-encore-bsd"); return 0; #endif #endif #endif #if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); + puts ("i386-pc-bsd"); return 0; #endif #if defined (sequent) #if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); + puts ("i386-sequent-dynix"); return 0; #endif #if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); + puts ("ns32k-sequent-dynix"); return 0; #endif #endif @@ -1686,12 +1678,12 @@ main () uname(&un); if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); + puts ("i386-sequent-ptx2"); return 0; } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); + puts ("i386-sequent-ptx1"); return 0; } - printf ("i386-sequent-ptx\n"); exit (0); + puts ("i386-sequent-ptx"); return 0; #endif #if defined (vax) @@ -1699,16 +1691,16 @@ main () #include <sys/param.h> #if defined (BSD) #if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); + puts ("vax-dec-bsd4.3"); return 0; #else #if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); + puts ("vax-dec-bsd4.3reno"); return 0; #else - printf ("vax-dec-bsd\n"); exit (0); + puts ("vax-dec-bsd"); return 0; #endif #endif #else - printf ("vax-dec-bsd\n"); exit (0); + puts ("vax-dec-bsd"); return 0; #endif #else #if defined(_SIZE_T_) || defined(SIGLOST) @@ -1716,7 +1708,7 @@ main () uname (&un); printf ("vax-dec-ultrix%s\n", un.release); exit (0); #else - printf ("vax-dec-ultrix\n"); exit (0); + puts ("vax-dec-ultrix"); return 0; #endif #endif #endif @@ -1727,16 +1719,16 @@ main () uname (&un); printf ("mips-dec-ultrix%s\n", un.release); exit (0); #else - printf ("mips-dec-ultrix\n"); exit (0); + puts ("mips-dec-ultrix"); return 0; #endif #endif #endif #if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); + puts ("i860-alliant-bsd"); return 0; #endif - exit (1); + return 1; } EOF -- 2.43.2