/** @file
Every thing you wanted to know about your compiler but didn't know whom to ask.
COPYRIGHT(c) 1993-9 Steven Pemberton, CWI. All rights reserved.
Steven Pemberton, CWI, Amsterdam; "Steven.Pemberton@cwi.nl"
Used with permission.
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#if defined(_MSC_VER) /* Handle Microsoft VC++ compiler specifics. */
#endif /* defined(_MSC_VER) */
//#define NO_SC 1 // Compiler doesn't support signed char
//#define NO_UC 1 // Compiler doesn't support unsigned char
//#define NO_UI 1 // Compiler doesn't support unsigned short and long
//#define NO_VOID 1 // Compiler doesn't support void
/* Some compilers can't cope with "#ifdef __FILE__". Use
either the FILENAME or BAD_CPP macro as described below.
*/
/* If your C preprocessor doesn't have the predefined __FILE__
macro, and you don't want to call this file enquire.c but, say,
*/
//#define FILENAME "enquire.c"
/* Some compilers won't accept the line "#include FILENAME". Uncomment
the following macro. In that case, this file *must* be called enquire.c.
*/
//#define BAD_CPP 1
/* Some naughty compilers define __STDC__, but don't really
support it. Some define it as 0, in which case we ignore it.
But if your compiler defines it, and isn't really ANSI C,
uncomment the BAD_STDC macro. (To those compiler writers: for shame).
*/
//#define BAD_STDC 1
/* Some naughty compilers define __STDC__, but don't have the
stddef.h include file. Uncomment the BAD_STDDEF macro. (Gcc needs this on
some machines, due to clashes between stddef.h and other include files.)
*/
//#define BAD_STDDEF 1
/* Some systems crash when you try to malloc all store. To save users of such
defective systems too much grief, they may uncomment the BAD_MALLOC macro,
which ignores that bit of the code.
*/
//#define BAD_MALLOC 1
#ifndef PROGRAM
#endif
#ifdef NOTDEFINED /* This is how you compile it; see below for details */
case $0 in
*.c) ;;
then :
else
echo '*** Giving up'
exit 1
else
echo " Signed char not accepted; using $CFLAGS"
else
CFLAGS="$CFLAGS -DNO_UC"
echo " Unsigned char not accepted; using $CFLAGS"
else
CFLAGS="$CFLAGS -DNO_UI"
echo " Unsigned short or long not accepted; using $CFLAGS"
else
CFLAGS="$CFLAGS -DNO_VOID"
echo " Void not accepted; using $CFLAGS"
case $# in
"1 2") ;;
;;
echo " enquire > enquire.out"
echo " verify -fl > verify.out"
echo ' *** Some problems: see verify.out'
exit 0
#endif
/*
PURPOSE
This is a program that determines many properties of the C
compiler and machine that it is run on, such as minimum and
double, and so on.
As a further option, it even checks that the compiler reads the
header files correctly.
It is a good test-case for compilers, since it exercises them with
many limiting values, such as the minimum and maximum floating-point
numbers.
COMPILING AND RUNNING ON UNIX MACHINES
With luck and a following wind, on Unix systems just the following
will work:
sh enquire.c (or whatever filename you chose).
Any parameters are passed to the C compiler, so if the compilation
fails for any reason curable as explained below, you can do the following:
sh enquire.c -DBAD_CPP
If you do get compilation errors, check the line in question.
Very often there is a comment attached saying which define to set.
You can use a different C compiler than the default cc by setting CC:
CC=gcc sh enquire.c -ansi
You can load extra libraries by setting LIBS:
CC=gcc LIBS=-lflong sh enquire.c -ansi
Add ID="string" for the string to be added to the output; for instance:
ID="`hostname` cc -ansi" sh enquire.c -ansi
Compiling may give messages about unreachable code. These you can ignore.
Some compilers offer various flags for different floating point
modes; it's worth trying all possible combinations of these.
Don't say I haven't tried to make life easy for you...
COMPILING AND RUNNING ON NON-UNIX SYSTEMS
On non-Unix systems, you must say (the equivalent of):
cc enquire.c -o enquire
enquire > enquire.out
enquire -l > limits.h
enquire -f > float.h
verify -fl > verify.out
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
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.
Compiling may give messages about unreachable code. These you can ignore.
Some compilers offer various flags for different floating point
modes; it's worth trying all possible combinations of these.
FAULTY COMPILERS
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,
- Some compilers won't accept the line "#include FILENAME". Add
flag -DBAD_CPP. In that case, this file *must* be called
- Some compilers can't cope with "#ifdef __FILE__". Use
-DFILENAME= or -DBAD_CPP as above.
- Some naughty compilers define __STDC__, but don't really
support it. Some define it as 0, in which case we ignore it.
But if your compiler defines it, and isn't really ANSI C, add
flag -DBAD_STDC. (To those compiler writers: for shame).
- Some naughty compilers define __STDC__, but don't have the
stddef.h include file. Add flag -DBAD_STDDEF. (Gcc needs this
on some machines, due to clashes between stddef.h and other
include files.)
- Some systems crash when you try to malloc all store. To save
users of such defective systems too much grief, they may
compile with -DBAD_MALLOC, which ignores that bit of the code.
Summary of naughty-compiler flags:
If your compiler doesn't support: add flag:
__FILE__ (and you changed the filename) -DFILENAME=\"name.c\"
#ifdef __FILE__ -DBAD_CPP or -DFILENAME=...
#include FILENAME -DBAD_CPP
__STDC__ (properly) -DBAD_STDC
stddef.h -DBAD_STDDEF
malloc(LOTS) == NULL -DBAD_MALLOC
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 -c -DSEP -DPASS0 -o p0.o <other flags> enquire.c
cc -c -DSEP -DPASS1 -o p1.o <other flags> enquire.c
cc -c -DSEP -DPASS2 -o p2.o <other flags> enquire.c
cc -c -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, SIGOVER, SIGBUS, and SIGSEGV.
See lines beginning #ifdef SIGxxx (and communicate the differences to me!).
OUTPUT
Running without argument gives 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
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
and checks that the constants it finds there are the same as the
constants it produces. Run the resulting program with enquire -fl.
Many compilers fail this test.
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 Verify()).
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.Pemberton@cwi.nl so that improvements can be worked into
future versions. Try to give as much information as possible;
DON'T FORGET TO MENTION THE VERSION NUMBER!
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...
but it was fun!
NEW VERSIONS
Worried that you may not have the latest version? Ftp to
for file enquireXX.c; XX is the version number. Or look at
HOW DOES ENQUIRE WORK?
There is an article that explains a lot of the workings: The
Ergonomics of Portability; available from the above addresses as file
enquire.ps.
THE SMALL PRINT
This is not a public domain program; nor is any other program that
carries a copyright notice. It is however freely copyable under the
following conditions:
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.
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.
If you do have a fix to any problem, please send it to me, so that
other people can have the benefits.
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?
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 called it hard-params.c)
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
Added check for pseudo-unsigned chars
Added description for each #define output
Added check for absence of defines during verify
Added prototypes
Added BAD_STDC and BAD_CPP
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 *_EPSILON (not the smallest but the effective smallest)
Added FILENAME, since ANSI C doesn't allow #define __FILE__
Added size_t and ptrdiff_t enquiries
Added promotion enquiries
Added type checks of #defines
Added BAD_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 BAD_MALLOC
5.0 Length 88228; February 1993; around 120 lines of output
(depends on what you count)
Added checks for long names: thanks Steve Simon@leeds-poly
Added FPE signal checks: thanks Leonid A. Broukhis
Added check for dereferencing NULL
Added TESTI
Added LIBS, fixed showtype: thanks Rainer Orth@TechFak.Uni-Bielefeld.DE
Added a free(): thanks nickc@perihelion.co.uk
Added signal catching to the malloc part
Renamed naughty-compiler defines to BAD_*
Renamed and altered Verify() to better check faulty compilers
Shut some compilers up from giving incorrect warnings.
Fixed sign_of(): thanks Hugh Redelmeier@redvax
Fixed USHRT_MAX for sizeof(short)=sizeof(int) but INT_MAX > SHRT_MAX
Fixed NO_UI
Fixed -DSEP: thanks Mike Black@seismo
Fixed exponent(): thanks Christophe BINOT
<chb%hpvpta.france.hp.com@hplb.hpl.hp.com>
5.0a Aug 1997
Made handling of ID= easier
Improved the reporting of use of bits in Floating values.
5.1 Length 88739; Sep 1998
Fixed detection of infinity for machines with no overflow trap
Speeded up search for max char (first 32 bit char machine turned up...)
5.1a Length 88832; Feb 1999
Changed identification message
5.1b Length 88926; Oct 2002
Fixed a missing \n in an output line; thanks Leonid Broukhis again
*/
/* Set FILENAME to the name of this file */
#ifndef FILENAME
#ifdef BAD_CPP
#else
#ifdef __FILE__ /* It's a compiler bug if this fails. Define BAD_CPP */
#else
#endif /* __FILE__ */
#endif /* BAD_CPP */
#endif /* FILENAME */
/* This file is read three times (it #includes itself), to generate
otherwise identical code for each of short+float, int+double,
long+long double. If PASS isn't defined, then this is the first pass.
Code bracketed by 'PASS0' is for stuff independent of all three,
but is read during the first pass.
*/
#ifndef PASS
#ifdef SEP /* so we're only interested if this is pass 1 or not */
#ifdef PASS1
#else
#define PASS 0
#endif
#else /* no SEP, so this is the first pass */
#define PASS 1
#define PASS0 1
#define PASS1 1
#endif /* SEP */
/* Void just marks the functions that don't return a result */
#ifdef NO_VOID
#define Void int
#else
#define Void void
#endif
/* Set STDC to whether this is *really* an ANSI C compiler.
Some bad compilers define __STDC__, when they don't support it.
Compile with -DBAD_STDC to get round this.
*/
#ifndef BAD_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,
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 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>
#include <wchar.h>
#ifdef STDC
#ifndef BAD_STDDEF
#include <stddef.h> /* for size_t: if this fails, define BAD_STDDEF */
#endif
#endif
#ifdef NO_SIG
#define jmp_buf int
#else
#include <signal.h> /* if this fails, define NO_SIG */
#include <setjmp.h> /* if this fails, define NO_SIG */
#endif
//#ifndef NO_SIG
//#include <signal.h> /* if this fails, define NO_SIG */
//#include <setjmp.h> /* if this fails, define NO_SIG */
//#endif
#ifdef CHAR_BIT
#endif
#ifdef VERIFY
#include "limits.h"
#include "float.h"
#endif
/* The largest unsigned type */
#ifdef NO_UI
#define ulong unsigned int
#else
#define ulong unsigned long
#endif
/* Some shorthands */
#endif /* PASS */
/* A description of the ANSI constants */
#ifdef PASS0
/* Prototypes for what's to come: */
int false NOARGS;
#ifdef BAD_STDDEF
char *malloc (); /* Old style prototype, since we don't know what size_t is */
#else
#endif
/* Dummy routines instead */
typedef int jmp_buf;
#else
}
{ /* what to do on an address error */
}
#endif /*NO_SIG*/
int V= 0, /* verbose */
L= 0, /* produce limits.h */
F= 0, /* produce float.h */
#ifdef TEST
/* Set the fp modes on a SUN with 68881 chip, to check that different
rounding modes etc. get properly detected.
Compile with -f68881 for cc, -m68881 for gcc, and with additional flag
-DTEST. Run with additional parameter +hex-number, to set the 68881 mode
register to hex-number
*/
/* Bits 0x30 = rounding mode */
/* Bits 0xc0 = extended rounding */
/* Enabled traps */
/* Only used for testing, on a Sun with 68881 chip */
/* Print the FP mode */
printf("New fp mode:\n");
printf(" Round toward ");
switch (new & ROUND_BITS) {
default: printf("???"); break;
}
printf("\n Extended rounding precision: ");
default: printf("???"); break;
}
printf("\n Enabled exceptions:");
printf("\n");
}
/* Only used for testing, on a Sun with 68881 chip */
/* Set the FP mode */
int setmode(s) char *s; {
char c;
while (*s) {
c= *s++;
else return 1;
}
return 0;
}
#define SETMODE
#endif
#ifdef TESTI /* Test mode using SunOs IEEE routines */
int setmode(char *s) {
while (*s) {
switch (c= *s++) {
default:
printf("Bad setmode character: %c\n", c);
return 1;
break;
}
printf(": failed\n");
return 1;
}
printf("\n");
}
return 0;
}
#define SETMODE
#endif
#ifndef SETMODE
/* ARGSUSED */
int
setmode(char *s)
{
return(1);
}
#endif
int
char *p1,
int size1,
char *p2,
int size2
)
{
/* See if two blocks of store are identical */
int i;
for (i=1; i<=size1; i++) {
}
return 1;
}
{
printf(" above\n see the section 'TROUBLESHOOTING' in the file ");
}
/* The program has received a signal where it wasn't expecting one */
{
}
/* This is here in case alloca.c is used, which calls this. */
char *
{
if (value == 0) {
}
return value;
}
int maxint;
int
maximum_int( void )
{
/* Find the maximum integer */
/* Calculate maxint ***********************************/
/* Calculate 2**n-1 until overflow - then use the previous value */
}
}
Unexpected(0);
return int_max;
}
/* How long are my identifiers? I could go further here, but some compilers
have line length limits that I don't want to break.
*/
int
name_len( void )
{
return
}
}
}
}
}
#endif
#ifdef aaaaaaaaa1aaaaaa
#endif
#ifdef aaaaaaaa
#endif
{
int l= name_len();
Vprintf("Compiler names are at least %d chars long", l);
if (l != 64)
Vprintf("\n");
if (LENGTH != 64)
Vprintf("\n\n");
}
/* Used by FPROP to see if FP traps are generated, and if they may return */
{
}
{
}
setsignals( void )
{
#ifdef SIGFPE
#endif
#ifdef SIGOVER
#endif
#ifdef SIGBUS
#endif
#ifdef SIGSEGV
#endif
/* Add more calls as necessary */
}
int
{
int i;
wchar_t *s;
int bad;
setsignals();
Unexpected(1);
bad=0;
for (i=1; i < argc; i++) {
if (*s == L'-') {
s++;
while (*s) {
switch (*(s++)) {
case L'v': V=1; break;
case L'l': L=1; break;
case L'f': F=1; break;
default: bad=1; break;
}
}
} else if (*s == L'+') {
s++;
} else bad= 1;
}
if (bad) {
exit(1);
}
if (L || F) {
} else {
V=1;
}
#ifdef ID
printf("%sProduced by enquire version %s (%s), CWI, Amsterdam\n %s\n",
#else
printf("%sProduced by enquire version %s, CWI, Amsterdam\n %s %s\n",
#endif
#ifdef VERIFY
#endif
#ifdef NO_SIG
Vprintf("%sCompiled without signal(): %s%s\n",
co,
"there's nothing that can be done if overflow occurs",
oc);
#endif
#ifdef NO_SC
#endif
#ifdef NO_UC
#endif
#ifdef NO_UI
#endif
#ifdef __STDC__
Vprintf("%sCompiler claims to be ANSI C level %d%s\n",
#else
#endif
printf("\n");
long_names();
maxint= maximum_int();
bits_per_byte= basic();
Vprintf("\n");
if (F||V) {
}
#ifndef BAD_MALLOC
if (V) {
/* An extra goody: the approximate amount of data-space */
/* Allocate store until no more available */
/* Different implementations have a different argument type
to malloc. Here we assume that it's the same type as
that which sizeof() returns */
unsigned int size;
char **link;
total=0;
while (size!=0) {
//if (save == NULL) save= ptr; /* save the biggest chunk */
// Save pointer to first allocated chunk
}
else {
// Build list of all subsequently allocated chunks, LIFO
}
}
} else {
eek_a_bug("Trying to malloc all store generates a trap");
}
size/=2;
}
//if (save != NULL) free(save);
}
if (total > 10000) {
}
if (total > 10000) {
}
if (total > 10000) {
}
Vprintf("%sMemory mallocatable ~= %ld %cbytes%s\n",
}
#endif
return bugs; /* To keep compilers and lint happy */
}
{
/* The program has discovered a problem */
bugs++;
}
{
/* Produce the description for a #define */
}
char *desc,
char *extra,
char *sort,
char *name,
long val,
long lim,
long req,
char *mark
)
{
/* Produce a #define for a signed int type */
if (val >= 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. */
printf("#define %s%s (%ld%s%ld%s)\n",
} else {
}
/* 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
*/
bugs++;
}
Vprintf("\n");
}
char *desc,
char *extra,
char *sort,
char *name,
char *mark
)
{
/* Produce a #define for an unsigned value */
bugs++;
}
Vprintf("\n");
}
char *desc,
char *extra,
char *sort,
char *name,
int precision,
char *mark
)
{
if (stdc) {
printf("#define %s%s %s%s\n",
} else if (*mark == 'F') {
/* non-ANSI C has no float constants, so cast the constant */
printf("#define %s%s ((float)%s)\n",
} else {
}
Vprintf("\n");
}
int
{
/* return floor(log base(x)) */
int r=0;
return r;
}
int
{
int r=0;
while (x>1.0) { r++; x/=base; }
return r;
}
int
{
/* Split x into a fraction and a power of ten;
returns 0 if x is unusable, 1 otherwise.
Only used for error messages about faulty output.
*/
int r=0, neg=0;
if (x<0.0) {
x= -x;
neg= 1;
}
if (x==0.0) return 1;
if (x>=10.0) {
while (x>=10.0) {
old=x; r++; x/=10.0;
if (old==x) return 0;
}
} else {
while (x<1.0) {
old=x; r--; x*=10.0;
if (old==x) return 0;
}
}
else *fract= x;
*exp=r;
return 1;
}
char *
{
/* Return the floating representation of val */
char *f1;
if (sizeof(double) == sizeof(Long_double)) {
/* Assume they're the same, and use non-stdc format */
/* This is for stdc compilers using non-stdc libraries */
f1= "%.*e";
} else {
/* It had better support Le then */
f1= "%.*Le";
}
return buf;
}
{
/* Printf the bit-pattern of p */
char c;
unsigned int i;
int j;
for (i=1; i<=size; i++) {
c= *p;
p++;
for (j=bits_per_byte-1; j>=0; j--)
}
}
{
int i;
for (i=0; i<size; i++)
p[i]= ab[i];
}
putchar(c==0 ? '?' : (char)c); }\
{
/* Printf the byte-order used on this machine */
/*unsigned*/ short s=0;
/*unsigned*/ int j=0;
/*unsigned*/ long l=0;
unsigned int mask, i, c;
mask=0;
if (V) {
Order(s, "short:");
Order(j, "int: ");
Order(l, "long: ");
}
}
missing(char *s)
{
bugs++;
}
fmissing(char *s)
{
bugs++;
}
/* To try and fool optimisers */
int false( void ) { return 0; }
#define Unsigned 0
char *type_of(int x)
{
if (x == sizeof(char)) {
return "char";
}
if (x == sizeof(short)) {
return "short";
}
if (x == sizeof(int)) {
return "int";
}
if (x == sizeof(long)) return "long";
return "unknown-type";
}
char *ftype_of(int x)
{
if (x == sizeof(float)) {
return "float";
}
if (x == sizeof(double)) {
if (sizeof(double) == sizeof(Long_double))
return "(long)double";
return "double";
}
if (x == sizeof(Long_double)) {
return "long double";
}
return "unknown-type";
}
{
Vprintf("*** %s has wrong type: expected %s %s, found %s %s\n",
}
{
Vprintf("*** %s has wrong type: expected %s, found %s\n",
}
{
unsigned int ui;
short ss;
#ifndef NO_UI
#endif
/* Shut compiler warnings up: */
/* Sanity checks. Possible warnings here; should be no problem */
eek_a_bug("unsigned int promotes to signed!\n");
eek_a_bug("signed int promotes to unsigned!\n");
eek_a_bug("signed long promotes to unsigned!\n");
eek_a_bug("int doesn't promote to int!\n");
eek_a_bug("long doesn't promote to long!\n");
eek_a_bug("short doesn't promote to int!\n");
eek_a_bug("unsigned int doesn't promote to int!\n");
#ifndef NO_UI
eek_a_bug("unsigned long doesn't promote to long!\n");
eek_a_bug("unsigned long promotes to signed!\n");
#endif
#ifndef NO_UI
#endif
}
#define checktype(x, n, s, t) if((sgn(x)!=s)||(sizeof(x)!=sizeof(t))) typerr(n, s, (int)sizeof(t), sgn(x), (int)sizeof(x));
{
/* ensure that all #defines are present and have the correct type */
#ifdef VERIFY
int usign;
#ifdef NO_UI
#else
/* Implementations promote unsigned short differently */
#endif
if (L) {
#ifdef CHAR_BIT
#else
missing("CHAR_BIT");
#endif
#ifdef CHAR_MAX
#else
missing("CHAR_MAX");
#endif
#ifdef CHAR_MIN
#else
missing("CHAR_MIN");
#endif
#ifdef SCHAR_MAX
#else
missing("SCHAR_MAX");
#endif
#ifdef SCHAR_MIN
#else
missing("SCHAR_MIN");
#endif
#ifdef UCHAR_MAX
#else
missing("UCHAR_MAX");
#endif
#ifdef SHRT_MAX
#else
missing("SHRT_MAX");
#endif
#ifdef SHRT_MIN
#else
missing("SHRT_MIN");
#endif
#ifdef INT_MAX
#else
missing("INT_MAX");
#endif
#ifdef INT_MIN
#else
missing("INT_MIN");
#endif
#ifdef LONG_MAX
#else
missing("LONG_MAX");
#endif
#ifdef LONG_MIN
#else
missing("LONG_MIN");
#endif
#ifdef USHRT_MAX
#else
missing("USHRT_MAX");
#endif
#ifdef UINT_MAX
#else
missing("UINT_MAX");
#endif
#ifdef ULONG_MAX
#else
missing("ULONG_MAX");
#endif
} /* if (L) */
if (F) {
#ifdef FLT_RADIX
#else
fmissing("FLT_RADIX");
#endif
#ifdef FLT_MANT_DIG
#else
fmissing("FLT_MANT_DIG");
#endif
#ifdef FLT_DIG
#else
fmissing("FLT_DIG");
#endif
#ifdef FLT_ROUNDS
#else
fmissing("FLT_ROUNDS");
#endif
#ifdef FLT_EPSILON
#else
fmissing("FLT_EPSILON");
#endif
#ifdef FLT_MIN_EXP
#else
fmissing("FLT_MIN_EXP");
#endif
#ifdef FLT_MIN
#else
fmissing("FLT_MIN");
#endif
#ifdef FLT_MIN_10_EXP
#else
fmissing("FLT_MIN_10_EXP");
#endif
#ifdef FLT_MAX_EXP
#else
fmissing("FLT_MAX_EXP");
#endif
#ifdef FLT_MAX
#else
fmissing("FLT_MAX");
#endif
#ifdef FLT_MAX_10_EXP
#else
fmissing("FLT_MAX_10_EXP");
#endif
#ifdef DBL_MANT_DIG
#else
fmissing("DBL_MANT_DIG");
#endif
#ifdef DBL_DIG
#else
fmissing("DBL_DIG");
#endif
#ifdef DBL_EPSILON
#else
fmissing("DBL_EPSILON");
#endif
#ifdef DBL_MIN_EXP
#else
fmissing("DBL_MIN_EXP");
#endif
#ifdef DBL_MIN
#else
fmissing("DBL_MIN");
#endif
#ifdef DBL_MIN_10_EXP
#else
fmissing("DBL_MIN_10_EXP");
#endif
#ifdef DBL_MAX_EXP
#else
fmissing("DBL_MAX_EXP");
#endif
#ifdef DBL_MAX
#else
fmissing("DBL_MAX");
#endif
#ifdef DBL_MAX_10_EXP
#else
fmissing("DBL_MAX_10_EXP");
#endif
#ifdef STDC
#ifdef LDBL_MANT_DIG
#else
fmissing("LDBL_MANT_DIG");
#endif
#ifdef LDBL_DIG
#else
fmissing("LDBL_DIG");
#endif
#ifdef LDBL_EPSILON
#else
fmissing("LDBL_EPSILON");
#endif
#ifdef LDBL_MIN_EXP
#else
fmissing("LDBL_MIN_EXP");
#endif
#ifdef LDBL_MIN
#else
fmissing("LDBL_MIN");
#endif
#ifdef LDBL_MIN_10_EXP
#else
fmissing("LDBL_MIN_10_EXP");
#endif
#ifdef LDBL_MAX_EXP
#else
fmissing("LDBL_MAX_EXP");
#endif
#ifdef LDBL_MAX
#else
fmissing("LDBL_MAX");
#endif
#ifdef LDBL_MAX_10_EXP
#else
fmissing("LDBL_MAX_10_EXP");
#endif
#endif /* STDC */
} /* if (F) */
#endif /* VERIFY */
}
#ifdef VERIFY
#ifndef SCHAR_MAX
#endif
#ifndef SCHAR_MIN
#endif
#ifndef UCHAR_MAX
#endif
#endif /* VERIFY */
#ifndef CHAR_BIT
#endif
#ifndef CHAR_MAX
#endif
#ifndef CHAR_MIN
#endif
#ifndef SCHAR_MAX
#endif
#ifndef SCHAR_MIN
#endif
#ifndef UCHAR_MAX
#endif
int cprop( void )
{
/* Properties of type char */
long char_bit;
Unexpected(2);
/* Calculate number of bits per character *************************/
c=1; byte_size=0;
do { c=c<<1; byte_size++; } while(c!=0);
c= (char)(-1);
if (((int)c)<0) c_signed=1;
else c_signed=0;
Vprintf("%schar = %d bits, %ssigned%s\n",
c=0; char_max=0;
c++;
while (c>char_max) {
char_max=c;
c=(char)(c*2+1);
}
} else {
}
c=0; char_min=0;
c--;
if (c<char_min) /* then the min char < 0 */ {
/* Minimum value: assume either two's or one's complement *********/
}
}
Unexpected(8);
Vprintf("%s %s%s%s\n",
"They contain only nonnegative values, ",
}
Unexpected(3);
if (L) {
/* Because of the integer promotions, you must use a U after
the MAX_CHARS in the following cases */
if ((sizeof(char) == sizeof(int)) && !c_signed) {
} else {
(long) char_max, 0L,
(long) CHAR_MAX, "");
}
(long) CHAR_MIN, "");
if (c_signed) {
(long) char_max, 0L,
(long) SCHAR_MAX, "");
(long) SCHAR_MIN, "");
} else {
if (sizeof(char) == sizeof(int)) {
} else {
(long) char_max, 0L,
(long) UCHAR_MAX, "");
}
}
if (c_signed) {
#ifndef NO_UC
c1++;
c1++;
}
}
Unexpected(4);
if (sizeof(char) == sizeof(int)) {
} else {
(long) char_max, 0L,
(long) UCHAR_MAX, "");
}
#endif
} else {
#ifndef NO_SC
c1++;
c1++;
}
}
c1--;
c1--;
}
}
Unexpected(5);
(long) SCHAR_MIN, "");
(long) char_max, 0L,
(long) SCHAR_MAX, "");
#endif /* NO_SC */
}
}
return byte_size;
}
int basic( void )
{
/* The properties of the basic types.
Returns number of bits per sizeof unit */
typedef int function ();
int variable;
int *p, *q;
/* Shorts, ints and longs *****************************************/
Vprintf("%sshort=%d int=%d long=%d float=%d double=%d bits %s\n",
co,
(int) sizeof(short)*byte_size,
(int) sizeof(int)*byte_size,
(int) sizeof(long)*byte_size,
(int) sizeof(float)*byte_size,
if (stdc) {
Vprintf("%slong double=%d bits%s\n",
}
Vprintf("%schar*=%d bits%s%s\n",
sizeof(char *)>sizeof(int)?" BEWARE! larger than int!":"",
oc);
Vprintf("%sint* =%d bits%s%s\n",
sizeof(int *)>sizeof(int)?" BEWARE! larger than int!":"",
oc);
Vprintf("%sfunc*=%d bits%s%s\n",
oc);
showtype("Type size_t is", sizeof(0));
#ifdef STDC
#endif
/* Alignment constants ********************************************/
((long)((char *)&((struct{char c; TYPE d;}*)0)->d - (char *)0))
Vprintf("%schar=%ld short=%ld int=%ld long=%ld%s\n",
co,
oc);
Vprintf("%sfloat=%ld double=%ld%s\n",
co,
oc);
if (stdc) {
Vprintf("%slong double=%ld%s\n",
co,
oc);
}
Vprintf("%schar*=%ld int*=%ld func*=%ld%s\n",
co,
oc);
Vprintf("\n");
/* Ten little endians *********************************************/
/* Pointers *******************************************************/
} else {
}
} else {
}
if (V) {
}
p=0; q=0;
showtype("Type ptrdiff_t is", p-q);
//if (setjmp(mlab) == 0) {
// variable= *p;
// Vprintf("%sBEWARE! Dereferencing NULL doesn't cause a trap%s\n",
// co, oc);
//} else {
// Vprintf("%sDereferencing NULL causes a trap%s\n", co, oc);
//}
sprop();
iprop();
lprop();
usprop();
uiprop();
ulprop();
promotions();
Unexpected(6);
return byte_size;
}
#else /* not PASS0 */
#ifdef SEP
/* The global variables used by several passes */
extern int V, L, F, bugs, bits_per_byte;
extern char *f_rep();
#endif /* SEP */
#endif /* ifdef PASS0 */
/* As I said, I apologise for the contortions below. The functions are
expanded by the preprocessor twice or three times (for float and double,
and maybe for long double, and for short, int and long). That way,
I never make a change to one that I forget to make to the other.
You can look on it as C's fault for not supporting multi-line macros.
This whole file is read 3 times by the preprocessor, with PASSn set for
n=1, 2 or 3, to decide which parts to reprocess.
*/
/* #undef on an already undefined thing is (wrongly) flagged as an error
by some compilers, therefore the #ifdef that follows:
*/
#ifdef Number
/* These are the float.h constants */
#endif
#ifdef Integer
#endif
#ifdef PASS1
/* Define the things we're going to use this pass */
#define Number float
#ifdef VERIFY
#endif
#define Integer short
#ifndef NO_UI
#endif
#ifdef VERIFY
#ifdef SHRT_MAX
#endif
#ifdef SHRT_MIN
#endif
#ifdef USHRT_MAX
#endif
#ifdef FLT_RADIX
#endif
#ifdef FLT_MANT_DIG
#endif
#ifdef FLT_DIG
#endif
#ifdef FLT_ROUNDS
#endif
#ifdef FLT_EPSILON
#endif
#ifdef FLT_MIN_EXP
#endif
#ifdef FLT_MIN
#endif
#ifdef FLT_MIN_10_EXP
#endif
#ifdef FLT_MAX_EXP
#endif
#ifdef FLT_MAX
#endif
#ifdef FLT_MAX_10_EXP
#endif
#endif /* VERIFY */
#endif /* PASS1 */
#ifdef PASS2
#define Number double
#ifdef VERIFY
#endif
#define Integer int
#ifdef VERIFY
#ifdef INT_MAX
#endif
#ifdef INT_MIN
#endif
#ifdef UINT_MAX
#endif
#ifdef DBL_MANT_DIG
#endif
#ifdef DBL_DIG
#endif
#ifdef DBL_EPSILON
#endif
#ifdef DBL_MIN_EXP
#endif
#ifdef DBL_MIN
#endif
#ifdef DBL_MIN_10_EXP
#endif
#ifdef DBL_MAX_EXP
#endif
#ifdef DBL_MAX
#endif
#ifdef DBL_MAX_10_EXP
#endif
#endif /* VERIFY */
#endif /* PASS2 */
#ifdef PASS3
#ifdef STDC
#define Number long double
#endif
#ifdef VERIFY
#endif
#define Integer long
#ifndef NO_UI
#endif
#ifdef VERIFY
#ifdef LONG_MAX
#endif
#ifdef LONG_MIN
#endif
#ifdef ULONG_MAX
#endif
#ifdef LDBL_MANT_DIG
#endif
#ifdef LDBL_DIG
#endif
#ifdef LDBL_EPSILON
#endif
#ifdef LDBL_MIN_EXP
#endif
#ifdef LDBL_MIN
#endif
#ifdef LDBL_MIN_10_EXP
#endif
#ifdef LDBL_MAX_EXP
#endif
#ifdef LDBL_MAX
#endif
#ifdef LDBL_MAX_10_EXP
#endif
#endif /* VERIFY */
#endif /* PASS3 */
/* The rest of the file gets read all three times;
the differences are encoded in the things #defined above.
*/
#ifndef I_MAX
#endif
#ifndef I_MIN
#endif
#ifndef U_MAX
#endif
#ifndef F_RADIX
#endif
#ifndef F_MANT_DIG
#endif
#ifndef F_DIG
#endif
#ifndef F_ROUNDS
#endif
#ifndef F_EPSILON
#endif
#ifndef F_MIN_EXP
#endif
#ifndef F_MIN
#endif
#ifndef F_MIN_10_EXP
#endif
#ifndef F_MAX_EXP
#endif
#ifndef F_MAX
#endif
#ifndef F_MAX_10_EXP
#endif
#ifndef VERIFY
#endif
#ifdef Integer
{
/* the properties of short, int, and long */
/* Calculate 2**n-1 until overflow - then use the previous value */
}
Vprintf("%sOverflow of a%s %s does not generate a trap%s\n",
} else {
Vprintf("%sOverflow of a%s %s generates a trap%s\n",
}
Unexpected(7);
/* Minimum value: assume either two's or one's complement *********/
}
Unexpected(8);
/* Now for those daft Cybers */
}
}
Unexpected(9);
}
Unexpected(10);
Vprintf("%sMaximum %s = %ld (= 2**%d-1)%s\n",
(long) int_max, 0L,
if(int_max < 0) { /* It has happened (on a Cray) */
eek_a_bug("signed integral comparison faulty?");
}
Vprintf("%sThere is a larger %s, %ld (= 2**%d-1), %s %s%s\n",
"but only for addition, not multiplication",
"(I smell a Cyber!)",
oc);
}
Vprintf("%sThere is a smaller %s, %ld, %s %s%s\n",
"but only for addition, not multiplication",
"(I smell a Cyber!)",
oc);
}
}
{
#ifdef OK_UI
}
}
Unexpected(11);
Vprintf("%sMaximum unsigned %s = %lu%s\n",
/* Oh woe: new standard C defines value preserving promotions:
3.2.1.1: "If an int can represent all values of the original type,
the value is converted to an int;
otherwise it is converted to an unsigned int."
*/
if (L) {
)
{ /* the value is converted to an int */
(long) u_max, 0L,
} else { /* it is converted to an unsigned int */
(unsigned long) u_max,
}
}
#endif
}
#endif /* Integer */
#ifdef Number
/* The following routines are intended to defeat any attempt at optimisation
or use of extended precision, and to defeat faulty narrowing casts.
The weird prototypes are because of widening incompatibilities.
*/
#define ARGS1(A, a) (A a)
#define ARGS2(A, a, B, b) (A a, B b)
#define ARGS5(A, a, B, b, C, c, D, d, E, e) (A a, B b, C c, D d, E e)
#else
#define ARGS1(A, a) (a) A a;
#define ARGS2(A, a, B, b) (a, b) A a; B b;
#define ARGS5(A, a, B, b, C, c, D, d, E, e) (a,b,c,d,e)A a; B b; C c; D d; E e;
#endif
{
/* You don't think I'm going to go to all the trouble of writing
a program that works out what all sorts of values are, only to
have printf go and print the wrong values out, do you?
No, you're right, so this function tries to see if printf
has written the right value, by reading it back again.
This introduces a new problem of course: suppose printf writes
the correct value, and scanf reads it back wrong... oh well.
But I'm adamant about this: the precision given is enough
to uniquely identify the printed number, therefore I insist
that sscanf read the number back identically. Harsh yes, but
sometimes you've got to be cruel to be kind.
*/
int e;
if (sizeof(double) == sizeof(Long_double)) {
/* Assume they're the same, and use non-stdc format */
/* This is for stdc compilers using non-stdc libraries */
} else {
/* It had better support Le then */
f2= "%Le";
}
} else {
eek_a_bug("sscanf caused a trap");
Unexpected(12);
return;
}
if (new != 0.0) {
/* That should be enough to generate a trap */
}
} else {
eek_a_bug("sscanf returned an unusable number");
printf("%s scanning: %s with format: %s%s\n\n",
Unexpected(13);
return;
}
Unexpected(14);
eek_a_bug("Possibly bad output from printf above");
printf("%s but value was an unusable number%s\n\n",
return;
}
//if (sizeof(double) == sizeof(Long_double)) {
/* Assume they're the same, and use non-stdc format */
/* This is for stdc compilers using non-stdc libraries */
//printf("%.*fe%d, bit pattern:\n ", precision, rem, e);
//} else {
/* It had better support Lfe then */
//}
printf("%s sscanf gave %s, bit pattern:\n ",
printf("%s difference= %s%s\n\n",
} /* else forget it */
Unexpected(15);
}
}
#ifdef VERIFY
{
/* Check that the compiler has read a #define value correctly */
Unexpected(16);
if (!same) {
printf(" Compiler has %s for value\n",
} else {
printf(" Compiler has %s for value\n",
"an unusable number");
}
} /*else forget it*/
printf(" difference= %s\n",
}
} /*else forget it*/
Unexpected(17);
bugs++;
} else if (!same1) {
else eek_a_bug("the cast didn't work");
printf("\n");
}
}
#endif /* VERIFY */
{
/* Properties of floating types, using algorithms by Cody and Waite
from MA Malcolm, as modified by WM Gentleman and SB Marovich.
Further extended by S Pemberton.
Returns the number of digits in the fraction.
*/
Volatile int
Unexpected(18);
/* Base and size of significand **************************************/
/* First repeatedly double until adding 1 has no effect. */
/* For instance, if base is 10, with 3 significant digits */
/* it will try 1, 2, 4, 8, ... 512, 1024, and stop there, */
/* since 1024 is only representable as 1020. */
a=1.0;
do { a=Sum(a, a); }
} else {
/* And supporting those is just TOO much trouble! */
}
Unexpected(19);
/* Now double until you find a number that can be added to the */
/* above number. For 1020 this is 8 or 16, depending whether the */
/* result is rounded or truncated. */
/* In either case the result is 1030. 1030-1020= the base, 10. */
b=1.0;
/* Sanity check; if base<2, I can't guarantee the rest will work */
if (f_radix < 2) {
eek_a_bug("Function return or parameter passing faulty? (This is a guess.)");
printf("\n");
return(0);
}
printf("\n%s*** WARNING: %s %s (%d) %s%s\n",
bugs++;
}
/* Now the number of digits precision */
f_mant_dig=0; b=1.0;
Vprintf("%sSignificant base digits = %d %s %d %s%s\n",
/* Rounding *******************************************************/
else basem1=1.0;
} else irnd=0; /* towards 0 */
else basem1=1.0;
} else mrnd=0; /* towards 0 */
if (f_rounds != -1) {
switch (f_rounds) {
case 0: Vprintf("zero (i.e. it chops)"); break;
default: Vprintf("???"); break;
}
} else { /* Hmm, try to give some help here */
Vprintf("%s Negative numbers %s%s\n",
"away from zero",
oc);
Vprintf("%s Positive numbers %s%s\n",
"away from zero",
oc);
}
/* An extra goody */
} else {
}
}
if (F)
} else if (f_rounds != flt_rounds) {
printf("\n%s*** WARNING: %s %s (%d) %s%s\n\n",
bugs++;
}
/* Various flavours of epsilon ************************************/
a=1.0;
b=a;
a*=base;
negeps--;
}
Vprintf("%sSmallest x such that 1.0-base**x != 1.0 = %d%s\n",
/* find the smallest epsneg (1-epsneg != 1) by binary search.
ebot and etop are the current bounds */
}
/* Sanity check */
eek_a_bug("internal error calculating epsneg");
}
Vprintf("%sSmallest x such that 1.0-x != 1.0 = %s%s\n",
epsneg=a;
/* a=(a*(1.0+a))/(1.0+1.0); => */
/* if ((1.0-a)-1.0 != 0.0) epsneg=a; => */
}
/* epsneg is used later */
Unexpected(20);
a=b;
Vprintf("%sSmallest x such that 1.0+base**x != 1.0 = %d%s\n",
/* find the smallest eps (1+eps != 1) by binary search.
ebot and etop are the current bounds */
}
/* Sanity check */
eek_a_bug("internal error calculating eps");
}
Vprintf("%sSmallest x such that 1.0+x != 1.0 = %s%s\n",
Vprintf("%s(Above number + 1.0) - 1.0 = %s%s\n",
/* Possible loss of precision warnings here from non-stdc compilers */
Unexpected(21);
Unexpected(22);
/* Extra chop info *************************************************/
if (f_rounds == 0) {
}
}
/* Size of and minimum normalised exponent ************************/
/* Coarse search for the largest power of two */
do {
i++;
k+=k;
} while(1);
} else {
}
Unexpected(23);
if (f_radix != 10) {
mx=k+k;
} else {
iexp=2;
}
/* Fine tune starting with y and y1 */
do {
k++;
} while (1);
}
Unexpected(24);
f_min_exp=(-k)+1;
if (F)
Vprintf("%sMinimum normalised positive number = %s%s\n",
} else {
eek_a_bug("printf can't print the smallest normalised number");
printf("\n");
}
Unexpected(25);
/* Possible loss of precision warnings here from non-stdc compilers */
} else {
eek_a_bug("xxx_MIN caused a trap");
printf("\n");
}
} else {
printf("%s*** Verify failed for above #define!\n %s %s\n\n",
bugs++;
}
Unexpected(26);
a=1.0; f_min_10_exp=0;
(long) f_min_10_exp, (long) maxint,
(long) F_MIN_10_EXP, "");
/* Minimum exponent ************************************************/
do {
xminner=y;
} while (1);
}
Unexpected(27);
normal= 0;
Vprintf("%sThe smallest numbers are not kept normalised%s\n",
Vprintf("%sSmallest unnormalised positive number = %s%s\n",
} else {
eek_a_bug("printf can't print the smallest unnormalised number.");
printf("\n");
}
Unexpected(28);
} else {
normal= 1;
}
/* Maximum exponent ************************************************/
} else {
trap=1;
break;
}
break;
}
f_max_exp++;
}
Unexpected(29);
/* Largest number ***************************************************/
Vprintf("%sMaximum number = %s%s\n",
} else {
eek_a_bug("printf can't print the largest double.");
printf("\n");
}
/* Possible loss of precision warnings here from non-stdc compilers */
} else {
eek_a_bug("xxx_MAX caused a trap");
printf("\n");
}
} else {
printf("%s*** Verify failed for above #define!\n %s %s\n\n",
bugs++;
}
Unexpected(30);
a=1.0; f_max_10_exp=0;
/* Traps and infinities ********************************************/
if (trap) {
} else {
Vprintf("%sOverflow doesn't seem to generate a trap%s\n",
}
#ifdef SIGFPE
#endif
trapped= 0; /* A global variable */
b= 0.0;
a= (1.0/b)/b;
if (!trapped) {
Vprintf("%sDivide by zero doesn't generate a trap%s\n",
} else {
Vprintf("%sDivide by zero generates a trap%s\n",
Vprintf("%sFP signal handlers return safely%s\n",
}
} else {
Vprintf("%sBEWARE! FP signal handlers can NOT return%s\n",
}
setsignals();
Unexpected(31);
/* Hidden bit + sanity check ****************************************/
if (f_radix != 10) {
hidden=0;
hidden=1;
Vprintf("%sArithmetic doesn't use a hidden bit%s\n",
Vprintf("%sOnly %d of the %d bits of a %s %s%s\n",
co,
"are actually used",
oc);
} else {
printf("\n%s%s\n %s (%d) %s (%d) %s %s (%d)!%s\n\n",
co,
"*** Something fishy here!",
"Exponent size",
iexp,
"+ significand size",
"doesn't match with the size of a",
oc);
}
Vprintf("%sIt looks like %s length IEEE format%s\n",
"some", oc);
if (f_rounds != 1) {
Vprintf("the rounding is unusual");
}
if (normal) {
Vprintf("the normalisation is unusual");
}
}
} else {
Vprintf("%sIt doesn't look like IEEE format%s\n",
}
}
return f_mant_dig;
}
{
/* See if expressions are evaluated in extended precision.
Some compilers optimise even if you don't want it,
and then this function fails to produce the right result.
We try to diagnose this if it happens.
*/
/* Size of significand **************************************/
a=1.0;
do { old=a; a=a+a; }
} else bad=1;
if (!bad) {
b=1.0;
do { old=b; b=b+b; }
} else bad=1;
}
if (!bad) {
} else bad=1;
}
Unexpected(32);
if (bad) {
Vprintf("%sCan't determine precision for %s expressions:\n%s%s\n",
oc);
Vprintf("%s%s expressions are evaluated in double precision%s\n",
Vprintf("%s%s expressions are evaluated in float precision%s\n",
Vprintf("%s%s expressions are evaluated in long double precision%s\n",
} else {
Vprintf("%s%s expressions are evaluated in a %s %s %d %s%s\n",
"precision than double,\n using",
eprec, "base digits",
oc);
}
}
#else /* not Number */
#ifdef FPROP /* Then create dummy routines for long double */
/* ARGSUSED */
#endif
#ifdef EPROP
/* ARGSUSED */
#endif
#endif /* ifdef Number */
/* Increment the pass number */
#ifdef PASS2
#endif
#ifdef PASS1
#endif
#ifdef PASS0
#endif
#ifndef SEP
#ifdef PASS /* then rescan this file */
#ifdef BAD_CPP
#include "enquire.c"
#else
#include FILENAME /* if this line fails to compile, define BAD_CPP */
#endif
#endif /* PASS */
#endif /* SEP */