⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enquire.c

📁 GUN开源阻止下的编译器GCC
💻 C
📖 第 1 页 / 共 5 页
字号:
/* Everything you wanted to know about your machine and C compiler,   but didn't know who to ask. */#ifndef VERSION#define VERSION "4.3"#endif/* Author: Steven Pemberton, CWI, Amsterdam; steven@cwi.nl   Bugfixes and upgrades gratefully received.   Copyright (c) 1988, 1989, 1990 Steven Pemberton, CWI, Amsterdam.   All rights reserved.   Changes by Richard Stallman:   Undef CHAR_BIT, etc., if defined in stdio.h, Richard Stallman, Aug 90.   In EPROP, avoid a <= old if bad is set, Richard Stallman, May 91.   Use gstddef.h, not stddef.h, Richard Stallman, Nov 91.   Don't declare malloc, instead cast the value, Richard Stallman, Nov 91.   Include sys/types.h before signal.h, Apr 92.   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.   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.   (f_define): Use ordinary constants for long double   if it's same width as double.  Make __convert_long_double_i unsigned.   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.   COMPILING   With luck and a following wind, just the following will work:	cc enquire.c -o enquire   You may get some messages about unreachable code, which you can ignore.   If your compiler doesn't support:		add flag:	signed char (eg pcc)			-DNO_SC	unsigned char				-DNO_UC	unsigned short and long			-DNO_UI	void					-DNO_VOID	signal(), or setjmp/longjmp()		-DNO_SIG	%Lf in printf				-DNO_LONG_DOUBLE_IO   Try to compile first with no flags, and see if you get any errors -   you might be surprised. (Most non-ANSI compilers need -DNO_SC, though.)   Some compilers need a -f flag for floating point.   Don't use any optimisation flags: the program may not work if you do.   Though "while (a+1.0-a-1.0 == 0.0)" may look like "while(1)" to an   optimiser, to a floating-point unit there's a world of difference.   Some compilers offer various flags for different floating point   modes; it's worth trying all possible combinations of these.   Add -DID=\"name\" if you want the machine/flags identified in the output.   FAULTY COMPILERS   Because of bugs and/or inadequacies, some compilers need the following   defines:   If your C preprocessor doesn't have the predefined __FILE__ macro, and   you don't want to call this file enquire.c but, say, tell.c, add the   flag -DFILENAME=\"tell.c\" .   Some compilers won't accept the line "#include FILENAME".   Add flag -DNO_FILE. In that case, this file *must* be called enquire.c.   Some compilers can't cope with "#ifdef __FILE__". Use -DFILENAME=   or -DNO_FILE as above.   Some naughty compilers define __STDC__, but don't really support it.   Some define it as 0, in which case we treat it as undefined.   But if your compiler defines it, and isn't really ANSI C,   add flag -DNO_STDC. (To those compiler writers: for shame).   Some naughty compilers define __STDC__, but don't have the stddef.h   include file. Add flag -DNO_STDDEF.   Summary of naughty-compiler flags:   If your compiler doesn't support:		 add flag:	__FILE__ (and you changed the filename)	-DFILENAME=\"name.c\"	#ifdef __FILE__				-DNO_FILE or -DFILENAME=...	#include FILENAME			-DNO_FILE	__STDC__ (properly)			-DNO_STDC	stddef.h				-DNO_STDDEF   Some systems crash when you try to malloc all store. To save users of   such defective systems too much grief, they may compile with -DNO_MEM,   which ignores that bit of the code.   While it is not our policy to support defective compilers, pity has been   taken on people with compilers that can't produce object files bigger than   32k (especially since it was an easy addition). Compile the program   into separate parts like this:       cc -DSEP -DPASS0 -o p0.o <other flags> enquire.c       cc -DSEP -DPASS1 -o p1.o <other flags> enquire.c       cc -DSEP -DPASS2 -o p2.o <other flags> enquire.c       cc -DSEP -DPASS3 -o p3.o <other flags> enquire.c       cc -o enquire p0.o p1.o p2.o p3.o   SYSTEM DEPENDENCIES   You may possibly need to add some calls to signal() for other sorts of   exception on your machine than SIGFPE, and SIGOVER. See lines beginning   #ifdef SIGxxx in main() (and communicate the differences to me!).   OUTPUT   Run without argument to get the information as English text. If run   with argument -l (e.g. enquire -l), output is a series of #define's for   the ANSI standard limits.h include file, excluding MB_MAX_CHAR. If run   with argument -f, output is a series of #define's for the ANSI standard   float.h include file (according to ANSI C Draft of Dec 7, 1988).   Flag -v gives verbose output: output includes the English text above   as C comments. The program exit(0)'s if everything went ok, otherwise   it exits with a positive number, telling how many problems there were.   VERIFYING THE COMPILER   If, having produced the float.h and limits.h header files, you want to   verify that the compiler reads them back correctly (there are a lot of   boundary cases, of course, like minimum and maximum numbers), you can   recompile enquire.c with -DVERIFY set (plus the other flags that you used   when compiling the version that produced the header files). This then   recompiles the program so that it #includes "limits.h" and "float.h",   and checks that the constants it finds there are the same as the   constants it produces. Run the resulting program with enquire -fl.   Very few compilers have passed without error.   NB: You *must* recompile with the same compiler and flags, otherwise   you may get odd results.   You can also use this option if your compiler already has both files,   and you want to confirm that this program produces the right results.   TROUBLESHOOTING.   This program is now quite trustworthy, and suspicious and wrong output   may well be caused by bugs in the compiler, not in the program (however   of course, this is not guaranteed, and no responsibility can be   accepted, etc.)   The program only works if overflows are ignored by the C system or   are catchable with signal().   If the program fails to run to completion (often with the error message   "Unexpected signal at point x"), this often turns out to be a bug in the   C compiler's run-time system. Check what was about to be printed, and   try to narrow the problem down.   Another possible problem is that you have compiled the program to produce   loss-of-precision arithmetic traps. The program cannot cope with these,   and you should re-compile without them. (They should never be the default).   Make sure you compiled with optimisation turned off.   Output preceded by *** WARNING: identifies behaviour of the C system   deemed incorrect by the program. Likely problems are that printf or   scanf don't cope properly with certain boundary numbers: this program   goes to a lot of trouble to calculate its values, and these values   are mostly boundary numbers. Experience has shown that often printf   cannot cope with these values, and so in an attempt to increase   confidence in the output, for each float and double that is printed,   the printed value is checked by using sscanf to read it back.       Care is taken that numbers are printed with enough digits to uniquely   identify them, and therefore that they can be read back identically.   If the number read back is different, then there is probably a bug in   printf or sscanf, and the program prints the warning message.   If the two numbers in the warning look identical, then printf is more   than likely rounding the last digit(s) incorrectly. To put you at ease   that the two really are different, the bit patterns of the two numbers   are also printed. The difference is very likely in the last bit.       Many scanf's read the minimum double back as 0.0, and similarly cause   overflow when reading the maximum double. This program quite ruthlessly   declares all these behaviours faulty. The point is that if you get   one of these warnings, the output may be wrong, so you should check   the result carefully if you intend to use the results. Of course, printf   and sscanf may both be wrong, and cancel each other out, so you should   check the output carefully anyway.   The warning that "a cast didn't work" refers to cases like this:      float f;      #define C 1.234567890123456789      f= C;      if (f != (float) C) printf ("Wrong!");   A faulty compiler will widen f to double and ignore the cast to float,   and because there is more accuracy in a double than a float, fail to   recognise that they are the same. In the actual case in point, f and C   are passed as parameters to a function that discovers they are not equal,   so it's just possible that the error was in the parameter passing,   not in the cast (see function Validate()).   For ANSI C, which has float constants, the error message is "constant has   wrong precision".   REPORTING PROBLEMS   If the program doesn't work for you for any reason that can't be   narrowed down to a problem in the C compiler, or it has to be changed in   order to get it to compile, or it produces suspicious output (like a very   low maximum float, for instance), please mail the problem and an example   of the incorrect output to steven@cwi.nl or ..!hp4nl!cwi.nl!steven, so that   improvements can be worked into future versions; cwi.nl is the European   backbone, and is connected to uunet and other fine hosts.   The program tries to catch and diagnose bugs in the compiler/run-time   system. I would be especially pleased to have reports of failures so   that I can improve this service.   I apologise unreservedly for the contorted use of the preprocessor...   THE SMALL PRINT   You may copy and distribute verbatim copies of this source file.   You may modify this source file, and copy and distribute such   modified versions, provided that you leave the copyright notice   at the top of the file and also cause the modified file to carry   prominent notices stating that you changed the files and the date   of any change; and cause the whole of any work that you distribute   or publish, that in whole or in part contains or is a derivative of   this program or any part thereof, to be licensed at no charge to   all third parties on terms identical to those here.   If you do have a fix to any problem, please send it to me, so that   other people can have the benefits.   While every effort has been taken to make this program as reliable as   possible, no responsibility can be taken for the correctness of the   output, nor suitability for any particular use.   This program is an offshoot of a project funded by public funds.   If you use this program for research or commercial use (i.e. more   than just for the fun of knowing about your compiler) mailing a short   note of acknowledgement may help keep enquire.c supported.   ACKNOWLEDGEMENTS   Many people have given time and ideas to making this program what it is.   To all of them thanks, and apologies for not mentioning them by name.   HISTORY   Originally started as a program to generate configuration constants   for a large piece of software we were writing, which later took on   a life of its own...   1.0 Length 6658!; end 1984?       Unix only. Only printed a dozen maximum int/double values.   2.0 Length 10535; Spring 1985       Prints values as #defines (about 20 of them)       More extensive floating point, using Cody and Waite       Handles signals better       Programs around optimisations       Handles Cybers   3.0 Length 12648; Aug 1987; prints about 42 values       Added PASS stuff, so treats float as well as double   4.0 Length 33891; Feb 1989; prints around 85 values       First GNU version (for gcc, where they call it hard-params.c)       Generates float.h and limits.h files       Handles long double       Generates warnings for dubious output   4.1 Length 47738; April 1989       Added VERIFY and TEST   4.2 Length 63442; Feb 1990       Added SEP       Fixed eps/epsneg       Added check for pseudo-unsigned chars       Added description for each #define output       Added check for absence of defines during verify       Added prototypes       Added NO_STDC and NO_FILE       Fixed alignments output   4.3 Length 75000; Oct 1990; around 114 lines of output       Function xmalloc defined, Richard Stallman, June 89.       Alignments computed from member offsets rather than structure sizes,          Richard Stallman, Oct 89.       Print whether char* and int* pointers have the same format;          also char * and function *.       Update to Draft C version Dec 7, 1988	  - types of constants produced in limits.h	    (whether to put a U after unsigned shorts and chars and	     whether to output -1024 as (-1023-1))	  - values of SCHAR_MIN/MAX	  - values of *_EPSILON (not the smallest but the effective smallest)       Added FILENAME, since standard C doesn't allow #define __FILE__       Renamed from config.c to enquire.c       Added size_t and ptrdiff_t enquiries       Added promotion enquiries       Added type checks of #defines       Added NO_STDDEF       Changed endian to allow for cases where not all bits are used       Sanity check for max integrals       Fixed definition of setjmp for -DNO_SIG       Moved #define ... 0.0L inside #ifdef STDC, in case some cpp's tokenize       Added NO_MEM*//* Set FILENAME to the name of this file */#ifndef FILENAME#ifdef NO_FILE#define FILENAME "enquire.c"#else#ifdef __FILE__ /* It's a compiler bug if this fails. Compile with -DNO_FILE */#define FILENAME __FILE__#else#define FILENAME "enquire.c"#endif /* __FILE__ */#endif /* NO_FILE */#endif /* FILENAME *//* If PASS isn't defined, then this is the first pass over this file. */#ifndef PASS#ifndef SEP#define PASS 1#define PASS0 1#define PASS1 1#endif /* SEP *//* A description of the ANSI constants */#define D_CHAR_BIT "Number of bits in a storage unit"#define D_CHAR_MAX "Maximum char"#define D_CHAR_MIN "Minimum char"#define D_SCHAR_MAX "Maximum signed char"#define D_SCHAR_MIN "Minimum signed char"#define D_UCHAR_MAX "Maximum unsigned char (minimum is always 0)"#define D_INT_MAX "Maximum %s"#define D_INT_MIN "Minimum %s"#define D_UINT_MAX "Maximum unsigned %s (minimum is always 0)"#define D_FLT_ROUNDS "Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown"#define D_FLT_RADIX "Radix of exponent representation"#define D_MANT_DIG "Number of base-FLT_RADIX digits in the significand of a %s"#define D_DIG "Number of decimal digits of precision in a %s"#define D_MIN_EXP "Minimum int x such that FLT_RADIX**(x-1) is a normalised %s"#define D_MIN_10_EXP "Minimum int x such that 10**x is a normalised %s"#define D_MAX_EXP "Maximum int x such that FLT_RADIX**(x-1) is a representable %s"#define D_MAX_10_EXP "Maximum int x such that 10**x is a representable %s"#define D_MAX "Maximum %s"#define D_EPSILON "Difference between 1.0 and the minimum %s greater than 1.0"#define D_MIN "Minimum normalised %s"/* Procedure just marks the functions that don't return a result */#ifdef NO_VOID#define Procedure int#else#define Procedure void#endif/* Some bad compilers define __STDC__, when they don't support it.   Compile with -DNO_STDC to get round this.*/#ifndef NO_STDC#ifdef __STDC__#if __STDC__ /* If __STDC__ is 0, assume it isn't supported */#define STDC#endif#endif#endif/* Stuff different for ANSI C, and old C:   ARGS and NOARGS are used for function prototypes.   Volatile is used to reduce the chance of optimisation,      and to prevent variables being put in registers (when setjmp/longjmp      wouldn't work as we want)   Long_double is the longest floating point type available.   stdc is used in tests like "if (stdc)", which is less ugly than #ifdef.   U is output after unsigned constants. */#ifdef STDC#define ARGS(x) x#define NOARGS (void)#define Volatile volatile#define Long_double long double#define stdc 1#define U "U"#else /* Old style C */#define ARGS(x) ()#define NOARGS ()#define Volatile static#define Long_double double#define stdc 0#define U ""#endif /* STDC *//* include files */#include <stdio.h>#ifdef STDC#ifndef NO_STDDEF#include <stddef.h> /* for size_t: if this fails, define NO_STDDEF */#endif#endif#ifdef NO_SIG#define jmp_buf int#else#include <sys/types.h>#include <signal.h>#include <setjmp.h>#endif/* Kludge around the possibility that <stdio.h> includes <limits.h> */#ifdef CHAR_BIT#undef CHAR_BIT#undef CHAR_MAX#undef CHAR_MIN#undef SCHAR_MAX#undef SCHAR_MIN#undef UCHAR_MAX#undef UCHAR_MIN#endif#ifdef VERIFY#include "limits.h"#include "float.h"#endif#define Vprintf if (V) printf#define Unexpected(place) if (setjmp(lab)!=0) croak(place)#define fabs(x) (((x)<0.0)?(-x):(x))#endif /* PASS */#ifdef PASS0/* Prototypes for what's to come: */int false NOARGS;#ifdef NO_STDDEFchar *malloc (); /* Old style prototype */#elsechar *malloc ARGS((size_t size));#endifProcedure exit ARGS((int status));char *f_rep ARGS((int precision, Long_double val));char *fake_f_rep ARGS((char *type, Long_double val));int maximum_int NOARGS;int cprop NOARGS;int basic NOARGS;Procedure sprop NOARGS;Procedure iprop NOARGS;Procedure lprop NOARGS;Procedure usprop NOARGS;Procedure uiprop NOARGS;Procedure ulprop NOARGS;int fprop ARGS((int bits_per_byte));int dprop ARGS((int bits_per_byte));int ldprop ARGS((int bits_per_byte));Procedure efprop ARGS((int fprec, int dprec, int lprec));Procedure edprop ARGS((int fprec, int dprec, int lprec));Procedure eldprop ARGS((int fprec, int dprec, int lprec));int setmode ARGS((char *s));Procedure farewell ARGS((int bugs));Procedure describe ARGS((char *description, char *extra));Procedure missing ARGS((char *s));Procedure fmissing ARGS((char *s));Procedure check_defines NOARGS;Procedure bitpattern ARGS((char *p, unsigned int size));int ceil_log ARGS((int base, Long_double x));Procedure croak ARGS((int place));Procedure eek_a_bug ARGS((char *problem));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));Procedure i_define ARGS((char *desc, char *extra, char *sort, char *name,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -