X-Git-Url: https://gcc.gnu.org/git/?a=blobdiff_plain;f=gcc%2Fenquire.c;h=bb5ea0be604cbe6fa54e2085708c0528894336e6;hb=05ca950a640db0fe4feccd68a30ef9cdaeac40a0;hp=d9e16f167889b06d820948f657e7298a1c6fac93;hpb=39ed64b80194686350080ad6edc37fd091c3c0eb;p=gcc.git diff --git a/gcc/enquire.c b/gcc/enquire.c index d9e16f167889..bb5ea0be604c 100644 --- a/gcc/enquire.c +++ b/gcc/enquire.c @@ -1,5 +1,5 @@ /* Everything you wanted to know about your machine and C compiler, - but didn't know who to ask. */ + but didn't know who to ask. */ #ifndef VERSION #define VERSION "4.3" @@ -20,7 +20,9 @@ Support NO_LONG_DOUBLE_IO in f_define and f_rep; new fn fake_f_rep, Apr 92. Enclose -f output in #ifndef _FLOAT_H___, Richard Stallman, May 92. - Add #undef before every #define, Jim Wilson, Dec 92. + Change by Jim Wilson: + Add #undef before every #define, Dec 92. + Use stddef.h not gstddef.h, Mar 94. Changes by Paul Eggert, installed Feb 93: (fake_f_rep): Clear all of u, initially. Make the ints in u unsigned. @@ -29,6 +31,13 @@ Richard Stallman, May 93: In F_check, check NO_LONG_DOUBLE_IO. + Changes by Stephen Moshier, installed Sep 93: + (FPROP): Recognize 80387 or 68881 XFmode format. + + Change by Manfred Hollstein, installed Mar 98: + (bitpattern): Change type of variable i to unsigned int. + + COMPILING With luck and a following wind, just the following will work: cc enquire.c -o enquire @@ -301,7 +310,7 @@ #endif /* NO_FILE */ #endif /* FILENAME */ -/* If PASS isn't defined, then this is the first pass over this file. */ +/* If PASS isn't defined, then this is the first pass over this file. */ #ifndef PASS #ifndef SEP #define PASS 1 @@ -381,11 +390,16 @@ #endif /* STDC */ /* include files */ +/* Stdio.h might include limits.h, and limits.h might include float.h, and + float.h is probably the float.h put together by the gcc makefile to + cause errors. We use our special define to assure float.h that we don't + really need it. */ +#define __GCC_FLOAT_NOT_NEEDED #include #ifdef STDC #ifndef NO_STDDEF -#include "gstddef.h" /* for size_t: if this fails, define NO_STDDEF */ +#include /* for size_t: if this fails, define NO_STDDEF */ #endif #endif @@ -410,6 +424,13 @@ #ifdef VERIFY #include "limits.h" +#endif + +#ifndef SYS_FLOAT_H_WRAP +#define SYS_FLOAT_H_WRAP 0 +#endif + +#if SYS_FLOAT_H_WRAP || defined VERIFY #include "float.h" #endif @@ -466,7 +487,8 @@ Procedure endian ARGS((int bits_per_byte)); int exponent ARGS((Long_double x, double *fract, int *exp)); int floor_log ARGS((int base, Long_double x)); Procedure f_define ARGS((char *desc, char *extra, char *sort, char *name, - int prec, Long_double val, char *mark)); + int prec, Long_double val, Long_double req, + char *mark)); Procedure i_define ARGS((char *desc, char *extra, char *sort, char *name, long val, long lim, long req, char *mark)); Procedure u_define ARGS((char *desc, char *extra, char *sort, char *name, @@ -609,7 +631,7 @@ Procedure croak(place) int place; { farewell(bugs+1); /* An exit isn't essential here, but avoids loops */ } -/* This is here in case alloca.c is used, which calls this. */ +/* This is here in case alloca.c is used, which calls this. */ char *xmalloc(size) unsigned size; { char *value = (char *)malloc(size); if (value == 0) { @@ -642,8 +664,6 @@ int maximum_int() { int main(argc, argv) int argc; char *argv[]; { int dprec, fprec, lprec; - unsigned int size; - long total; int i; char *s; int bad; #ifdef SIGFPE @@ -695,6 +715,8 @@ int main(argc, argv) int argc; char *argv[]; { if (F) { printf ("#ifndef _FLOAT_H___\n"); printf ("#define _FLOAT_H___\n"); + if (SYS_FLOAT_H_WRAP) + printf ("#include_next \n"); } #ifdef ID printf("%sProduced on %s by enquire version %s, CWI, Amsterdam%s\n", @@ -745,6 +767,8 @@ int main(argc, argv) int argc; char *argv[]; { } #ifndef NO_MEM if (V) { + unsigned int size; + long total; /* An extra goody: the approximate amount of data-space */ /* Allocate store until no more available */ /* Different implementations have a different argument type @@ -761,7 +785,7 @@ int main(argc, argv) int argc; char *argv[]; { size/=2; } - Vprintf("%sMemory mallocatable ~= %ld Kbytes%s\n", + Vprintf("%sMemory allocable ~= %ld Kbytes%s\n", co, (total+511)/512, oc); } #endif @@ -787,6 +811,8 @@ Procedure describe(description, extra) char *description, *extra; { Procedure i_define(desc, extra, sort, name, val, lim, req, mark) char *desc, *extra, *sort, *name; long val, lim, req; char *mark; { + if (SYS_FLOAT_H_WRAP && F && val == req) + return; /* Produce a #define for a signed int type */ describe(desc, extra); printf("#undef %s%s\n", sort, name); @@ -795,21 +821,19 @@ Procedure i_define(desc, extra, sort, name, val, lim, req, mark) } else if (val + lim < 0) { /* We may not produce a constant like -1024 if the max allowable value is 1023. It has then to be output as - -1023-1. lim is the max allowable value. */ + -1023-1. lim is the max allowable value. */ printf("#define %s%s (%ld%s%ld%s)\n", sort, name, -lim, mark, val+lim, mark); } else { printf("#define %s%s (%ld%s)\n", sort, name, val, mark); } - /* If VERIFY is not set, val and req are just the same value; - if it is set, val is the value as calculated, and req is - the #defined constant - */ +#ifdef VERIFY if (val != req) { printf("%s*** Verify failed for above #define!\n", co); printf(" Compiler has %ld for value%s\n\n", req, oc); bugs++; } +#endif Vprintf("\n"); } @@ -819,17 +843,21 @@ Procedure u_define(desc, extra, sort, name, val, req, mark) describe(desc, extra); printf("#undef %s%s\n", sort, name); printf("#define %s%s %lu%s%s\n", sort, name, val, U, mark); +#ifdef VERIFY if (val != req) { printf("%s*** Verify failed for above #define!\n", co); printf(" Compiler has %lu for value%s\n\n", req, oc); bugs++; } +#endif Vprintf("\n"); } -Procedure f_define(desc, extra, sort, name, precision, val, mark) +Procedure f_define(desc, extra, sort, name, precision, val, req, mark) char *desc, *extra, *sort, *name; int precision; - Long_double val; char *mark; { + Long_double val, req; char *mark; { + if (SYS_FLOAT_H_WRAP && F && val == req) + return; /* Produce a #define for a float/double/long double */ describe(desc, extra); printf ("#undef %s%s\n", sort, name); @@ -921,7 +949,7 @@ char *fake_f_rep(type, val) char *type; Long_double val; { union { unsigned int i[4]; Long_double ld;} u; u.i[0] = u.i[1] = u.i[2] = u.i[3] = 0; u.ld = val; - sprintf(buf, "(__extension__ ((union __convert_long_double) {0x%x, 0x%x, 0x%x, 0x%x}).__convert_long_double_d)", + sprintf(buf, "(__extension__ ((union __convert_long_double) {__convert_long_double_i: {0x%x, 0x%x, 0x%x, 0x%x}}).__convert_long_double_d)", u.i[0], u.i[1], u.i[2], u.i[3]); return buf; } @@ -929,7 +957,6 @@ char *fake_f_rep(type, val) char *type; Long_double val; { char *f_rep(precision, val) int precision; Long_double val; { /* Return the floating representation of val */ static char buf[1024]; - char *f1; #ifdef NO_LONG_DOUBLE_IO if (1) #else @@ -950,7 +977,8 @@ char *f_rep(precision, val) int precision; Long_double val; { Procedure bitpattern(p, size) char *p; unsigned int size; { /* Printf the bit-pattern of p */ char c; - int i, j; + unsigned int i; + int j; for (i=1; i<=size; i++) { c= *p; @@ -1058,8 +1086,8 @@ Procedure ftyperr(name, esize, size) char *name; int esize, size; { name, ftype_of(esize), ftype_of(size)); } -promotions() { - int si; long sl; +int promotions() { + int si = 0; long sl = 0; unsigned int ui; unsigned long ul; short ss; unsigned short us; @@ -1080,8 +1108,9 @@ promotions() { eek_a_bug("promotions don't work properly in conditional expressions\n"); } - showtype("unsigned short promotes to", Promoted((unsigned short)0)); + showtype("unsigned short promotes to", Promoted((unsigned short) 0)); showtype("long+unsigned gives", sl+ui); + return 0; } #define checktype(x, n, s, t) if((sgn(x)!=s)||(sizeof(x)!=sizeof(t))) typerr(n, s, sizeof(t), sign_of(x), sizeof(x)); @@ -1097,7 +1126,7 @@ Procedure check_defines() { usign= Signed; #else /* Implementations promote unsigned short differently */ - usign= is_signed((unsigned short)0); + usign= is_signed((unsigned short) 0); #endif if (L) { @@ -1383,21 +1412,42 @@ int cprop() { c=0; char_max=0; c++; - if (setjmp(lab)==0) { /* Yields char_max */ - while (c>char_max) { - char_max=c; - c++; - } + if (bits_per_byte <= 16) { + if (setjmp(lab)==0) { /* Yields char_max */ + while (c>char_max) { + char_max=c; + c++; + } + } else { + Vprintf("%sCharacter overflow generates a trap!%s\n", + co, oc); + } + c=0; char_min=0; + c--; + if (setjmp(lab)==0) { /* Yields char_min */ + while (c char_max) + char_max = ~0; + c = 0; + char_min = 0; + c--; + if (c < char_min) { + c = (1 << (bits_per_byte - 1)) - 1; + c = -c; + char_min = c; + c--; + if (c < char_min) + char_min = c; + } } if (c_signed && char_min == 0) { Vprintf("%sBEWARE! Chars are pseudo-unsigned:%s\n", co, oc); @@ -1543,7 +1593,7 @@ if (V) printf ("%s%s %s %s%s\n", co, "Type size_t is", /* Alignment constants ********************************************/ #define alignment(TYPE) \ - ((long)((char *)&((struct{char c; TYPE d;}*)0)->d - (char *)0)) + ((long)((char *)&((struct{char c; TYPE d;}*)0)->d - (char *) 0)) Vprintf("\n%sALIGNMENTS%s\n", co, oc); @@ -1579,18 +1629,20 @@ if (V) printf ("%s%s %s %s%s\n", co, "Type size_t is", Vprintf("\n%sPROPERTIES OF POINTERS%s\n", co, oc); - if ((long) (char *) &variable == (long) (int *) &variable) + if ((long) (char *) &variable == (long) (int *) &variable) { Vprintf("%sChar and int pointer formats seem identical%s\n", co, oc); - else + } else { Vprintf("%sChar and int pointer formats are different%s\n", co, oc); - if ((long) (char *) &variable == (long) (function *) &variable) + } + if ((long) (char *) &variable == (long) (function *) &variable) { Vprintf("%sChar and function pointer formats seem identical%s\n", co, oc); - else + } else { Vprintf("%sChar and function pointer formats are different%s\n", co, oc); + } if (V) { if ("abcd"=="abcd") @@ -1734,7 +1786,6 @@ extern char *f_rep(); #define UPROP usprop #define Uname "USHRT" -#ifdef VERIFY #ifdef SHRT_MAX #define I_MAX SHRT_MAX #endif @@ -1778,7 +1829,6 @@ extern char *f_rep(); #ifdef FLT_MAX_10_EXP #define F_MAX_10_EXP FLT_MAX_10_EXP #endif -#endif /* VERIFY */ #endif /* PASS1 */ @@ -1820,7 +1870,6 @@ extern char *f_rep(); #define UPROP uiprop #define Uname "UINT" -#ifdef VERIFY #ifdef INT_MAX #define I_MAX INT_MAX #endif @@ -1858,7 +1907,6 @@ extern char *f_rep(); #ifdef DBL_MAX_10_EXP #define F_MAX_10_EXP DBL_MAX_10_EXP #endif -#endif /* VERIFY */ #endif /* PASS2 */ @@ -1906,7 +1954,6 @@ extern char *f_rep(); #define UPROP ulprop #define Uname "ULONG" -#ifdef VERIFY #ifdef LONG_MAX #define I_MAX LONG_MAX #endif @@ -1944,52 +1991,53 @@ extern char *f_rep(); #ifdef LDBL_MAX_10_EXP #define F_MAX_10_EXP LDBL_MAX_10_EXP #endif -#endif /* VERIFY */ #endif /* PASS3 */ +#define UNDEFINED (-2) + #ifndef I_MAX -#define I_MAX int_max +#define I_MAX ((unsigned long) UNDEFINED) #endif #ifndef I_MIN -#define I_MIN int_min +#define I_MIN ((unsigned long) UNDEFINED) #endif #ifndef U_MAX -#define U_MAX u_max +#define U_MAX ((unsigned long) UNDEFINED) #endif #ifndef F_RADIX -#define F_RADIX f_radix +#define F_RADIX UNDEFINED #endif #ifndef F_MANT_DIG -#define F_MANT_DIG f_mant_dig +#define F_MANT_DIG UNDEFINED #endif #ifndef F_DIG -#define F_DIG f_dig +#define F_DIG UNDEFINED #endif #ifndef F_ROUNDS -#define F_ROUNDS f_rounds +#define F_ROUNDS UNDEFINED #endif #ifndef F_EPSILON -#define F_EPSILON f_epsilon +#define F_EPSILON ((Number) UNDEFINED) #endif #ifndef F_MIN_EXP -#define F_MIN_EXP f_min_exp +#define F_MIN_EXP UNDEFINED #endif #ifndef F_MIN -#define F_MIN f_min +#define F_MIN ((Number) UNDEFINED) #endif #ifndef F_MIN_10_EXP -#define F_MIN_10_EXP f_min_10_exp +#define F_MIN_10_EXP UNDEFINED #endif #ifndef F_MAX_EXP -#define F_MAX_EXP f_max_exp +#define F_MAX_EXP UNDEFINED #endif #ifndef F_MAX -#define F_MAX f_max +#define F_MAX ((Number) UNDEFINED) #endif #ifndef F_MAX_10_EXP -#define F_MAX_10_EXP f_max_10_exp +#define F_MAX_10_EXP UNDEFINED #endif #ifndef VERIFY @@ -2394,7 +2442,9 @@ int FPROP(bits_per_byte) int bits_per_byte; { } if (PASS == 1) { /* only for FLT */ flt_rounds= f_rounds; - if (F) + /* Prefer system float.h definition of F_ROUNDS, + since it's more likely to be right than our "1". */ + if (F && (!SYS_FLOAT_H_WRAP || F_ROUNDS == UNDEFINED)) i_define(D_FLT_ROUNDS, "", "FLT", "_ROUNDS", (long) f_rounds, 1L, (long) F_ROUNDS, ""); } else if (f_rounds != flt_rounds) { @@ -2481,7 +2531,9 @@ int FPROP(bits_per_byte) int bits_per_byte; { /* Possible loss of precision warnings here from non-stdc compilers */ if (F) f_define(D_EPSILON, thing, - Fname, "_EPSILON", digs, (Long_double) f_epsilon, MARK); + Fname, "_EPSILON", digs, + (Long_double) f_epsilon, + (Long_double) F_EPSILON, MARK); if (V || F) F_check(digs, (Long_double) f_epsilon); Unexpected(21); if (F) Validate(digs, (Long_double) f_epsilon, (Long_double) F_EPSILON, @@ -2559,7 +2611,9 @@ int FPROP(bits_per_byte) int bits_per_byte; { /* Possible loss of precision warnings here from non-stdc compilers */ if (setjmp(lab) == 0) { if (F) f_define(D_MIN, thing, - Fname, "_MIN", digs, (Long_double) f_min, MARK); + Fname, "_MIN", digs, + (Long_double) f_min, + (Long_double) F_MIN, MARK); if (V || F) F_check(digs, (Long_double) f_min); } else { eek_a_bug("xxx_MIN caused a trap"); @@ -2653,7 +2707,9 @@ int FPROP(bits_per_byte) int bits_per_byte; { if (setjmp(lab)==0) { /* Possible loss of precision warnings here from non-stdc compilers */ if (F) f_define(D_MAX, thing, - Fname, "_MAX", digs, (Long_double) f_max, MARK); + Fname, "_MAX", digs, + (Long_double) f_max, + (Long_double) F_MAX, MARK); if (V || F) F_check(digs, (Long_double) f_max); } else { eek_a_bug("xxx_MAX caused a trap"); @@ -2678,6 +2734,14 @@ int FPROP(bits_per_byte) int bits_per_byte; { if (f_radix != 10) { hidden=0; mantbits=floor_log(2, (Long_double)f_radix)*f_mant_dig; + if (mantbits == 64 + && iexp == 15 + && f_max_exp+f_min_exp > 0 /* ??? f_min_exp may be wrong. */ + && mantbits+iexp+17 == (int)sizeof(Number)*bits_per_byte) { + Vprintf("%sArithmetic probably doesn't use a hidden bit%s\n", co, oc); + Vprintf("%sIt's probably 80387 or 68881 extended real%s\n", co, oc); + goto is_extended; + } if (mantbits+iexp == (int)sizeof(Number)*bits_per_byte) { hidden=1; Vprintf("%sArithmetic uses a hidden bit%s\n", co, oc); @@ -2698,6 +2762,7 @@ int FPROP(bits_per_byte) int bits_per_byte; { f_mant_dig==53 ? "double" : f_mant_dig >53 ? "extended" : "some", oc); +is_extended: if (f_rounds != 1 || normal) { Vprintf("%s though ", co); if (f_rounds != 1) {