]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Enquire/Enquire.c
Standard Libraries for EDK II.
[mirror_edk2.git] / AppPkg / Applications / Enquire / Enquire.c
diff --git a/AppPkg/Applications/Enquire/Enquire.c b/AppPkg/Applications/Enquire/Enquire.c
new file mode 100644 (file)
index 0000000..1e1db69
--- /dev/null
@@ -0,0 +1,3377 @@
+/** @file\r
+    Every thing you wanted to know about your compiler but didn't know whom to ask.\r
+\r
+    COPYRIGHT(c) 1993-9 Steven Pemberton, CWI. All rights reserved.\r
+    Steven Pemberton, CWI, Amsterdam; "Steven.Pemberton@cwi.nl"\r
+    Used with permission.\r
+\r
+    Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
+    This program and the accompanying materials\r
+    are licensed and made available under the terms and conditions of the BSD License\r
+    which accompanies this distribution. The full text of the license may be found at\r
+    http://opensource.org/licenses/bsd-license.\r
+\r
+    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+#if defined(_MSC_VER)           /* Handle Microsoft VC++ compiler specifics. */\r
+  #pragma warning ( disable : 4018 )\r
+  #pragma warning ( disable : 4055 )\r
+  #pragma warning ( disable : 4116 )\r
+  #pragma warning ( disable : 4130 )\r
+  #pragma warning ( disable : 4189 )\r
+  #pragma warning ( disable : 4244 )\r
+  #pragma warning ( disable : 4723 )\r
+#endif  /* defined(_MSC_VER) */\r
+\r
+//#define NO_SC   1   // Compiler doesn't support signed char\r
+//#define NO_UC   1   // Compiler doesn't support unsigned char\r
+//#define NO_UI   1   // Compiler doesn't support unsigned short and long\r
+//#define NO_VOID 1   // Compiler doesn't support void\r
+//#define NO_SIG  1   // Compiler doesn't support signal() or setjmp/longjmp()\r
+\r
+/*  Some compilers can't cope with "#ifdef __FILE__". Use\r
+    either the FILENAME or BAD_CPP macro as described below.\r
+*/\r
+/*  If your C preprocessor doesn't have the predefined __FILE__\r
+macro, and you don't want to call this file enquire.c but, say,\r
+tell.c, uncomment the following and change enquire.c to tell.c.\r
+*/\r
+//#define FILENAME "enquire.c"\r
+\r
+/*  Some compilers won't accept the line "#include FILENAME".  Uncomment\r
+    the following macro. In that case, this file *must* be called enquire.c.\r
+*/\r
+//#define BAD_CPP     1\r
+\r
+/*  Some naughty compilers define __STDC__, but don't really\r
+    support it.  Some define it as 0, in which case we ignore it.\r
+    But if your compiler defines it, and isn't really ANSI C,\r
+    uncomment the BAD_STDC macro. (To those compiler writers: for shame).\r
+*/\r
+//#define BAD_STDC    1\r
+\r
+/*  Some naughty compilers define __STDC__, but don't have the\r
+    stddef.h include file. Uncomment the BAD_STDDEF macro. (Gcc needs this on\r
+    some machines, due to clashes between stddef.h and other include files.)\r
+*/\r
+//#define BAD_STDDEF  1\r
+\r
+/*  Some systems crash when you try to malloc all store. To save users of such\r
+    defective systems too much grief, they may uncomment the BAD_MALLOC macro,\r
+    which ignores that bit of the code.\r
+*/\r
+//#define BAD_MALLOC  1\r
+\r
+\r
+\r
+#ifndef PROGRAM\r
+#define PROGRAM enquire.c\r
+#define VERSION "5.1a"\r
+#define PURPOSE Everything you wanted to know about your machine and C compiler\r
+#define BUT didnt know who to ask\r
+#define FOR Any OS, any C compiler\r
+#define AUTHOR  Steven Pemberton, CWI, Amsterdam; "Steven.Pemberton@cwi.nl"\r
+#define COPYRIGHT(c) 1993-9 Steven Pemberton, CWI. All rights reserved.\r
+#define NOTE  Improvements gratefully received. Please mention the version.\r
+#define COMPILE On Unix compile with: "sh enquire.c"; see below for details\r
+#define WEB "http://www.cwi.nl/~steven/enquire.html"\r
+#endif\r
+\r
+#ifdef NOTDEFINED /* This is how you compile it; see below for details */\r
+  case $0 in\r
+  *.c) ;;\r
+  sh) echo 'Use "sh enquire.c", not "sh < enquire.c"' >&2; exit 1;;\r
+  *) echo 'Filename must end in ".c"' >&2; exit 1;;\r
+  esac\r
+  if test -r test.c\r
+  then echo Would overwrite test.c - try it somewhere safer >&2; exit 1\r
+  fi\r
+  CFLAGS=\r
+  echo Testing for needed CFLAGS ...\r
+  echo "main(){char c; c=0;}" > test.c\r
+  if ${CC=cc} ${1+"$@"} -o enquire test.c $LIBS\r
+  then :\r
+  else\r
+      echo '*** "'$CC ${1+"$@"} -o enquire test.c $LIBS'" failed'\r
+      echo '*** Giving up'\r
+      /bin/rm -f test.c\r
+      exit 1\r
+  fi\r
+  echo "main(){signed char c; c=0;}" > test.c\r
+  if $CC ${1+"$@"} -o enquire test.c $LIBS 2>/dev/null\r
+  then echo "   Signed char ok"\r
+  else\r
+    CFLAGS=-DNO_SC\r
+    echo "   Signed char not accepted; using $CFLAGS"\r
+  fi\r
+  echo "main(){unsigned char c; c=0;}" > test.c\r
+  if $CC ${1+"$@"} -o enquire test.c $LIBS 2>/dev/null\r
+  then echo "   Unsigned char ok"\r
+  else\r
+    CFLAGS="$CFLAGS -DNO_UC"\r
+    echo "   Unsigned char not accepted; using $CFLAGS"\r
+  fi\r
+  echo "main(){unsigned short s;unsigned long l;s=0;l=0;}" > test.c\r
+  if $CC ${1+"$@"} -o enquire test.c $LIBS 2>/dev/null\r
+  then echo "   Unsigned short and long ok"\r
+  else\r
+    CFLAGS="$CFLAGS -DNO_UI"\r
+    echo "   Unsigned short or long not accepted; using $CFLAGS"\r
+  fi\r
+  echo "void foo(){} main(){foo();}" > test.c\r
+  if $CC ${1+"$@"} -o enquire test.c $LIBS 2>/dev/null\r
+  then echo "   Void ok"\r
+  else\r
+    CFLAGS="$CFLAGS -DNO_VOID"\r
+    echo "   Void not accepted; using $CFLAGS"\r
+  fi\r
+  /bin/rm -f test.c a.out\r
+\r
+  echo Compiling $0 ...\r
+  case $# in\r
+  0) : check bug in interpreting "$@" in some shells, if no parameters\r
+     case `echo 1 "$@" 2` in\r
+     "1  2") echo '   *** There is a bug in your shell expanding "$@"!'\r
+       echo '   *** Taking remedial action' ;;\r
+     "1 2") ;;\r
+     esac\r
+  esac\r
+  case $ID in\r
+  "") echo "   $CC" $CFLAGS "$@" $0 -o enquire $LIBS\r
+      $CC $CFLAGS ${1+"$@"} $0 -o enquire $LIBS ||\r
+    { echo '***' Try setting some CFLAGS; exit 1; }\r
+      ;;\r
+  *)  echo "   $CC" $CFLAGS "$@" -DID="\"$ID\"" $0 -o enquire $LIBS\r
+      $CC $CFLAGS ${1+"$@"} -DID="\"$ID\"" $0 -o enquire $LIBS ||\r
+    { echo '***' Try setting some CFLAGS; exit 1; }\r
+  esac\r
+  echo "Producing enquire.out limits.h and float.h ..."\r
+  echo "   enquire > enquire.out"\r
+  ./enquire > enquire.out || echo '   *** Some problems: see enquire.out'\r
+  echo "   enquire -l > limits.h"\r
+  ./enquire -l > limits.h || echo '   *** Some problems: see limits.h'\r
+  echo "   enquire -f > float.h"\r
+  ./enquire -f > float.h  || echo '   *** Some problems: see float.h'\r
+  echo "Verifying the contents of limits.h and float.h ..."\r
+  echo "   $CC" -DVERIFY $CFLAGS "$@" $0 -o verify $LIBS\r
+  $CC -DVERIFY $CFLAGS ${@+"$@"} $0 -o verify $LIBS ||\r
+    { echo '***' Failed; exit 1; }\r
+  echo "   verify -fl > verify.out"\r
+  ./verify -fl > verify.out ||\r
+    echo '   *** Some problems: see verify.out'\r
+  echo Done\r
+  exit 0\r
+#endif\r
+\r
+/*\r
+ PURPOSE\r
+    This is a program that determines many properties of the C\r
+    compiler and machine that it is run on, such as minimum and\r
+    maximum [un]signed char/int/long, many properties of float/ [long]\r
+    double, and so on.\r
+\r
+    As an option it produces the ANSI C float.h and limits.h files.\r
+\r
+    As a further option, it even checks that the compiler reads the\r
+    header files correctly.\r
+\r
+    It is a good test-case for compilers, since it exercises them with\r
+    many limiting values, such as the minimum and maximum floating-point\r
+    numbers.\r
+\r
+ COMPILING AND RUNNING ON UNIX MACHINES\r
+    With luck and a following wind, on Unix systems just the following\r
+    will work:\r
+  sh enquire.c    (or whatever filename you chose).\r
+    Any parameters are passed to the C compiler, so if the compilation\r
+    fails for any reason curable as explained below, you can do the following:\r
+  sh enquire.c -DBAD_CPP\r
+\r
+    If you do get compilation errors, check the line in question.\r
+    Very often there is a comment attached saying which define to set.\r
+\r
+    You can use a different C compiler than the default cc by setting CC:\r
+  CC=gcc sh enquire.c -ansi\r
+    You can load extra libraries by setting LIBS:\r
+  CC=gcc LIBS=-lflong sh enquire.c -ansi\r
+    Add ID="string" for the string to be added to the output; for instance:\r
+  ID="`hostname` cc -ansi" sh enquire.c -ansi\r
+\r
+    Compiling may give messages about unreachable code. These you can ignore.\r
+\r
+    Some compilers offer various flags for different floating point\r
+    modes; it's worth trying all possible combinations of these.\r
+\r
+    Don't say I haven't tried to make life easy for you...\r
+\r
+ COMPILING AND RUNNING ON NON-UNIX SYSTEMS\r
+    On non-Unix systems, you must say (the equivalent of):\r
+  cc enquire.c -o enquire\r
+  enquire > enquire.out\r
+  enquire -l > limits.h\r
+  enquire -f > float.h\r
+  cc -DVERIFY enquire.c -o verify #this includes limits.h and float.h\r
+  verify -fl > verify.out\r
+\r
+    If your compiler doesn't support:   add flag:\r
+  signed char (eg pcc)      -DNO_SC\r
+  unsigned char       -DNO_UC\r
+  unsigned short and long     -DNO_UI\r
+  void          -DNO_VOID\r
+  signal(), or setjmp/longjmp()   -DNO_SIG\r
+\r
+    Try to compile first with no flags, and see if you get any errors\r
+    - you might be surprised. (Most non-ANSI compilers need -DNO_SC,\r
+    though.)  Some compilers need a -f flag for floating point.\r
+\r
+    Don't use any optimisation flags: the program may not work if you\r
+    do.  Though "while (a+1.0-a-1.0 == 0.0)" may look like "while(1)"\r
+    to an optimiser, to a floating-point unit there's a world of difference.\r
+\r
+    Compiling may give messages about unreachable code. These you can ignore.\r
+\r
+    Some compilers offer various flags for different floating point\r
+    modes; it's worth trying all possible combinations of these.\r
+\r
+ FAULTY COMPILERS\r
+    Because of bugs and/or inadequacies, some compilers need the following\r
+    defines:\r
+\r
+    -  If your C preprocessor doesn't have the predefined __FILE__\r
+       macro, and you don't want to call this file enquire.c but, say,\r
+       tell.c, add the flag -DFILENAME=\"tell.c\" .\r
+\r
+    -  Some compilers won't accept the line "#include FILENAME".  Add\r
+       flag -DBAD_CPP. In that case, this file *must* be called\r
+       enquire.c.\r
+\r
+    -  Some compilers can't cope with "#ifdef __FILE__". Use\r
+       -DFILENAME= or -DBAD_CPP as above.\r
+\r
+    -  Some naughty compilers define __STDC__, but don't really\r
+       support it.  Some define it as 0, in which case we ignore it.\r
+       But if your compiler defines it, and isn't really ANSI C, add\r
+       flag -DBAD_STDC. (To those compiler writers: for shame).\r
+\r
+    -  Some naughty compilers define __STDC__, but don't have the\r
+       stddef.h include file. Add flag -DBAD_STDDEF. (Gcc needs this\r
+       on some machines, due to clashes between stddef.h and other\r
+       include files.)\r
+\r
+    -  Some systems crash when you try to malloc all store. To save\r
+       users of such defective systems too much grief, they may\r
+       compile with -DBAD_MALLOC, which ignores that bit of the code.\r
+\r
+    Summary of naughty-compiler flags:\r
+    If your compiler doesn't support:    add flag:\r
+  __FILE__ (and you changed the filename) -DFILENAME=\"name.c\"\r
+  #ifdef __FILE__       -DBAD_CPP or -DFILENAME=...\r
+  #include FILENAME     -DBAD_CPP\r
+  __STDC__ (properly)     -DBAD_STDC\r
+  stddef.h        -DBAD_STDDEF\r
+  malloc(LOTS) == NULL      -DBAD_MALLOC\r
+\r
+    While it is not our policy to support defective compilers, pity has been\r
+    taken on people with compilers that can't produce object files bigger than\r
+    32k (especially since it was an easy addition). Compile the program\r
+    into separate parts like this:\r
+  cc -c -DSEP -DPASS0 -o p0.o <other flags> enquire.c\r
+  cc -c -DSEP -DPASS1 -o p1.o <other flags> enquire.c\r
+  cc -c -DSEP -DPASS2 -o p2.o <other flags> enquire.c\r
+  cc -c -DSEP -DPASS3 -o p3.o <other flags> enquire.c\r
+  cc -o enquire p0.o p1.o p2.o p3.o\r
+\r
+ SYSTEM DEPENDENCIES\r
+    You may possibly need to add some calls to signal() for other sorts of\r
+    exception on your machine than SIGFPE, SIGOVER, SIGBUS, and SIGSEGV.\r
+    See lines beginning #ifdef SIGxxx (and communicate the differences to me!).\r
+\r
+ OUTPUT\r
+    Running without argument gives the information as English text. If run\r
+    with argument -l (e.g. enquire -l), output is a series of #define's for\r
+    the ANSI standard limits.h include file, excluding MB_MAX_CHAR. If run\r
+    with argument -f, output is a series of #define's for the ANSI standard\r
+    float.h include file (according to ANSI C Draft of Dec 7, 1988).\r
+    Flag -v gives verbose output: output includes the English text above\r
+    as C comments. The program exit(0)'s if everything went ok, otherwise\r
+    it exits with a positive number, telling how many problems there were.\r
+\r
+ VERIFYING THE COMPILER\r
+    If, having produced the float.h and limits.h header files, you want to\r
+    verify that the compiler reads them back correctly (there are a lot of\r
+    boundary cases, of course, like minimum and maximum numbers), you can\r
+    recompile enquire.c with -DVERIFY set (plus the other flags that you used\r
+    when compiling the version that produced the header files). This then\r
+    recompiles the program so that it #includes "limits.h" and "float.h",\r
+    and checks that the constants it finds there are the same as the\r
+    constants it produces. Run the resulting program with enquire -fl.\r
+    Many compilers fail this test.\r
+    NB: You *must* recompile with the same compiler and flags, otherwise\r
+    you may get odd results.\r
+\r
+    You can also use this option if your compiler already has both files,\r
+    and you want to confirm that this program produces the right results.\r
+\r
+ TROUBLESHOOTING.\r
+    This program is now quite trustworthy, and suspicious and wrong output\r
+    may well be caused by bugs in the compiler, not in the program (however\r
+    of course, this is not guaranteed, and no responsibility can be\r
+    accepted, etc.)\r
+\r
+    The program only works if overflows are ignored by the C system or\r
+    are catchable with signal().\r
+\r
+    If the program fails to run to completion (often with the error message\r
+    "Unexpected signal at point x"), this often turns out to be a bug in the\r
+    C compiler's run-time system. Check what was about to be printed, and\r
+    try to narrow the problem down.\r
+\r
+    Another possible problem is that you have compiled the program to produce\r
+    loss-of-precision arithmetic traps. The program cannot cope with these,\r
+    and you should re-compile without them. (They should never be the default).\r
+\r
+    Make sure you compiled with optimisation turned off.\r
+\r
+    Output preceded by *** WARNING: identifies behaviour of the C system\r
+    deemed incorrect by the program. Likely problems are that printf or\r
+    scanf don't cope properly with certain boundary numbers: this program\r
+    goes to a lot of trouble to calculate its values, and these values\r
+    are mostly boundary numbers. Experience has shown that often printf\r
+    cannot cope with these values, and so in an attempt to increase\r
+    confidence in the output, for each float and double that is printed,\r
+    the printed value is checked by using sscanf to read it back.\r
+   Care is taken that numbers are printed with enough digits to uniquely\r
+    identify them, and therefore that they can be read back identically.\r
+    If the number read back is different, then there is probably a bug in\r
+    printf or sscanf, and the program prints the warning message.\r
+    If the two numbers in the warning look identical, then printf is more\r
+    than likely rounding the last digit(s) incorrectly. To put you at ease\r
+    that the two really are different, the bit patterns of the two numbers\r
+    are also printed. The difference is very likely in the last bit.\r
+   Many scanf's read the minimum double back as 0.0, and similarly cause\r
+    overflow when reading the maximum double. This program quite ruthlessly\r
+    declares all these behaviours faulty. The point is that if you get\r
+    one of these warnings, the output may be wrong, so you should check\r
+    the result carefully if you intend to use the results. Of course, printf\r
+    and sscanf may both be wrong, and cancel each other out, so you should\r
+    check the output carefully anyway.\r
+\r
+    The warning that "a cast didn't work" refers to cases like this:\r
+\r
+  float f;\r
+  #define C 1.234567890123456789\r
+  f= C;\r
+  if (f != (float) C) printf ("Wrong!");\r
+\r
+    A faulty compiler will widen f to double and ignore the cast to float,\r
+    and because there is more accuracy in a double than a float, fail to\r
+    recognise that they are the same. In the actual case in point, f and C\r
+    are passed as parameters to a function that discovers they are not equal,\r
+    so it's just possible that the error was in the parameter passing,\r
+    not in the cast (see function Verify()).\r
+    For ANSI C, which has float constants, the error message is "constant has\r
+    wrong precision".\r
+\r
+ REPORTING PROBLEMS\r
+    If the program doesn't work for you for any reason that can't be\r
+    narrowed down to a problem in the C compiler, or it has to be\r
+    changed in order to get it to compile, or it produces suspicious\r
+    output (like a very low maximum float, for instance), please mail\r
+    the problem and an example of the incorrect output to\r
+    Steven.Pemberton@cwi.nl so that improvements can be worked into\r
+    future versions. Try to give as much information as possible;\r
+    DON'T FORGET TO MENTION THE VERSION NUMBER!\r
+\r
+    The program tries to catch and diagnose bugs in the compiler/run-time\r
+    system. I would be especially pleased to have reports of failures so\r
+    that I can improve this service.\r
+\r
+    I apologise unreservedly for the contorted use of the preprocessor...\r
+    but it was fun!\r
+\r
+ NEW VERSIONS\r
+    Worried that you may not have the latest version? Ftp to\r
+    ftp.cwi.nl, and look in directory pub/steven/enquire\r
+    for file enquireXX.c; XX is the version number. Or look at\r
+    http://www.cwi.nl/~steven/enquire.html\r
+\r
+ HOW DOES ENQUIRE WORK?\r
+    There is an article that explains a lot of the workings: The\r
+    Ergonomics of Portability; available from the above addresses as file\r
+    enquire.ps.\r
+\r
+ THE SMALL PRINT\r
+    This is not a public domain program; nor is any other program that\r
+    carries a copyright notice. It is however freely copyable under the\r
+    following conditions:\r
+\r
+       You may copy and distribute verbatim copies of this source file.\r
+       You may modify this source file, and copy and distribute such\r
+       modified versions, provided that you leave the copyright notice\r
+       at the top of the file and also cause the modified file to carry\r
+       prominent notices stating that you changed the files and the\r
+       date of any change; and cause the whole of any work that you\r
+       distribute or publish, that in whole or in part contains or is a\r
+       derivative of this program or any part thereof, to be licensed\r
+       at no charge to all third parties on terms identical to those\r
+       here.\r
+\r
+    While every effort has been taken to make this program as reliable as\r
+    possible, no responsibility can be taken for the correctness of the\r
+    output, nor suitability for any particular use.\r
+\r
+    If you do have a fix to any problem, please send it to me, so that\r
+    other people can have the benefits.\r
+\r
+    This program is an offshoot of a project funded by public funds.\r
+    If you use this program for research or commercial use (i.e. more\r
+    than just for the fun of knowing about your compiler) mailing a short\r
+    note of acknowledgement may help keep enquire.c supported.\r
+\r
+ ACKNOWLEDGEMENTS\r
+    Many people have given time and ideas to making this program what it is.\r
+    To all of them thanks, and apologies for not mentioning them by name.\r
+\r
+ HISTORY\r
+    Originally started as a program to generate configuration constants\r
+    for a large piece of software we were writing, which later took on\r
+    a life of its own...\r
+    1.0 Length 6658!; end 1984?\r
+  Unix only. Only printed a dozen maximum int/double values.\r
+    2.0 Length 10535; Spring 1985\r
+  Prints values as #defines (about 20 of them)\r
+  More extensive floating point, using Cody and Waite\r
+  Handles signals better\r
+  Programs around optimisations\r
+  Handles Cybers\r
+    3.0 Length 12648; Aug 1987; prints about 42 values\r
+  Added PASS stuff, so treats float as well as double\r
+    4.0 Length 33891; Feb 1989; prints around 85 values\r
+  First GNU version (for gcc, where they called it hard-params.c)\r
+  Generates float.h and limits.h files\r
+  Handles long double\r
+  Generates warnings for dubious output\r
+    4.1 Length 47738; April 1989\r
+  Added VERIFY and TEST\r
+    4.2 Length 63442; Feb 1990\r
+  Added SEP\r
+  Fixed eps/epsneg\r
+  Added check for pseudo-unsigned chars\r
+  Added description for each #define output\r
+  Added check for absence of defines during verify\r
+  Added prototypes\r
+  Added BAD_STDC and BAD_CPP\r
+  Fixed alignments output\r
+    4.3 Length 75000; Oct 1990; around 114 lines of output\r
+  Function xmalloc defined, Richard Stallman, June 89.\r
+  Alignments computed from member offsets rather than structure sizes,\r
+      Richard Stallman, Oct 89\r
+  Print whether char* and int* pointers have the same format;\r
+      also char * and function *\r
+  Update to Draft C version Dec 7, 1988\r
+      - types of constants produced in limits.h\r
+    (whether to put a U after unsigned shorts and chars and\r
+     whether to output -1024 as (-1023-1))\r
+      - values of SCHAR_MIN/MAX\r
+      - values of *_EPSILON (not the smallest but the effective smallest)\r
+  Added FILENAME, since ANSI C doesn't allow #define __FILE__\r
+  Renamed from config.c to enquire.c\r
+  Added size_t and ptrdiff_t enquiries\r
+  Added promotion enquiries\r
+  Added type checks of #defines\r
+  Added BAD_STDDEF\r
+  Changed endian to allow for cases where not all bits are used\r
+  Sanity check for max integrals\r
+  Fixed definition of setjmp for -DNO_SIG\r
+  Moved #define ... 0.0L inside #ifdef STDC, in case some cpp's tokenize\r
+  Added BAD_MALLOC\r
+    5.0 Length 88228; February 1993; around 120 lines of output\r
+         (depends on what you count)\r
+  Added the 'sh enquire.c' horror/delight: thanks David Mankins@think\r
+  Added checks for long names: thanks Steve Simon@leeds-poly\r
+  Added FPE signal checks: thanks Leonid A. Broukhis\r
+  Added check for dereferencing NULL\r
+  Added TESTI\r
+  Added LIBS, fixed showtype: thanks Rainer Orth@TechFak.Uni-Bielefeld.DE\r
+  Added a free(): thanks nickc@perihelion.co.uk\r
+  Added signal catching to the malloc part\r
+  Renamed naughty-compiler defines to BAD_*\r
+  Renamed and altered Verify() to better check faulty compilers\r
+  Shut some compilers up from giving incorrect warnings.\r
+  Fixed sign_of(): thanks Hugh Redelmeier@redvax\r
+  Fixed USHRT_MAX for sizeof(short)=sizeof(int) but INT_MAX > SHRT_MAX\r
+  Fixed NO_UI\r
+  Fixed -DSEP: thanks Mike Black@seismo\r
+  Fixed the case where stdio.h includes limits.h: thanks rms@gnu\r
+  Fixed exponent(): thanks Christophe BINOT\r
+    <chb%hpvpta.france.hp.com@hplb.hpl.hp.com>\r
+   5.0a Aug 1997\r
+  Made handling of ID= easier\r
+  Improved the reporting of use of bits in Floating values.\r
+   5.1  Length 88739; Sep 1998\r
+  Fixed detection of infinity for machines with no overflow trap\r
+  Speeded up search for max char (first 32 bit char machine turned up...)\r
+   5.1a Length 88832; Feb 1999\r
+  Changed identification message\r
+   5.1b Length 88926; Oct 2002\r
+        Fixed a missing \n in an output line; thanks Leonid Broukhis again\r
+*/\r
+\r
+/* Set FILENAME to the name of this file */\r
+#ifndef FILENAME\r
+#ifdef BAD_CPP\r
+#define FILENAME "enquire.c"\r
+#else\r
+#ifdef __FILE__ /* It's a compiler bug if this fails. Define BAD_CPP */\r
+#define FILENAME __FILE__\r
+#else\r
+#define FILENAME "enquire.c"\r
+#endif /* __FILE__ */\r
+#endif /* BAD_CPP */\r
+#endif /* FILENAME */\r
+\r
+/* This file is read three times (it #includes itself), to generate\r
+   otherwise identical code for each of short+float, int+double,\r
+   long+long double. If PASS isn't defined, then this is the first pass.\r
+   Code bracketed by 'PASS0' is for stuff independent of all three,\r
+   but is read during the first pass.\r
+*/\r
+#ifndef PASS\r
+#ifdef SEP /* so we're only interested if this is pass 1 or not */\r
+#ifdef PASS1\r
+#define PASS 1\r
+#else\r
+#define PASS 0\r
+#endif\r
+#else /* no SEP, so this is the first pass */\r
+#define PASS 1\r
+#define PASS0 1\r
+#define PASS1 1\r
+#endif /* SEP */\r
+\r
+/* Void just marks the functions that don't return a result */\r
+#ifdef NO_VOID\r
+#define Void int\r
+#else\r
+#define Void void\r
+#endif\r
+\r
+/* Set STDC to whether this is *really* an ANSI C compiler.\r
+   Some bad compilers define __STDC__, when they don't support it.\r
+   Compile with -DBAD_STDC to get round this.\r
+*/\r
+#ifndef BAD_STDC\r
+#ifdef __STDC__\r
+#if __STDC__ /* If __STDC__ is 0, assume it isn't supported */\r
+#define STDC\r
+#endif\r
+#endif\r
+#endif\r
+\r
+/* Stuff different for ANSI C, and old C:\r
+   ARGS and NOARGS are used for function prototypes.\r
+   Volatile is used to reduce the chance of optimisation,\r
+  and to prevent variables being put in registers (when setjmp/longjmp\r
+  wouldn't work as we want)\r
+   Long_double is the longest floating point type available.\r
+   stdc is used in tests like "if (stdc)", which is less ugly than #ifdef.\r
+   U is output after unsigned constants.\r
+ */\r
+#ifdef STDC\r
+\r
+#define ARGS(x) x\r
+#define NOARGS (void)\r
+#define Volatile volatile\r
+#define Long_double long double\r
+#define stdc 1\r
+#define U "U"\r
+\r
+#else /* Old style C */\r
+\r
+#define ARGS(x) ()\r
+#define NOARGS ()\r
+#define Volatile static\r
+#define Long_double double\r
+#define stdc 0\r
+#define U ""\r
+\r
+#endif /* STDC */\r
+\r
+/* include files */\r
+#include <stdio.h>\r
+#include  <wchar.h>\r
+\r
+#ifdef STDC\r
+#ifndef BAD_STDDEF\r
+#include <stddef.h> /* for size_t: if this fails, define BAD_STDDEF */\r
+#endif\r
+#endif\r
+\r
+#ifdef NO_SIG\r
+#define jmp_buf int\r
+#else\r
+#include <signal.h> /* if this fails, define NO_SIG */\r
+#include <setjmp.h> /* if this fails, define NO_SIG */\r
+#endif\r
+//#ifndef NO_SIG\r
+//#include <signal.h> /* if this fails, define NO_SIG */\r
+//#include <setjmp.h> /* if this fails, define NO_SIG */\r
+//#endif\r
+\r
+/* Kludge around the possiblity that <stdio.h> includes <limits.h> */\r
+#ifdef CHAR_BIT\r
+#undef CHAR_BIT\r
+#undef CHAR_MAX\r
+#undef CHAR_MIN\r
+#undef SCHAR_MAX\r
+#undef SCHAR_MIN\r
+#undef UCHAR_MAX\r
+#undef UCHAR_MIN\r
+#endif\r
+\r
+#ifdef VERIFY\r
+#include "limits.h"\r
+#include "float.h"\r
+#endif\r
+\r
+/* The largest unsigned type */\r
+#ifdef NO_UI\r
+#define ulong unsigned int\r
+#else\r
+#define ulong unsigned long\r
+#endif\r
+\r
+/* Some shorthands */\r
+#define Vprintf if (V) printf\r
+#define Unexpected(place) if (setjmp(lab)!=0) croak(place)\r
+#define fabs(x) (((x)<0.0)?(-x):(x))\r
+\r
+#endif /* PASS */\r
+\r
+/* A description of the ANSI constants */\r
+#define D_CHAR_BIT "Number of bits in a storage unit"\r
+#define D_CHAR_MAX "Maximum char"\r
+#define D_CHAR_MIN "Minimum char"\r
+#define D_SCHAR_MAX "Maximum signed char"\r
+#define D_SCHAR_MIN "Minimum signed char"\r
+#define D_UCHAR_MAX "Maximum unsigned char (minimum is always 0)"\r
+\r
+#define D_INT_MAX "Maximum %s"\r
+#define D_INT_MIN "Minimum %s"\r
+#define D_UINT_MAX "Maximum unsigned %s (minimum is always 0)"\r
+\r
+#define D_FLT_ROUNDS "Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown"\r
+#define D_FLT_RADIX "Radix of exponent representation"\r
+#define D_MANT_DIG "Number of base-FLT_RADIX digits in the significand of a %s"\r
+#define D_DIG "Number of decimal digits of precision in a %s"\r
+#define D_MIN_EXP "Minimum int x such that FLT_RADIX**(x-1) is a normalised %s"\r
+#define D_MIN_10_EXP "Minimum int x such that 10**x is a normalised %s"\r
+#define D_MAX_EXP "Maximum int x such that FLT_RADIX**(x-1) is a representable %s"\r
+#define D_MAX_10_EXP "Maximum int x such that 10**x is a representable %s"\r
+#define D_MAX "Maximum %s"\r
+#define D_EPSILON "Difference between 1.0 and the minimum %s greater than 1.0"\r
+#define D_MIN "Minimum normalised %s"\r
+\r
+#ifdef PASS0\r
+\r
+/* Prototypes for what's to come: */\r
+\r
+int false NOARGS;\r
+\r
+#ifdef BAD_STDDEF\r
+char *malloc (); /* Old style prototype, since we don't know what size_t is */\r
+#else\r
+char *malloc ARGS((size_t size));\r
+#endif\r
+Void free ARGS((char *p)); /* Syntax error here? Try -DNO_VOID */\r
+\r
+Void exit ARGS((int status));\r
+\r
+char *f_rep ARGS((int precision, Long_double val));\r
+\r
+int maximum_int NOARGS;\r
+int cprop NOARGS;\r
+int basic NOARGS;\r
+Void sprop NOARGS;\r
+Void iprop NOARGS;\r
+Void lprop NOARGS;\r
+Void usprop NOARGS;\r
+Void uiprop NOARGS;\r
+Void ulprop NOARGS;\r
+int fprop ARGS((int byte_size));\r
+int dprop ARGS((int byte_size));\r
+int ldprop ARGS((int byte_size));\r
+Void efprop ARGS((int fprec, int dprec, int lprec));\r
+Void edprop ARGS((int fprec, int dprec, int lprec));\r
+Void eldprop ARGS((int fprec, int dprec, int lprec));\r
+\r
+int setmode ARGS((char *s));\r
+Void farewell ARGS((int bugs));\r
+Void describe ARGS((char *description, char *extra));\r
+Void missing ARGS((char *s));\r
+Void fmissing ARGS((char *s));\r
+Void check_defines NOARGS;\r
+Void bitpattern ARGS((char *p, unsigned int size));\r
+int ceil_log ARGS((int base, Long_double x));\r
+Void croak ARGS((int place));\r
+Void trap1 ARGS((int sig));\r
+Void eek_a_bug ARGS((char *problem));\r
+Void endian ARGS((int byte_size));\r
+int exponent ARGS((Long_double x, Long_double *fract, int *exp));\r
+int floor_log ARGS((int base, Long_double x));\r
+Void f_define ARGS((char *desc, char *extra, char *sort, char *name,\r
+       int prec, Long_double val, char *mark));\r
+Void i_define ARGS((char *desc, char *extra, char *sort, char *name,\r
+       long val, long lim, long req, char *mark));\r
+Void u_define ARGS((char *desc, char *extra, char *sort, char *name,\r
+       ulong val, ulong req, char *mark));\r
+\r
+#ifdef NO_SIG  /* There's no signal(), or setjmp/longjmp() */\r
+\r
+  /* Dummy routines instead */\r
+  typedef int jmp_buf;\r
+\r
+  int setjmp ARGS((jmp_buf lab));\r
+\r
+  jmp_buf lab, mlab;\r
+  int setjmp(jmp_buf lab) { return(0); }\r
+  void  longjmp(jmp_buf lab, int val) { return; }\r
+\r
+  Void signal(int i, void (*p)()) {}\r
+\r
+#else\r
+  jmp_buf lab, mlab;\r
+  Void overflow(int sig)\r
+  { /* what to do on over/underflow */\r
+    signal(sig, overflow);\r
+    longjmp(lab, 1);\r
+  }\r
+\r
+  Void address(int sig)\r
+  { /* what to do on an address error */\r
+    signal(sig, address);\r
+    longjmp(mlab, 1);\r
+  }\r
+\r
+#endif /*NO_SIG*/\r
+\r
+int V= 0, /* verbose */\r
+    L= 0, /* produce limits.h */\r
+    F= 0, /* produce float.h  */\r
+    bugs=0; /* The number of (possible) bugs in the output */\r
+\r
+char co[4], oc[4]; /* Comment starter and ender symbols */\r
+\r
+int bits_per_byte; /* the number of bits per unit returned by sizeof() */\r
+int flt_rounds;    /* The calculated value of FLT_ROUNDS */\r
+int flt_radix;     /* The calculated value of FLT_RADIX */\r
+Volatile int trapped; /* For testing FPE traps */\r
+\r
+#ifdef TEST\r
+/* Set the fp modes on a SUN with 68881 chip, to check that different\r
+   rounding modes etc. get properly detected.\r
+   Compile with -f68881 for cc, -m68881 for gcc, and with additional flag\r
+   -DTEST. Run with additional parameter +hex-number, to set the 68881 mode\r
+   register to hex-number\r
+*/\r
+\r
+/* Bits 0x30 = rounding mode */\r
+#define ROUND_BITS  0x30\r
+#define TO_NEAREST  0x00\r
+#define TO_ZERO   0x10\r
+#define TO_MINUS_INF  0x20\r
+#define TO_PLUS_INF 0x30 /* The SUN FP user's guide seems to be wrong here */\r
+\r
+/* Bits 0xc0 = extended rounding */\r
+#define EXT_BITS  0xc0\r
+#define ROUND_EXTENDED  0x00\r
+#define ROUND_SINGLE  0x40\r
+#define ROUND_DOUBLE  0x80\r
+\r
+/* Enabled traps */\r
+#define EXE_INEX1  0x100\r
+#define EXE_INEX2  0x200\r
+#define EXE_DZ     0x400\r
+#define EXE_UNFL   0x800\r
+#define EXE_OVFL  0x1000\r
+#define EXE_OPERR 0x2000\r
+#define EXE_SNAN  0x4000\r
+#define EXE_BSUN  0x8000\r
+\r
+/* Only used for testing, on a Sun with 68881 chip */\r
+/* Print the FP mode */\r
+printmode(new) unsigned new; {\r
+  fpmode_(&new);\r
+  printf("New fp mode:\n");\r
+  printf("  Round toward ");\r
+  switch (new & ROUND_BITS) {\r
+        case TO_NEAREST:   printf("nearest"); break;\r
+        case TO_ZERO:      printf("zero"); break;\r
+        case TO_MINUS_INF: printf("minus infinity"); break;\r
+        case TO_PLUS_INF:  printf("plus infinity"); break;\r
+        default: printf("???"); break;\r
+  }\r
+\r
+  printf("\n  Extended rounding precision: ");\r
+\r
+  switch (new & EXT_BITS) {\r
+        case ROUND_EXTENDED: printf("extended"); break;\r
+        case ROUND_SINGLE:   printf("single"); break;\r
+        case ROUND_DOUBLE:   printf("double"); break;\r
+        default: printf("???"); break;\r
+  }\r
+\r
+  printf("\n  Enabled exceptions:");\r
+  if (new & (unsigned) EXE_INEX1) printf(" inex1");\r
+  if (new & (unsigned) EXE_INEX2) printf(" inex2");\r
+  if (new & (unsigned) EXE_DZ)    printf(" divz");\r
+  if (new & (unsigned) EXE_UNFL)  printf(" unfl");\r
+  if (new & (unsigned) EXE_OVFL)  printf(" ovfl");\r
+  if (new & (unsigned) EXE_OPERR) printf(" operr");\r
+  if (new & (unsigned) EXE_SNAN)  printf(" snan");\r
+  if (new & (unsigned) EXE_BSUN)  printf(" bsun");\r
+  printf("\n");\r
+}\r
+\r
+/* Only used for testing, on a Sun with 68881 chip */\r
+/* Set the FP mode */\r
+int setmode(s) char *s; {\r
+  unsigned mode=0, dig;\r
+  char c;\r
+\r
+  while (*s) {\r
+    c= *s++;\r
+    if  (c>='0' && c<='9') dig= c-'0';\r
+    else if (c>='a' && c<='f') dig= c-'a'+10;\r
+    else if (c>='A' && c<='F') dig= c-'A'+10;\r
+    else return 1;\r
+    mode= mode<<4 | dig;\r
+  }\r
+  printmode(mode);\r
+  return 0;\r
+}\r
+#define SETMODE\r
+#endif\r
+\r
+#ifdef TESTI /* Test mode using SunOs IEEE routines */\r
+\r
+#include <sys/ieeefp.h>\r
+\r
+int setmode(char *s) {\r
+  char *dummy, c, *cmd, *val;\r
+  while (*s) {\r
+    switch (c= *s++) {\r
+          case '=': cmd= "direction"; val= "nearest"; break;\r
+          case '0': cmd= "direction"; val= "tozero"; break;\r
+          case '+': cmd= "direction"; val= "positive"; break;\r
+          case '-': cmd= "direction"; val= "negative"; break;\r
+          case '1': cmd= "precision"; val= "single"; break;\r
+          case '2': cmd= "precision"; val= "double"; break;\r
+          case '3': cmd= "precision"; val= "extended"; break;\r
+          case '~': cmd= "exception"; val= "inexact"; break;\r
+          case '/': cmd= "exception"; val= "division"; break;\r
+          case '>': cmd= "exception"; val= "overflow"; break;\r
+          case '<': cmd= "exception"; val= "underflow"; break;\r
+          default:\r
+      printf("Bad setmode character: %c\n", c);\r
+      return 1;\r
+      break;\r
+    }\r
+    printf("Set %s %s", cmd, val);\r
+    if (ieee_flags("set", cmd, val, &dummy)) {\r
+      printf(": failed\n");\r
+      return 1;\r
+    }\r
+    printf("\n");\r
+  }\r
+  return 0;\r
+}\r
+#define SETMODE\r
+#endif\r
+\r
+#ifndef SETMODE\r
+/* ARGSUSED */\r
+int\r
+setmode(char *s)\r
+{\r
+  fprintf(stderr, "Can't set mode: not compiled with TEST\n");\r
+  return(1);\r
+}\r
+#endif\r
+\r
+int\r
+memeq(\r
+  char *p1,\r
+  int size1,\r
+  char *p2,\r
+  int size2\r
+  )\r
+{\r
+  /* See if two blocks of store are identical */\r
+  int i;\r
+  if (size1 != size2) return 0;\r
+  for (i=1; i<=size1; i++) {\r
+    if (*p1++ != *p2++) return 0;\r
+  }\r
+  return 1;\r
+}\r
+\r
+Void\r
+farewell(int bugs)\r
+{\r
+  if (bugs == 0) exit(0);\r
+  printf("\n%sFor hints on dealing with the ", co);\r
+  if (bugs == 1) printf("problem");\r
+  else printf("%d problems", bugs);\r
+  printf(" above\n   see the section 'TROUBLESHOOTING' in the file ");\r
+  printf("%s%s\n", FILENAME, oc);\r
+  exit(bugs);\r
+}\r
+\r
+/* The program has received a signal where it wasn't expecting one */\r
+Void\r
+croak(int place)\r
+{\r
+  printf("*** Unexpected signal at point %d\n", place);\r
+  farewell(bugs+1); /* An exit isn't essential here, but avoids loops */\r
+}\r
+\r
+/* This is here in case alloca.c is used, which calls this. */\r
+char *\r
+xmalloc(unsigned size)\r
+{\r
+  char *value = malloc(size);\r
+  if (value == 0) {\r
+    fprintf(stderr, "Virtual memory exceeded\n");\r
+    exit(bugs+1);\r
+  }\r
+  return value;\r
+}\r
+\r
+int maxint;\r
+\r
+int\r
+maximum_int( void )\r
+{\r
+  /* Find the maximum integer */\r
+  Volatile int newi, int_max, two=2;\r
+\r
+  /* Calculate maxint ***********************************/\r
+  /* Calculate 2**n-1 until overflow - then use the previous value  */\r
+\r
+  newi=1; int_max=0;\r
+\r
+  if (setjmp(lab)==0) { /* Yields int_max */\r
+    while(newi>int_max) {\r
+      int_max=newi;\r
+      newi=newi*two+1;\r
+    }\r
+  }\r
+  Unexpected(0);\r
+  return int_max;\r
+}\r
+\r
+/* How long are my identifiers? I could go further here, but some compilers\r
+   have line length limits that I don't want to break.\r
+*/\r
+\r
+int zzzzzzzzz1zzzzzzzzz2zzzzzzzzz3zzzzzzzzz4zzzzzzzzz5zzzzzzzzz6zzzz=64;\r
+\r
+int\r
+name_len( void )\r
+{\r
+   int zzzzzzzzz1zzzzzzzzz2zzzzzzzzz3zz=32;\r
+   { int zzzzzzzzz1zzzzzz=16;\r
+     { int zzzzzzzz=8;\r
+       { int zzzzzzz=7;\r
+   { int zzzzzz=6;\r
+     return\r
+       zzzzzzzzz1zzzzzzzzz2zzzzzzzzz3zzzzzzzzz4zzzzzzzzz5zzzzzzzzz6zzzz;\r
+   }\r
+       }\r
+     }\r
+   }\r
+}\r
+\r
+#define aaaaaaaaa1aaaaaaaaa2aaaaaaaaa3aaaaaaaaa4aaaaaaaaa5aaaaaaaaa6aaaa 64\r
+#define LENGTH 64\r
+\r
+#ifdef aaaaaaaaa1aaaaaaaaa2aaaaaaaaa3aa\r
+#undef LENGTH\r
+#define LENGTH 32\r
+#endif\r
+\r
+#ifdef aaaaaaaaa1aaaaaa\r
+#undef LENGTH\r
+#define LENGTH 16\r
+#endif\r
+\r
+#ifdef aaaaaaaa\r
+#undef LENGTH\r
+#define LENGTH 8\r
+#endif\r
+\r
+#undef aaaaaaaaa1aaaaaaaaa2aaaaaaaaa3aaaaaaaaa4aaaaaaaaa5aaaaaaaaa6aaaa\r
+\r
+Void long_names()\r
+{\r
+  int l= name_len();\r
+  Vprintf("Compiler names are at least %d chars long", l);\r
+  if (l != 64)\r
+    Vprintf(" (but less than %d)", l*2);\r
+  Vprintf("\n");\r
+  Vprintf("Preprocessor names are at least %d long", LENGTH);\r
+  if (LENGTH != 64)\r
+    Vprintf(" (but less than %d)", LENGTH*2);\r
+  Vprintf("\n\n");\r
+}\r
+\r
+/* Used by FPROP to see if FP traps are generated, and if they may return */\r
+\r
+Void\r
+trap2(int sig)\r
+{\r
+  longjmp(lab, 1);\r
+}\r
+\r
+Void\r
+trap1(int sig)\r
+{\r
+  trapped= 1; /* A global */\r
+  signal(sig, trap2);\r
+}\r
+\r
+Void\r
+setsignals( void )\r
+{\r
+#ifdef SIGFPE\r
+  signal(SIGFPE, overflow);\r
+#endif\r
+#ifdef SIGOVER\r
+  signal(SIGOVER, overflow);\r
+#endif\r
+#ifdef SIGBUS\r
+  signal(SIGBUS, address);\r
+#endif\r
+#ifdef SIGSEGV\r
+  signal(SIGSEGV, address);\r
+#endif\r
+  /* Add more calls as necessary */\r
+}\r
+\r
+#undef LENGTH\r
+\r
+int\r
+main(int argc, char *argv[])\r
+{\r
+  int dprec, fprec, lprec;\r
+  int i;\r
+  wchar_t *s;\r
+  int bad;\r
+\r
+  setsignals();\r
+  Unexpected(1);\r
+\r
+  bad=0;\r
+  for (i=1; i < argc; i++) {\r
+    s = (wchar_t *)(argv[i]);\r
+    if (*s == L'-') {\r
+      s++;\r
+      while (*s) {\r
+        switch (*(s++)) {\r
+              case L'v': V=1; break;\r
+              case L'l': L=1; break;\r
+              case L'f': F=1; break;\r
+              default: bad=1; break;\r
+        }\r
+      }\r
+    } else if (*s == L'+') {\r
+      s++;\r
+      bad = setmode((char *)s);\r
+    } else bad= 1;\r
+  }\r
+  if (bad) {\r
+    fprintf(stderr,\r
+      "Usage: %ls [-vlf]\n  v=Verbose l=Limits.h f=Float.h\n",\r
+      (wchar_t *)(argv[0]));\r
+    exit(1);\r
+  }\r
+  if (L || F) {\r
+    co[0]= '/'; oc[0]= ' ';\r
+    co[1]= '*'; oc[1]= '*';\r
+    co[2]= ' '; oc[2]= '/';\r
+    co[3]= '\0'; oc[3]= '\0';\r
+  } else {\r
+    co[0]= '\0'; oc[0]= '\0';\r
+    V=1;\r
+  }\r
+\r
+  if (L) printf("%slimits.h%s\n", co, oc);\r
+  if (F) printf("%sfloat.h%s\n", co, oc);\r
+#ifdef ID\r
+  printf("%sProduced by enquire version %s (%s), CWI, Amsterdam\n   %s\n",\r
+         co, VERSION, ID, WEB, oc);\r
+#else\r
+  printf("%sProduced by enquire version %s, CWI, Amsterdam\n   %s %s\n",\r
+         co, VERSION,     WEB, oc);\r
+#endif\r
+\r
+#ifdef VERIFY\r
+  printf("%sVerification phase%s\n", co, oc);\r
+#endif\r
+\r
+#ifdef NO_SIG\r
+  Vprintf("%sCompiled without signal(): %s%s\n",\r
+    co,\r
+    "there's nothing that can be done if overflow occurs",\r
+    oc);\r
+#endif\r
+#ifdef NO_SC\r
+  Vprintf("%sCompiled without signed char%s\n", co, oc);\r
+#endif\r
+#ifdef NO_UC\r
+  Vprintf("%sCompiled without unsigned char%s\n", co, oc);\r
+#endif\r
+#ifdef NO_UI\r
+  Vprintf("%sCompiled without unsigned short or long%s\n", co, oc);\r
+#endif\r
+#ifdef __STDC__\r
+  Vprintf("%sCompiler claims to be ANSI C level %d%s\n",\r
+    co, __STDC__, oc);\r
+#else\r
+  Vprintf("%sCompiler does not claim to be ANSI C%s\n", co, oc);\r
+#endif\r
+  printf("\n");\r
+\r
+  long_names();\r
+  check_defines();\r
+\r
+  maxint= maximum_int();\r
+  bits_per_byte= basic();\r
+  Vprintf("\n");\r
+  if (F||V) {\r
+    fprec= fprop(bits_per_byte);\r
+    dprec= dprop(bits_per_byte);\r
+    lprec= ldprop(bits_per_byte);\r
+    efprop(fprec, dprec, lprec);\r
+    edprop(fprec, dprec, lprec);\r
+    eldprop(fprec, dprec, lprec);\r
+  }\r
+#ifndef BAD_MALLOC\r
+  if (V) {\r
+    /* An extra goody: the approximate amount of data-space */\r
+    /* Allocate store until no more available */\r
+    /* Different implementations have a different argument type\r
+       to malloc. Here we assume that it's the same type as\r
+       that which sizeof() returns */\r
+    unsigned int size;\r
+    Volatile long total;\r
+    char kmg, *ptr, *save;\r
+    char **link;\r
+\r
+    save= NULL;\r
+    size=maximum_int()/4;\r
+    total=0;\r
+    while (size!=0) {\r
+      if (setjmp(mlab) == 0) {\r
+        while ((ptr= malloc((false()?sizeof(int):size))) != (char *)NULL) {\r
+          //if (save == NULL) save= ptr; /* save the biggest chunk */\r
+          link = (char **)ptr;\r
+          if (save == NULL) {\r
+            // Save pointer to first allocated chunk\r
+            save= ptr;\r
+            *link = NULL;\r
+          }\r
+          else {\r
+            // Build list of all subsequently allocated chunks, LIFO\r
+            *link = save;\r
+            save = ptr;\r
+          }\r
+          total+=(size/2);\r
+        }\r
+      } else {\r
+        eek_a_bug("Trying to malloc all store generates a trap");\r
+      }\r
+      size/=2;\r
+    }\r
+    if (setjmp(mlab)!=0) croak(-1);\r
+\r
+    //if (save != NULL) free(save);\r
+    while(save != NULL) {\r
+      link = (char **)save;\r
+      ptr = *link;\r
+      free(save);\r
+      save = ptr;\r
+    }\r
+\r
+    total= (total+511)/512; /* Sic */ kmg= 'K';\r
+    if (total > 10000) {\r
+      total= (total+999)/1000; kmg= 'M';\r
+    }\r
+    if (total > 10000) {\r
+      total= (total+999)/1000; kmg= 'G';\r
+    }\r
+    if (total > 10000) {\r
+      total= (total+999)/1000; kmg= 'T';\r
+    }\r
+    Vprintf("%sMemory mallocatable ~= %ld %cbytes%s\n",\r
+      co, total, kmg, oc);\r
+  }\r
+#endif\r
+  farewell(bugs);\r
+  return bugs; /* To keep compilers and lint happy */\r
+}\r
+\r
+Void\r
+eek_a_bug(char *problem)\r
+{\r
+  /* The program has discovered a problem */\r
+  printf("\n%s*** WARNING: %s%s\n", co, problem, oc);\r
+  bugs++;\r
+}\r
+\r
+Void\r
+describe(char *description, char *extra)\r
+{\r
+  /* Produce the description for a #define */\r
+  printf("   %s", co);\r
+  printf(description, extra);\r
+  printf("%s\n", oc);\r
+}\r
+\r
+Void\r
+i_define(\r
+   char *desc,\r
+   char *extra,\r
+   char *sort,\r
+   char *name,\r
+   long val,\r
+   long lim,\r
+   long req,\r
+   char *mark\r
+  )\r
+{\r
+  /* Produce a #define for a signed int type */\r
+  describe(desc, extra);\r
+  if (val >= 0) {\r
+    printf("#define %s%s %ld%s\n", sort, name, val, mark);\r
+  } else if (val + lim < 0) {\r
+    /* We may not produce a constant like -1024 if the max\r
+       allowable value is 1023. It has then to be output as\r
+       -1023-1. lim is the max allowable value. */\r
+    printf("#define %s%s (%ld%s%ld%s)\n",\r
+           sort, name, -lim, mark, val+lim, mark);\r
+  } else {\r
+    printf("#define %s%s (%ld%s)\n", sort, name, val, mark);\r
+  }\r
+  /* If VERIFY is not set, val and req are just the same value;\r
+     if it is set, val is the value as calculated, and req is\r
+     the #defined constant\r
+  */\r
+  if (val != req) {\r
+    printf("%s*** Verify failed for above #define!\n", co);\r
+    printf("       Compiler has %ld for value%s\n\n", req, oc);\r
+    bugs++;\r
+  }\r
+  Vprintf("\n");\r
+}\r
+\r
+Void\r
+u_define(\r
+  char *desc,\r
+  char *extra,\r
+  char *sort,\r
+  char *name,\r
+  ulong val,\r
+  ulong req,\r
+  char *mark\r
+  )\r
+{\r
+  /* Produce a #define for an unsigned value */\r
+  describe(desc, extra);\r
+  printf("#define %s%s %lu%s%s\n", sort, name, val, U, mark);\r
+  if (val != req) {\r
+    printf("%s*** Verify failed for above #define!\n", co);\r
+    printf("       Compiler has %lu for value%s\n\n", req, oc);\r
+    bugs++;\r
+  }\r
+  Vprintf("\n");\r
+}\r
+\r
+Void f_define(\r
+  char *desc,\r
+  char *extra,\r
+  char *sort,\r
+  char *name,\r
+  int precision,\r
+  Long_double val,\r
+  char *mark\r
+  )\r
+{\r
+  /* Produce a #define for a float/double/long double */\r
+  describe(desc, extra);\r
+  if (stdc) {\r
+    printf("#define %s%s %s%s\n",\r
+           sort, name, f_rep(precision, val), mark);\r
+  } else if (*mark == 'F') {\r
+    /* non-ANSI C has no float constants, so cast the constant */\r
+    printf("#define %s%s ((float)%s)\n",\r
+           sort, name, f_rep(precision, val));\r
+  } else {\r
+    printf("#define %s%s %s\n", sort, name, f_rep(precision, val));\r
+  }\r
+  Vprintf("\n");\r
+}\r
+\r
+int\r
+floor_log(int base, Long_double x)\r
+{\r
+  /* return floor(log base(x)) */\r
+  int r=0;\r
+  while (x>=base) { r++; x/=base; }\r
+  return r;\r
+}\r
+\r
+int\r
+ceil_log(int base, Long_double x)\r
+{\r
+  int r=0;\r
+  while (x>1.0) { r++; x/=base; }\r
+  return r;\r
+}\r
+\r
+int\r
+exponent(Long_double x, Long_double *fract, int *exp)\r
+{\r
+  /* Split x into a fraction and a power of ten;\r
+     returns 0 if x is unusable, 1 otherwise.\r
+     Only used for error messages about faulty output.\r
+  */\r
+  int r=0, neg=0;\r
+  Long_double old;\r
+  *fract=0.0; *exp=0;\r
+  if (x<0.0) {\r
+    x= -x;\r
+    neg= 1;\r
+  }\r
+  if (x==0.0) return 1;\r
+  if (x>=10.0) {\r
+    while (x>=10.0) {\r
+      old=x; r++; x/=10.0;\r
+      if (old==x) return 0;\r
+    }\r
+  } else {\r
+    while (x<1.0) {\r
+      old=x; r--; x*=10.0;\r
+      if (old==x) return 0;\r
+    }\r
+  }\r
+  if (neg) *fract= -x;\r
+  else *fract= x;\r
+  *exp=r;\r
+  return 1;\r
+}\r
+\r
+char *\r
+f_rep(int precision, Long_double val)\r
+{\r
+  /* Return the floating representation of val */\r
+  static char buf[1024];\r
+  char *f1;\r
+  if (sizeof(double) == sizeof(Long_double)) {\r
+    /* Assume they're the same, and use non-stdc format */\r
+    /* This is for stdc compilers using non-stdc libraries */\r
+    f1= "%.*e";\r
+  } else {\r
+    /* It had better support Le then */\r
+    f1= "%.*Le";\r
+  }\r
+  sprintf(buf, f1, precision, val);\r
+  return buf;\r
+}\r
+\r
+Void\r
+bitpattern(char *p, unsigned int size)\r
+{\r
+  /* Printf the bit-pattern of p */\r
+  char c;\r
+  unsigned int i;\r
+  int j;\r
+\r
+  for (i=1; i<=size; i++) {\r
+    c= *p;\r
+    p++;\r
+    for (j=bits_per_byte-1; j>=0; j--)\r
+      printf("%c", (c>>j)&1 ? '1' : '0');\r
+    if (i!=size) printf(" ");\r
+  }\r
+}\r
+\r
+Void\r
+fill(char *p, int size)\r
+{\r
+  char *ab= "ABCDEFGHIJKLMNOPQRSTUVWXYZ";\r
+  int i;\r
+\r
+  for (i=0; i<size; i++)\r
+    p[i]= ab[i];\r
+}\r
+\r
+#define Order(x, mode)\\r
+   printf("%s%s ", co, mode); fill((char *)&x, sizeof(x)); \\r
+   for (i=1; i<=sizeof(x); i++) { c=((x>>(byte_size*(sizeof(x)-i)))&mask);\\r
+      putchar(c==0 ? '?' : (char)c); }\\r
+   printf("%s\n", oc);\r
+\r
+Void\r
+endian(int byte_size)\r
+{\r
+  /* Printf the byte-order used on this machine */\r
+  /*unsigned*/ short s=0;\r
+  /*unsigned*/ int j=0;\r
+  /*unsigned*/ long l=0;\r
+\r
+  unsigned int mask, i, c;\r
+\r
+  mask=0;\r
+  for (i=1; i<=(unsigned)byte_size; i++) mask= (mask<<1)|1;\r
+\r
+  if (V) {\r
+    printf("%sCHARACTER ORDER%s\n", co, oc);\r
+    Order(s, "short:");\r
+    Order(j, "int:  ");\r
+    Order(l, "long: ");\r
+  }\r
+}\r
+\r
+Void\r
+missing(char *s)\r
+{\r
+  printf("%s*** #define %s missing from limits.h%s\n", co, s, oc);\r
+  bugs++;\r
+}\r
+\r
+Void\r
+fmissing(char *s)\r
+{\r
+  printf("%s*** #define %s missing from float.h%s\n", co, s, oc);\r
+  bugs++;\r
+}\r
+\r
+/* To try and fool optimisers */\r
+int false( void ) { return 0; }\r
+\r
+#define Promoted(x) (false()?(x):(-1))\r
+#define is_signed(x) (Promoted(x) < 0)\r
+#define sign_of(x) (is_signed(x)?"signed":"unsigned")\r
+#define Signed 1\r
+#define Unsigned 0\r
+#define sgn(x) ((is_signed(x))?Signed:Unsigned)\r
+\r
+#define showtype(t, x) Vprintf("%s%s %s %s%s\n", co, t, sign_of(x), type_of((int)sizeof(x)), oc)\r
+\r
+char *type_of(int x)\r
+{\r
+  if (x == sizeof(char)) {\r
+    if (sizeof(char) == sizeof(int)) return "char/short/int";\r
+    if (sizeof(char) == sizeof(short)) return "char/short";\r
+    return "char";\r
+  }\r
+  if (x == sizeof(short)) {\r
+    if (sizeof(short) == sizeof(int)) return "short/int";\r
+    return "short";\r
+  }\r
+  if (x == sizeof(int)) {\r
+    if (sizeof(int) == sizeof(long)) return "int/long";\r
+    return "int";\r
+  }\r
+  if (x == sizeof(long)) return "long";\r
+  return "unknown-type";\r
+}\r
+\r
+char *ftype_of(int x)\r
+{\r
+  if (x == sizeof(float)) {\r
+    return "float";\r
+  }\r
+  if (x == sizeof(double)) {\r
+    if (sizeof(double) == sizeof(Long_double))\r
+      return "(long)double";\r
+    return "double";\r
+  }\r
+  if (x == sizeof(Long_double)) {\r
+    return "long double";\r
+  }\r
+  return "unknown-type";\r
+}\r
+\r
+Void typerr(char *name, int esign, int esize, int sign, int size)\r
+{\r
+  Vprintf("*** %s has wrong type: expected %s %s, found %s %s\n",\r
+    name, sign_of(esign), type_of(esize),\r
+    sign_of(sign), type_of(size));\r
+}\r
+\r
+Void ftyperr(char *name, int esize, int size)\r
+{\r
+  Vprintf("*** %s has wrong type: expected %s, found %s\n",\r
+    name, ftype_of(esize), ftype_of(size));\r
+}\r
+\r
+Void promotions( void )\r
+{\r
+  int si; long sl;\r
+  unsigned int ui;\r
+  short ss;\r
+\r
+#ifndef NO_UI\r
+  unsigned long ul;  /* if this fails, define NO_UI */\r
+  unsigned short us; /* if this fails, define NO_UI */\r
+\r
+  ul=0; us=0;\r
+#endif\r
+  /* Shut compiler warnings up: */\r
+  si=0; sl=0; ui=0; ss=0;\r
+\r
+  Vprintf("\n%sPROMOTIONS%s\n", co, oc);\r
+\r
+  /* Sanity checks. Possible warnings here; should be no problem */\r
+  if (is_signed(ui))\r
+    eek_a_bug("unsigned int promotes to signed!\n");\r
+  if (!is_signed(si))\r
+    eek_a_bug("signed int promotes to unsigned!\n");\r
+  if (!is_signed(sl))\r
+    eek_a_bug("signed long promotes to unsigned!\n");\r
+  if (sizeof(Promoted(si)) != sizeof(int))\r
+    eek_a_bug("int doesn't promote to int!\n");\r
+  if (sizeof(Promoted(sl)) != sizeof(long))\r
+    eek_a_bug("long doesn't promote to long!\n");\r
+  if (sizeof(Promoted(ss)) != sizeof(int))\r
+    eek_a_bug("short doesn't promote to int!\n");\r
+  if (sizeof(Promoted(ui)) != sizeof(int))\r
+    eek_a_bug("unsigned int doesn't promote to int!\n");\r
+#ifndef NO_UI\r
+  if (sizeof(Promoted(ul)) != sizeof(long))\r
+    eek_a_bug("unsigned long doesn't promote to long!\n");\r
+  if (is_signed(ul))\r
+    eek_a_bug("unsigned long promotes to signed!\n");\r
+#endif\r
+\r
+#ifndef NO_UI\r
+  showtype("unsigned short promotes to", Promoted(us));\r
+#endif\r
+  showtype("long+unsigned gives", sl+ui);\r
+}\r
+\r
+#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));\r
+\r
+#define fchecktype(x, n, t) if (sizeof(x) != sizeof(t)) ftyperr(n, (int)sizeof(x), (int)sizeof(t));\r
+\r
+Void check_defines( void )\r
+{\r
+  /* ensure that all #defines are present and have the correct type */\r
+#ifdef VERIFY\r
+  int usign;\r
+\r
+#ifdef NO_UI\r
+  usign= Signed;\r
+#else\r
+  /* Implementations promote unsigned short differently */\r
+  usign= is_signed((unsigned short)0);\r
+#endif\r
+\r
+  if (L) {\r
+#ifdef CHAR_BIT\r
+  checktype(CHAR_BIT, "CHAR_BIT", Signed, int);\r
+#else\r
+  missing("CHAR_BIT");\r
+#endif\r
+#ifdef CHAR_MAX\r
+  checktype(CHAR_MAX, "CHAR_MAX", Signed, int);\r
+#else\r
+  missing("CHAR_MAX");\r
+#endif\r
+#ifdef CHAR_MIN\r
+  checktype(CHAR_MIN, "CHAR_MIN", Signed, int);\r
+#else\r
+  missing("CHAR_MIN");\r
+#endif\r
+#ifdef SCHAR_MAX\r
+  checktype(SCHAR_MAX, "SCHAR_MAX", Signed, int);\r
+#else\r
+  missing("SCHAR_MAX");\r
+#endif\r
+#ifdef SCHAR_MIN\r
+  checktype(SCHAR_MIN, "SCHAR_MIN", Signed, int);\r
+#else\r
+  missing("SCHAR_MIN");\r
+#endif\r
+#ifdef UCHAR_MAX\r
+  checktype(UCHAR_MAX, "UCHAR_MAX", Signed, int);\r
+#else\r
+  missing("UCHAR_MAX");\r
+#endif\r
+#ifdef SHRT_MAX\r
+  checktype(SHRT_MAX, "SHRT_MAX", Signed, int);\r
+#else\r
+  missing("SHRT_MAX");\r
+#endif\r
+#ifdef SHRT_MIN\r
+  checktype(SHRT_MIN, "SHRT_MIN", Signed, int);\r
+#else\r
+  missing("SHRT_MIN");\r
+#endif\r
+#ifdef INT_MAX\r
+  checktype(INT_MAX, "INT_MAX", Signed, int);\r
+#else\r
+  missing("INT_MAX");\r
+#endif\r
+#ifdef INT_MIN\r
+  checktype(INT_MIN, "INT_MIN", Signed, int);\r
+#else\r
+  missing("INT_MIN");\r
+#endif\r
+#ifdef LONG_MAX\r
+  checktype(LONG_MAX, "LONG_MAX", Signed, long);\r
+#else\r
+  missing("LONG_MAX");\r
+#endif\r
+#ifdef LONG_MIN\r
+  checktype(LONG_MIN, "LONG_MIN", Signed, long);\r
+#else\r
+  missing("LONG_MIN");\r
+#endif\r
+#ifdef USHRT_MAX\r
+  checktype(USHRT_MAX, "USHRT_MAX", usign, int);\r
+#else\r
+  missing("USHRT_MAX");\r
+#endif\r
+#ifdef UINT_MAX\r
+  checktype(UINT_MAX, "UINT_MAX", Unsigned, int);\r
+#else\r
+  missing("UINT_MAX");\r
+#endif\r
+#ifdef ULONG_MAX\r
+  checktype(ULONG_MAX, "ULONG_MAX", Unsigned, long);\r
+#else\r
+  missing("ULONG_MAX");\r
+#endif\r
+  } /* if (L) */\r
+\r
+  if (F) {\r
+#ifdef FLT_RADIX\r
+  checktype(FLT_RADIX, "FLT_RADIX", Signed, int);\r
+#else\r
+  fmissing("FLT_RADIX");\r
+#endif\r
+#ifdef FLT_MANT_DIG\r
+  checktype(FLT_MANT_DIG, "FLT_MANT_DIG", Signed, int);\r
+#else\r
+  fmissing("FLT_MANT_DIG");\r
+#endif\r
+#ifdef FLT_DIG\r
+  checktype(FLT_DIG, "FLT_DIG", Signed, int);\r
+#else\r
+  fmissing("FLT_DIG");\r
+#endif\r
+#ifdef FLT_ROUNDS\r
+  checktype(FLT_ROUNDS, "FLT_ROUNDS", Signed, int);\r
+#else\r
+  fmissing("FLT_ROUNDS");\r
+#endif\r
+#ifdef FLT_EPSILON\r
+  fchecktype(FLT_EPSILON, "FLT_EPSILON", float);\r
+#else\r
+  fmissing("FLT_EPSILON");\r
+#endif\r
+#ifdef FLT_MIN_EXP\r
+  checktype(FLT_MIN_EXP, "FLT_MIN_EXP", Signed, int);\r
+#else\r
+  fmissing("FLT_MIN_EXP");\r
+#endif\r
+#ifdef FLT_MIN\r
+  fchecktype(FLT_MIN, "FLT_MIN", float);\r
+#else\r
+  fmissing("FLT_MIN");\r
+#endif\r
+#ifdef FLT_MIN_10_EXP\r
+  checktype(FLT_MIN_10_EXP, "FLT_MIN_10_EXP", Signed, int);\r
+#else\r
+  fmissing("FLT_MIN_10_EXP");\r
+#endif\r
+#ifdef FLT_MAX_EXP\r
+  checktype(FLT_MAX_EXP, "FLT_MAX_EXP", Signed, int);\r
+#else\r
+  fmissing("FLT_MAX_EXP");\r
+#endif\r
+#ifdef FLT_MAX\r
+  fchecktype(FLT_MAX, "FLT_MAX", float);\r
+#else\r
+  fmissing("FLT_MAX");\r
+#endif\r
+#ifdef FLT_MAX_10_EXP\r
+  checktype(FLT_MAX_10_EXP, "FLT_MAX_10_EXP", Signed, int);\r
+#else\r
+  fmissing("FLT_MAX_10_EXP");\r
+#endif\r
+#ifdef DBL_MANT_DIG\r
+  checktype(DBL_MANT_DIG, "DBL_MANT_DIG", Signed, int);\r
+#else\r
+  fmissing("DBL_MANT_DIG");\r
+#endif\r
+#ifdef DBL_DIG\r
+  checktype(DBL_DIG, "DBL_DIG", Signed, int);\r
+#else\r
+  fmissing("DBL_DIG");\r
+#endif\r
+#ifdef DBL_EPSILON\r
+  fchecktype(DBL_EPSILON, "DBL_EPSILON", double);\r
+#else\r
+  fmissing("DBL_EPSILON");\r
+#endif\r
+#ifdef DBL_MIN_EXP\r
+  checktype(DBL_MIN_EXP, "DBL_MIN_EXP", Signed, int);\r
+#else\r
+  fmissing("DBL_MIN_EXP");\r
+#endif\r
+#ifdef DBL_MIN\r
+  fchecktype(DBL_MIN, "DBL_MIN", double);\r
+#else\r
+  fmissing("DBL_MIN");\r
+#endif\r
+#ifdef DBL_MIN_10_EXP\r
+  checktype(DBL_MIN_10_EXP, "DBL_MIN_10_EXP", Signed, int);\r
+#else\r
+  fmissing("DBL_MIN_10_EXP");\r
+#endif\r
+#ifdef DBL_MAX_EXP\r
+  checktype(DBL_MAX_EXP, "DBL_MAX_EXP", Signed, int);\r
+#else\r
+  fmissing("DBL_MAX_EXP");\r
+#endif\r
+#ifdef DBL_MAX\r
+  fchecktype(DBL_MAX, "DBL_MAX", double);\r
+#else\r
+  fmissing("DBL_MAX");\r
+#endif\r
+#ifdef DBL_MAX_10_EXP\r
+  checktype(DBL_MAX_10_EXP, "DBL_MAX_10_EXP", Signed, int);\r
+#else\r
+  fmissing("DBL_MAX_10_EXP");\r
+#endif\r
+#ifdef STDC\r
+#ifdef LDBL_MANT_DIG\r
+  checktype(LDBL_MANT_DIG, "LDBL_MANT_DIG", Signed, int);\r
+#else\r
+  fmissing("LDBL_MANT_DIG");\r
+#endif\r
+#ifdef LDBL_DIG\r
+  checktype(LDBL_DIG, "LDBL_DIG", Signed, int);\r
+#else\r
+  fmissing("LDBL_DIG");\r
+#endif\r
+#ifdef LDBL_EPSILON\r
+  fchecktype(LDBL_EPSILON, "LDBL_EPSILON", long double);\r
+#else\r
+  fmissing("LDBL_EPSILON");\r
+#endif\r
+#ifdef LDBL_MIN_EXP\r
+  checktype(LDBL_MIN_EXP, "LDBL_MIN_EXP", Signed, int);\r
+#else\r
+  fmissing("LDBL_MIN_EXP");\r
+#endif\r
+#ifdef LDBL_MIN\r
+  fchecktype(LDBL_MIN, "LDBL_MIN", long double);\r
+#else\r
+  fmissing("LDBL_MIN");\r
+#endif\r
+#ifdef LDBL_MIN_10_EXP\r
+  checktype(LDBL_MIN_10_EXP, "LDBL_MIN_10_EXP", Signed, int);\r
+#else\r
+  fmissing("LDBL_MIN_10_EXP");\r
+#endif\r
+#ifdef LDBL_MAX_EXP\r
+  checktype(LDBL_MAX_EXP, "LDBL_MAX_EXP", Signed, int);\r
+#else\r
+  fmissing("LDBL_MAX_EXP");\r
+#endif\r
+#ifdef LDBL_MAX\r
+  fchecktype(LDBL_MAX, "LDBL_MAX", long double);\r
+#else\r
+  fmissing("LDBL_MAX");\r
+#endif\r
+#ifdef LDBL_MAX_10_EXP\r
+  checktype(LDBL_MAX_10_EXP, "LDBL_MAX_10_EXP", Signed, int);\r
+#else\r
+  fmissing("LDBL_MAX_10_EXP");\r
+#endif\r
+#endif /* STDC */\r
+  } /* if (F) */\r
+#endif /* VERIFY */\r
+}\r
+\r
+#ifdef VERIFY\r
+#ifndef SCHAR_MAX\r
+#define SCHAR_MAX char_max\r
+#endif\r
+#ifndef SCHAR_MIN\r
+#define SCHAR_MIN char_min\r
+#endif\r
+#ifndef UCHAR_MAX\r
+#define UCHAR_MAX char_max\r
+#endif\r
+#endif /* VERIFY */\r
+\r
+#ifndef CHAR_BIT\r
+#define CHAR_BIT  char_bit\r
+#endif\r
+#ifndef CHAR_MAX\r
+#define CHAR_MAX  char_max\r
+#endif\r
+#ifndef CHAR_MIN\r
+#define CHAR_MIN  char_min\r
+#endif\r
+#ifndef SCHAR_MAX\r
+#define SCHAR_MAX char_max\r
+#endif\r
+#ifndef SCHAR_MIN\r
+#define SCHAR_MIN char_min\r
+#endif\r
+#ifndef UCHAR_MAX\r
+#define UCHAR_MAX char_max\r
+#endif\r
+\r
+int cprop( void )\r
+{\r
+  /* Properties of type char */\r
+  Volatile char c, char_max, char_min;\r
+  Volatile int byte_size, c_signed;\r
+  long char_bit;\r
+\r
+  Unexpected(2);\r
+\r
+  /* Calculate number of bits per character *************************/\r
+  c=1; byte_size=0;\r
+  do { c=c<<1; byte_size++; } while(c!=0);\r
+  c= (char)(-1);\r
+  if (((int)c)<0) c_signed=1;\r
+  else c_signed=0;\r
+  Vprintf("%schar = %d bits, %ssigned%s\n",\r
+    co, (int)sizeof(c)*byte_size, (c_signed?"":"un"), oc);\r
+  char_bit=(long)(sizeof(c)*byte_size);\r
+  if (L) i_define(D_CHAR_BIT, "", "CHAR", "_BIT",\r
+      char_bit, 0L, (long) CHAR_BIT, "");\r
+\r
+  c=0; char_max=0;\r
+  c++;\r
+  if (setjmp(lab)==0) { /* Yields char_max */\r
+    while (c>char_max) {\r
+      char_max=c;\r
+      c=(char)(c*2+1);\r
+    }\r
+  } else {\r
+    Vprintf("%sCharacter overflow generates a trap!%s\n", co, oc);\r
+  }\r
+  c=0; char_min=0;\r
+  c--;\r
+  if (c<char_min) /* then the min char < 0 */ {\r
+     /* Minimum value: assume either two's or one's complement *********/\r
+    char_min= -char_max;\r
+    if (setjmp(lab)==0) { /* Yields char_min */\r
+        if (char_min-1 < char_min) char_min--;\r
+    }\r
+  }\r
+  Unexpected(8);\r
+  if (c_signed && char_min == 0) {\r
+    Vprintf("%sBEWARE! Chars are pseudo-unsigned:%s\n", co, oc);\r
+    Vprintf("%s   %s%s%s\n",\r
+      "They contain only nonnegative values, ",\r
+      "but sign extend when used as integers.", co, oc);\r
+  }\r
+  Unexpected(3);\r
+\r
+  if (L) {\r
+    /* Because of the integer promotions, you must use a U after\r
+       the MAX_CHARS in the following cases */\r
+    if ((sizeof(char) == sizeof(int)) && !c_signed) {\r
+      u_define(D_CHAR_MAX, "", "CHAR", "_MAX",\r
+         (ulong) char_max,\r
+         (ulong) CHAR_MAX, "");\r
+    } else {\r
+      i_define(D_CHAR_MAX, "", "CHAR", "_MAX",\r
+         (long) char_max, 0L,\r
+         (long) CHAR_MAX, "");\r
+    }\r
+    i_define(D_CHAR_MIN, "", "CHAR", "_MIN",\r
+       (long) char_min, (long) maxint,\r
+       (long) CHAR_MIN, "");\r
+    if (c_signed) {\r
+      i_define(D_SCHAR_MAX, "", "SCHAR", "_MAX",\r
+         (long) char_max, 0L,\r
+         (long) SCHAR_MAX, "");\r
+      i_define(D_SCHAR_MIN, "", "SCHAR", "_MIN",\r
+         (long) char_min, (long) maxint,\r
+         (long) SCHAR_MIN, "");\r
+    } else {\r
+      if (sizeof(char) == sizeof(int)) {\r
+        u_define(D_UCHAR_MAX, "", "UCHAR", "_MAX",\r
+           (ulong) char_max,\r
+           (ulong) UCHAR_MAX, "");\r
+      } else {\r
+        i_define(D_UCHAR_MAX, "", "UCHAR", "_MAX",\r
+           (long) char_max, 0L,\r
+           (long) UCHAR_MAX, "");\r
+      }\r
+    }\r
+\r
+    if (c_signed) {\r
+#ifndef NO_UC\r
+/* Syntax error? Define NO_UC */ Volatile unsigned char c1, char_max;\r
+      c1=0; char_max=0;\r
+      c1++;\r
+      if (setjmp(lab)==0) { /* Yields char_max */\r
+        while (c1>char_max) {\r
+          char_max=c1;\r
+          c1++;\r
+        }\r
+      }\r
+      Unexpected(4);\r
+      if (sizeof(char) == sizeof(int)) {\r
+        u_define(D_UCHAR_MAX, "", "UCHAR", "_MAX",\r
+           (ulong) char_max,\r
+           (ulong) UCHAR_MAX, "");\r
+      } else {\r
+        i_define(D_UCHAR_MAX, "", "UCHAR", "_MAX",\r
+           (long) char_max, 0L,\r
+           (long) UCHAR_MAX, "");\r
+      }\r
+#endif\r
+    } else {\r
+#ifndef NO_SC\r
+/* Syntax error? Define NO_SC */ Volatile signed char c1, char_max, char_min;\r
+      c1=0; char_max=0;\r
+      c1++;\r
+      if (setjmp(lab)==0) { /* Yields char_max */\r
+        while (c1>char_max) {\r
+          char_max=c1;\r
+          c1++;\r
+        }\r
+      }\r
+      c1=0; char_min=0;\r
+      c1--;\r
+      if (setjmp(lab)==0) { /* Yields char_min */\r
+        while (c1<char_min) {\r
+          char_min=c1;\r
+          c1--;\r
+        }\r
+      }\r
+      Unexpected(5);\r
+      i_define(D_SCHAR_MIN, "", "SCHAR", "_MIN",\r
+         (long) char_min, (long) maxint,\r
+         (long) SCHAR_MIN, "");\r
+      i_define(D_SCHAR_MAX, "", "SCHAR", "_MAX",\r
+         (long) char_max, 0L,\r
+         (long) SCHAR_MAX, "");\r
+#endif /* NO_SC */\r
+    }\r
+  }\r
+  return byte_size;\r
+}\r
+\r
+int basic( void )\r
+{\r
+  /* The properties of the basic types.\r
+     Returns number of bits per sizeof unit */\r
+  Volatile int byte_size;\r
+  typedef int function ();\r
+  int variable;\r
+  char *cp; int *ip; function *fp;\r
+  int *p, *q;\r
+\r
+  Vprintf("%sSIZES%s\n", co, oc);\r
+  byte_size= cprop();\r
+\r
+  /* Shorts, ints and longs *****************************************/\r
+  Vprintf("%sshort=%d int=%d long=%d float=%d double=%d bits %s\n",\r
+    co,\r
+    (int) sizeof(short)*byte_size,\r
+    (int) sizeof(int)*byte_size,\r
+    (int) sizeof(long)*byte_size,\r
+    (int) sizeof(float)*byte_size,\r
+    (int) sizeof(double)*byte_size, oc);\r
+  if (stdc) {\r
+    Vprintf("%slong double=%d bits%s\n",\r
+      co, (int) sizeof(Long_double)*byte_size, oc);\r
+  }\r
+  Vprintf("%schar*=%d bits%s%s\n",\r
+    co, (int)sizeof(char *)*byte_size,\r
+    sizeof(char *)>sizeof(int)?" BEWARE! larger than int!":"",\r
+    oc);\r
+  Vprintf("%sint* =%d bits%s%s\n",\r
+    co, (int)sizeof(int *)*byte_size,\r
+    sizeof(int *)>sizeof(int)?" BEWARE! larger than int!":"",\r
+    oc);\r
+  Vprintf("%sfunc*=%d bits%s%s\n",\r
+    co, (int)sizeof(function *)*byte_size,\r
+    sizeof(function *)>sizeof(int)?" BEWARE! larger than int!":"",\r
+    oc);\r
+\r
+  showtype("Type size_t is", sizeof(0));\r
+#ifdef STDC\r
+  showtype("Type wchar_t is", L'x');\r
+#endif\r
+\r
+  /* Alignment constants ********************************************/\r
+\r
+#define alignment(TYPE) \\r
+  ((long)((char *)&((struct{char c; TYPE d;}*)0)->d - (char *)0))\r
+\r
+  Vprintf("\n%sALIGNMENTS%s\n", co, oc);\r
+\r
+  Vprintf("%schar=%ld short=%ld int=%ld long=%ld%s\n",\r
+    co,\r
+    alignment(char), alignment(short),\r
+    alignment(int), alignment(long),\r
+    oc);\r
+\r
+  Vprintf("%sfloat=%ld double=%ld%s\n",\r
+    co,\r
+    alignment(float), alignment(double),\r
+    oc);\r
+\r
+  if (stdc) {\r
+    Vprintf("%slong double=%ld%s\n",\r
+      co,\r
+      alignment(Long_double),\r
+      oc);\r
+  }\r
+  Vprintf("%schar*=%ld int*=%ld func*=%ld%s\n",\r
+    co,\r
+    alignment(char *), alignment(int *), alignment(function *),\r
+    oc);\r
+\r
+  Vprintf("\n");\r
+\r
+  /* Ten little endians *********************************************/\r
+\r
+  endian(byte_size);\r
+\r
+  /* Pointers *******************************************************/\r
+\r
+  Vprintf("\n%sPROPERTIES OF POINTERS%s\n", co, oc);\r
+  cp= (char *) &variable;\r
+  ip= (int *) &variable;\r
+  fp= (function *) &variable;\r
+\r
+  Vprintf("%sChar and int pointer formats ", co);\r
+  if (memeq((char *) &cp, sizeof(cp), (char *) &ip, sizeof(ip))) {\r
+    Vprintf("seem identical%s\n", oc);\r
+  } else {\r
+    Vprintf("are different%s\n", oc);\r
+  }\r
+  Vprintf("%sChar and function pointer formats ", co);\r
+  if (memeq((char *) &cp, sizeof(cp), (char *) &fp, sizeof(fp))) {\r
+    Vprintf("seem identical%s\n", oc);\r
+  } else {\r
+    Vprintf("are different%s\n", oc);\r
+  }\r
+\r
+  if (V) {\r
+    if ((VOID *)"abcd" == (VOID *)"abcd")\r
+      printf("%sStrings are shared%s\n", co, oc);\r
+    else printf("%sStrings are not shared%s\n", co, oc);\r
+  }\r
+\r
+  p=0; q=0;\r
+  showtype("Type ptrdiff_t is", p-q);\r
+\r
+  //if (setjmp(mlab) == 0) {\r
+  //  variable= *p;\r
+  //  Vprintf("%sBEWARE! Dereferencing NULL doesn't cause a trap%s\n",\r
+  //    co, oc);\r
+  //} else {\r
+  //  Vprintf("%sDereferencing NULL causes a trap%s\n", co, oc);\r
+  //}\r
+  if (setjmp(mlab)!=0) croak(-2);\r
+\r
+  Vprintf("\n%sPROPERTIES OF INTEGRAL TYPES%s\n", co, oc);\r
+\r
+  sprop();\r
+  iprop();\r
+  lprop();\r
+  usprop();\r
+  uiprop();\r
+  ulprop();\r
+\r
+  promotions();\r
+\r
+  Unexpected(6);\r
+\r
+  return byte_size;\r
+}\r
+\r
+#else /* not PASS0 */\r
+\r
+#ifdef SEP\r
+/* The global variables used by several passes */\r
+extern jmp_buf lab;\r
+extern int V, L, F, bugs, bits_per_byte;\r
+extern int maxint, flt_radix, flt_rounds;\r
+extern Volatile int trapped;\r
+extern char co[], oc[];\r
+extern char *f_rep();\r
+extern Void trap1();\r
+#endif /* SEP */\r
+#endif /* ifdef PASS0 */\r
+\r
+/* As I said, I apologise for the contortions below. The functions are\r
+   expanded by the preprocessor twice or three times (for float and double,\r
+   and maybe for long double, and for short, int and long). That way,\r
+   I never make a change to one that I forget to make to the other.\r
+   You can look on it as C's fault for not supporting multi-line macros.\r
+   This whole file is read 3 times by the preprocessor, with PASSn set for\r
+   n=1, 2 or 3, to decide which parts to reprocess.\r
+*/\r
+\r
+/* #undef on an already undefined thing is (wrongly) flagged as an error\r
+   by some compilers, therefore the #ifdef that follows:\r
+*/\r
+#ifdef Number\r
+#undef Number\r
+#undef THING\r
+#undef Thing\r
+#undef thing\r
+#undef FPROP\r
+#undef Fname\r
+#undef Store\r
+#undef Sum\r
+#undef Diff\r
+#undef Mul\r
+#undef Div\r
+#undef ZERO\r
+#undef HALF\r
+#undef ONE\r
+#undef TWO\r
+#undef THREE\r
+#undef FOUR\r
+#undef Self\r
+#undef F_check\r
+#undef Verify\r
+#undef EPROP\r
+#undef MARK\r
+\r
+/* These are the float.h constants */\r
+#undef F_RADIX\r
+#undef F_MANT_DIG\r
+#undef F_DIG\r
+#undef F_ROUNDS\r
+#undef F_EPSILON\r
+#undef F_MIN_EXP\r
+#undef F_MIN\r
+#undef F_MIN_10_EXP\r
+#undef F_MAX_EXP\r
+#undef F_MAX\r
+#undef F_MAX_10_EXP\r
+#endif\r
+\r
+#ifdef Integer\r
+#undef Integer\r
+#undef INT\r
+#undef IPROP\r
+#undef Iname\r
+#undef UPROP\r
+#undef Uname\r
+#undef OK_UI\r
+#undef IMARK\r
+\r
+#undef I_MAX\r
+#undef I_MIN\r
+#undef U_MAX\r
+#endif\r
+\r
+#ifdef PASS1\r
+\r
+/* Define the things we're going to use this pass */\r
+\r
+#define Number  float\r
+#define THING "FLOAT"\r
+#define Thing "Float"\r
+#define thing "float"\r
+#define Fname "FLT"\r
+#define FPROP fprop\r
+#define Store fStore\r
+#define Sum fSum\r
+#define Diff  fDiff\r
+#define Mul fMul\r
+#define Div fDiv\r
+#define ZERO  0.0\r
+#define HALF  0.5\r
+#define ONE 1.0\r
+#define TWO 2.0\r
+#define THREE 3.0\r
+#define FOUR  4.0\r
+#define Self  fSelf\r
+#define F_check fCheck\r
+#define MARK  "F"\r
+#ifdef VERIFY\r
+#define Verify fVerify\r
+#endif\r
+\r
+#define EPROP efprop\r
+\r
+#define Integer short\r
+#define INT "short"\r
+#define IPROP sprop\r
+#define Iname "SHRT"\r
+#ifndef NO_UI\r
+#define OK_UI 1\r
+#endif\r
+#define IMARK ""\r
+\r
+#define UPROP usprop\r
+#define Uname "USHRT"\r
+\r
+#ifdef VERIFY\r
+#ifdef SHRT_MAX\r
+#define I_MAX   SHRT_MAX\r
+#endif\r
+#ifdef SHRT_MIN\r
+#define I_MIN   SHRT_MIN\r
+#endif\r
+#ifdef USHRT_MAX\r
+#define U_MAX   USHRT_MAX\r
+#endif\r
+\r
+#ifdef FLT_RADIX\r
+#define F_RADIX   FLT_RADIX\r
+#endif\r
+#ifdef FLT_MANT_DIG\r
+#define F_MANT_DIG  FLT_MANT_DIG\r
+#endif\r
+#ifdef FLT_DIG\r
+#define F_DIG   FLT_DIG\r
+#endif\r
+#ifdef FLT_ROUNDS\r
+#define F_ROUNDS  FLT_ROUNDS\r
+#endif\r
+#ifdef FLT_EPSILON\r
+#define F_EPSILON FLT_EPSILON\r
+#endif\r
+#ifdef FLT_MIN_EXP\r
+#define F_MIN_EXP FLT_MIN_EXP\r
+#endif\r
+#ifdef FLT_MIN\r
+#define F_MIN   FLT_MIN\r
+#endif\r
+#ifdef FLT_MIN_10_EXP\r
+#define F_MIN_10_EXP  FLT_MIN_10_EXP\r
+#endif\r
+#ifdef FLT_MAX_EXP\r
+#define F_MAX_EXP FLT_MAX_EXP\r
+#endif\r
+#ifdef FLT_MAX\r
+#define F_MAX   FLT_MAX\r
+#endif\r
+#ifdef FLT_MAX_10_EXP\r
+#define F_MAX_10_EXP  FLT_MAX_10_EXP\r
+#endif\r
+#endif /* VERIFY */\r
+\r
+#endif /* PASS1 */\r
+\r
+#ifdef PASS2\r
+\r
+#define Number  double\r
+#define THING "DOUBLE"\r
+#define Thing "Double"\r
+#define thing "double"\r
+#define Fname "DBL"\r
+#define FPROP dprop\r
+#define Store dStore\r
+#define Sum dSum\r
+#define Diff  dDiff\r
+#define Mul dMul\r
+#define Div dDiv\r
+#define ZERO  0.0\r
+#define HALF  0.5\r
+#define ONE 1.0\r
+#define TWO 2.0\r
+#define THREE 3.0\r
+#define FOUR  4.0\r
+#define Self  dSelf\r
+#define F_check dCheck\r
+#define MARK  ""\r
+#ifdef VERIFY\r
+#define Verify dVerify\r
+#endif\r
+\r
+#define EPROP edprop\r
+\r
+#define Integer int\r
+#define INT "int"\r
+#define IPROP iprop\r
+#define Iname "INT"\r
+#define OK_UI 1 /* Unsigned int is always possible */\r
+#define IMARK ""\r
+\r
+#define UPROP uiprop\r
+#define Uname "UINT"\r
+\r
+#ifdef VERIFY\r
+#ifdef INT_MAX\r
+#define I_MAX   INT_MAX\r
+#endif\r
+#ifdef INT_MIN\r
+#define I_MIN   INT_MIN\r
+#endif\r
+#ifdef UINT_MAX\r
+#define U_MAX   UINT_MAX\r
+#endif\r
+\r
+#ifdef DBL_MANT_DIG\r
+#define F_MANT_DIG  DBL_MANT_DIG\r
+#endif\r
+#ifdef DBL_DIG\r
+#define F_DIG   DBL_DIG\r
+#endif\r
+#ifdef DBL_EPSILON\r
+#define F_EPSILON DBL_EPSILON\r
+#endif\r
+#ifdef DBL_MIN_EXP\r
+#define F_MIN_EXP DBL_MIN_EXP\r
+#endif\r
+#ifdef DBL_MIN\r
+#define F_MIN   DBL_MIN\r
+#endif\r
+#ifdef DBL_MIN_10_EXP\r
+#define F_MIN_10_EXP  DBL_MIN_10_EXP\r
+#endif\r
+#ifdef DBL_MAX_EXP\r
+#define F_MAX_EXP DBL_MAX_EXP\r
+#endif\r
+#ifdef DBL_MAX\r
+#define F_MAX   DBL_MAX\r
+#endif\r
+#ifdef DBL_MAX_10_EXP\r
+#define F_MAX_10_EXP  DBL_MAX_10_EXP\r
+#endif\r
+#endif /* VERIFY */\r
+\r
+#endif /* PASS2 */\r
+\r
+#ifdef PASS3\r
+\r
+#ifdef STDC\r
+#define Number  long double\r
+\r
+#define ZERO  0.0L\r
+#define HALF  0.5L\r
+#define ONE 1.0L\r
+#define TWO 2.0L\r
+#define THREE 3.0L\r
+#define FOUR  4.0L\r
+#endif\r
+\r
+#define THING "LONG DOUBLE"\r
+#define Thing "Long double"\r
+#define thing "long double"\r
+#define Fname "LDBL"\r
+#define FPROP ldprop\r
+#define Store ldStore\r
+#define Sum ldSum\r
+#define Diff  ldDiff\r
+#define Mul ldMul\r
+#define Div ldDiv\r
+#define Self  ldSelf\r
+#define F_check ldCheck\r
+#define MARK  "L"\r
+#ifdef VERIFY\r
+#define Verify ldVerify\r
+#endif\r
+\r
+#define EPROP eldprop\r
+\r
+#define Integer long\r
+#define INT "long"\r
+#define IPROP lprop\r
+#define Iname "LONG"\r
+#ifndef NO_UI\r
+#define OK_UI 1\r
+#endif\r
+#define IMARK "L"\r
+\r
+#define UPROP ulprop\r
+#define Uname "ULONG"\r
+\r
+#ifdef VERIFY\r
+#ifdef LONG_MAX\r
+#define I_MAX LONG_MAX\r
+#endif\r
+#ifdef LONG_MIN\r
+#define I_MIN LONG_MIN\r
+#endif\r
+#ifdef ULONG_MAX\r
+#define U_MAX ULONG_MAX\r
+#endif\r
+\r
+#ifdef LDBL_MANT_DIG\r
+#define F_MANT_DIG  LDBL_MANT_DIG\r
+#endif\r
+#ifdef LDBL_DIG\r
+#define F_DIG   LDBL_DIG\r
+#endif\r
+#ifdef LDBL_EPSILON\r
+#define F_EPSILON LDBL_EPSILON\r
+#endif\r
+#ifdef LDBL_MIN_EXP\r
+#define F_MIN_EXP LDBL_MIN_EXP\r
+#endif\r
+#ifdef LDBL_MIN\r
+#define F_MIN   LDBL_MIN\r
+#endif\r
+#ifdef LDBL_MIN_10_EXP\r
+#define F_MIN_10_EXP  LDBL_MIN_10_EXP\r
+#endif\r
+#ifdef LDBL_MAX_EXP\r
+#define F_MAX_EXP LDBL_MAX_EXP\r
+#endif\r
+#ifdef LDBL_MAX\r
+#define F_MAX   LDBL_MAX\r
+#endif\r
+#ifdef LDBL_MAX_10_EXP\r
+#define F_MAX_10_EXP  LDBL_MAX_10_EXP\r
+#endif\r
+#endif /* VERIFY */\r
+\r
+#endif /* PASS3 */\r
+\r
+/* The rest of the file gets read all three times;\r
+   the differences are encoded in the things #defined above.\r
+*/\r
+\r
+#ifndef I_MAX\r
+#define I_MAX int_max\r
+#endif\r
+#ifndef I_MIN\r
+#define I_MIN int_min\r
+#endif\r
+#ifndef U_MAX\r
+#define U_MAX u_max\r
+#endif\r
+\r
+#ifndef F_RADIX\r
+#define F_RADIX   f_radix\r
+#endif\r
+#ifndef F_MANT_DIG\r
+#define F_MANT_DIG  f_mant_dig\r
+#endif\r
+#ifndef F_DIG\r
+#define F_DIG   f_dig\r
+#endif\r
+#ifndef F_ROUNDS\r
+#define F_ROUNDS  f_rounds\r
+#endif\r
+#ifndef F_EPSILON\r
+#define F_EPSILON f_epsilon\r
+#endif\r
+#ifndef F_MIN_EXP\r
+#define F_MIN_EXP f_min_exp\r
+#endif\r
+#ifndef F_MIN\r
+#define F_MIN   f_min\r
+#endif\r
+#ifndef F_MIN_10_EXP\r
+#define F_MIN_10_EXP  f_min_10_exp\r
+#endif\r
+#ifndef F_MAX_EXP\r
+#define F_MAX_EXP f_max_exp\r
+#endif\r
+#ifndef F_MAX\r
+#define F_MAX   f_max\r
+#endif\r
+#ifndef F_MAX_10_EXP\r
+#define F_MAX_10_EXP  f_max_10_exp\r
+#endif\r
+\r
+#ifndef VERIFY\r
+#define Verify(prec, val, req, same, same1) {;}\r
+#endif\r
+\r
+#ifdef Integer\r
+\r
+Void IPROP( void )\r
+{\r
+  /* the properties of short, int, and long */\r
+  Volatile Integer newi, int_max, maxeri, int_min, minneri;\r
+  Volatile int ibits, ipower, two=2;\r
+\r
+  /* Calculate max short/int/long ***********************************/\r
+  /* Calculate 2**n-1 until overflow - then use the previous value  */\r
+\r
+  newi=1; int_max=0;\r
+\r
+  if (setjmp(lab)==0) { /* Yields int_max */\r
+    for(ipower=0; newi>int_max; ipower++) {\r
+      int_max=newi;\r
+      newi=newi*two+1;\r
+    }\r
+    Vprintf("%sOverflow of a%s %s does not generate a trap%s\n",\r
+      co, INT[0]=='i'?"n":"", INT, oc);\r
+  } else {\r
+    Vprintf("%sOverflow of a%s %s generates a trap%s\n",\r
+      co, INT[0]=='i'?"n":"", INT, oc);\r
+  }\r
+  Unexpected(7);\r
+\r
+  /* Minimum value: assume either two's or one's complement *********/\r
+  int_min= -int_max;\r
+  if (setjmp(lab)==0) { /* Yields int_min */\r
+    if (int_min-1 < int_min) int_min--;\r
+  }\r
+  Unexpected(8);\r
+\r
+  /* Now for those daft Cybers */\r
+\r
+  maxeri=0; newi=int_max;\r
+\r
+  if (setjmp(lab)==0) { /* Yields maxeri */\r
+    for(ibits=ipower; newi>maxeri; ibits++) {\r
+      maxeri=newi;\r
+      newi=newi+newi+1;\r
+    }\r
+  }\r
+  Unexpected(9);\r
+\r
+  minneri= -maxeri;\r
+  if (setjmp(lab)==0) { /* Yields minneri */\r
+    if (minneri-1 < minneri) minneri--;\r
+  }\r
+  Unexpected(10);\r
+\r
+  Vprintf("%sMaximum %s = %ld (= 2**%d-1)%s\n",\r
+    co, INT, (long)int_max, ipower, oc);\r
+  Vprintf("%sMinimum %s = %ld%s\n", co, INT, (long)int_min, oc);\r
+\r
+  if (L) i_define(D_INT_MAX, INT, Iname, "_MAX",\r
+      (long) int_max, 0L,\r
+      (long) I_MAX, IMARK);\r
+  if (L) i_define(D_INT_MIN, INT, Iname, "_MIN",\r
+      (long) int_min, (long) (PASS==1?maxint:int_max),\r
+      (long) I_MIN, IMARK);\r
+\r
+  if(int_max < 0) { /* It has happened (on a Cray) */\r
+    eek_a_bug("signed integral comparison faulty?");\r
+  }\r
+\r
+  if (maxeri>int_max) {\r
+    Vprintf("%sThere is a larger %s, %ld (= 2**%d-1), %s %s%s\n",\r
+      co, INT, (long)maxeri, ibits,\r
+      "but only for addition, not multiplication",\r
+      "(I smell a Cyber!)",\r
+      oc);\r
+  }\r
+\r
+  if (minneri<int_min) {\r
+    Vprintf("%sThere is a smaller %s, %ld, %s %s%s\n",\r
+      co, INT, (long)minneri,\r
+      "but only for addition, not multiplication",\r
+      "(I smell a Cyber!)",\r
+      oc);\r
+  }\r
+}\r
+\r
+Void UPROP ( void )\r
+{\r
+  /* The properties of unsigned short/int/long */\r
+#ifdef OK_UI\r
+  Volatile unsigned Integer u_max, newi, two;\r
+  newi=1; u_max=0; two=2;\r
+\r
+  if (setjmp(lab)==0) { /* Yields u_max */\r
+    while(newi>u_max) {\r
+      u_max=newi;\r
+      newi=newi*two+1;\r
+    }\r
+  }\r
+  Unexpected(11);\r
+  Vprintf("%sMaximum unsigned %s = %lu%s\n",\r
+    co, INT, (unsigned long) u_max, oc);\r
+\r
+  /* Oh woe: new standard C defines value preserving promotions:\r
+     3.2.1.1: "If an int can represent all values of the original type,\r
+           the value is converted to an int;\r
+         otherwise it is converted to an unsigned int."\r
+  */\r
+  if (L) {\r
+    if (PASS == 1 /* we're dealing with short */\r
+        && u_max <= maxint /* an int can represent all values */\r
+        )\r
+    { /* the value is converted to an int */\r
+      i_define(D_UINT_MAX, INT, Uname, "_MAX",\r
+         (long) u_max, 0L,\r
+         (long) U_MAX, IMARK);\r
+    } else { /* it is converted to an unsigned int */\r
+      u_define(D_UINT_MAX, INT, Uname, "_MAX",\r
+         (unsigned long) u_max,\r
+         (unsigned long) U_MAX, IMARK);\r
+    }\r
+  }\r
+#endif\r
+}\r
+\r
+#endif /* Integer */\r
+\r
+#ifdef Number\r
+\r
+/* The following routines are intended to defeat any attempt at optimisation\r
+   or use of extended precision, and to defeat faulty narrowing casts.\r
+   The weird prototypes are because of widening incompatibilities.\r
+*/\r
+#if defined(STDC) || defined(_MSC_VER)\r
+#define ARGS1(A, a) (A a)\r
+#define ARGS2(A, a, B, b) (A a, B b)\r
+#define ARGS5(A, a, B, b, C, c, D, d, E, e) (A a, B b, C c, D d, E e)\r
+#else\r
+#define ARGS1(A, a) (a) A a;\r
+#define ARGS2(A, a, B, b) (a, b) A a; B b;\r
+#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;\r
+#endif\r
+\r
+Void Store ARGS2(Number, a, Number *, b) { *b=a; }\r
+Number Sum ARGS2(Number, a, Number, b) {Number r; Store(a+b, &r); return r; }\r
+Number Diff ARGS2(Number, a, Number, b){Number r; Store(a-b, &r); return r; }\r
+Number Mul ARGS2(Number, a, Number, b) {Number r; Store(a*b, &r); return r; }\r
+Number Div ARGS2(Number, a, Number, b) {Number r; Store(a/b, &r); return r; }\r
+Number Self ARGS1(Number, a)         {Number r; Store(a,   &r); return r; }\r
+\r
+Void F_check ARGS((int precision, Long_double val1));\r
+\r
+Void F_check(int precision, Long_double val1)\r
+{\r
+  /* You don't think I'm going to go to all the trouble of writing\r
+     a program that works out what all sorts of values are, only to\r
+     have printf go and print the wrong values out, do you?\r
+     No, you're right, so this function tries to see if printf\r
+     has written the right value, by reading it back again.\r
+     This introduces a new problem of course: suppose printf writes\r
+     the correct value, and scanf reads it back wrong... oh well.\r
+     But I'm adamant about this: the precision given is enough\r
+     to uniquely identify the printed number, therefore I insist\r
+     that sscanf read the number back identically. Harsh yes, but\r
+     sometimes you've got to be cruel to be kind.\r
+  */\r
+  Long_double new1, rem;\r
+  Number val, new, diff;\r
+  int e;\r
+  char *rep, *f2;\r
+\r
+  if (sizeof(double) == sizeof(Long_double)) {\r
+    /* Assume they're the same, and use non-stdc format */\r
+    /* This is for stdc compilers using non-stdc libraries */\r
+    f2= "%le";   /* Input */\r
+  } else {\r
+    /* It had better support Le then */\r
+    f2= "%Le";\r
+  }\r
+  val= (Number) val1;\r
+  rep= f_rep(precision, (Long_double) val);\r
+  if (setjmp(lab)==0) {\r
+    sscanf(rep, f2, &new1);\r
+  } else {\r
+    eek_a_bug("sscanf caused a trap");\r
+    printf("%s    scanning: %s format: %s%s\n\n", co, rep, f2, oc);\r
+    Unexpected(12);\r
+    return;\r
+  }\r
+\r
+  if (setjmp(lab)==0) { /* See if new is usable */\r
+    new= new1;\r
+    if (new != 0.0) {\r
+      diff= val/new - 1.0;\r
+      if (diff < 0.1) diff= 1.0;\r
+      /* That should be enough to generate a trap */\r
+    }\r
+  } else {\r
+    eek_a_bug("sscanf returned an unusable number");\r
+    printf("%s    scanning: %s with format: %s%s\n\n",\r
+           co, rep, f2, oc);\r
+    Unexpected(13);\r
+    return;\r
+  }\r
+\r
+  Unexpected(14);\r
+  if (new != val) {\r
+    eek_a_bug("Possibly bad output from printf above");\r
+    if (!exponent((Long_double)val, &rem, &e)) {\r
+      printf("%s    but value was an unusable number%s\n\n",\r
+             co, oc);\r
+      return;\r
+    }\r
+    printf("%s    expected value around ", co);\r
+    //if (sizeof(double) == sizeof(Long_double)) {\r
+      /* Assume they're the same, and use non-stdc format */\r
+      /* This is for stdc compilers using non-stdc libraries */\r
+      //printf("%.*fe%d, bit pattern:\n    ", precision, rem, e);\r
+    //} else {\r
+      /* It had better support Lfe then */\r
+      printf("%.*Lfe%d, bit pattern:\n    ", precision, rem, e);\r
+    //}\r
+    bitpattern((char *) &val, (unsigned)sizeof(val));\r
+    printf ("%s\n", oc);\r
+    printf("%s    sscanf gave           %s, bit pattern:\n    ",\r
+           co, f_rep(precision, (Long_double) new));\r
+    bitpattern((char *) &new, (unsigned)sizeof(new));\r
+    printf ("%s\n", oc);\r
+    if (setjmp(lab) == 0) {\r
+      diff= val-new;\r
+      printf("%s    difference= %s%s\n\n",\r
+             co, f_rep(precision, (Long_double) diff), oc);\r
+    } /* else forget it */\r
+    Unexpected(15);\r
+  }\r
+}\r
+\r
+#ifdef VERIFY\r
+Void Verify ARGS5(int, prec, Number, val, Number, req, int, same, int, same1)\r
+{\r
+  /* Check that the compiler has read a #define value correctly */\r
+  Unexpected(16);\r
+  if (!same) {\r
+    printf("%s*** Verify failed for above #define!\n", co);\r
+    if (setjmp(lab) == 0) { /* for the case that req == nan */\r
+      printf("       Compiler has %s for value\n",\r
+             f_rep(prec, req));\r
+    } else {\r
+      printf("       Compiler has %s for value\n",\r
+             "an unusable number");\r
+    }\r
+    if (setjmp(lab) == 0) {\r
+      F_check(prec, (Long_double) req);\r
+    } /*else forget it*/\r
+    if (setjmp(lab) == 0) {\r
+      if (req > 0.0 && val > 0.0) {\r
+        printf("       difference= %s\n",\r
+               f_rep(prec, val-req));\r
+      }\r
+    } /*else forget it*/\r
+    Unexpected(17);\r
+    printf("%s\n", oc);\r
+    bugs++;\r
+  } else if (!same1) {\r
+    if (stdc) eek_a_bug("constant has the wrong precision");\r
+    else eek_a_bug("the cast didn't work");\r
+    printf("\n");\r
+  }\r
+}\r
+#endif /* VERIFY */\r
+\r
+int FPROP(int byte_size)\r
+{\r
+  /* Properties of floating types, using algorithms by Cody and Waite\r
+     from MA Malcolm, as modified by WM Gentleman and SB Marovich.\r
+     Further extended by S Pemberton.\r
+\r
+     Returns the number of digits in the fraction.\r
+  */\r
+\r
+  Volatile int\r
+    i, f_radix, iexp, irnd, mrnd, f_rounds, f_mant_dig,\r
+    iz, k, inf, machep, f_max_exp, f_min_exp, mx, negeps,\r
+    mantbits, digs, f_dig, trap,\r
+    hidden, normal, f_min_10_exp, f_max_10_exp;\r
+  Volatile Number\r
+    a, b, base, basein, basem1, f_epsilon, epsneg,\r
+    eps, epsp1, etop, ebot,\r
+    f_max, newxmax, f_min, xminner, y, y1, z, z1, z2;\r
+\r
+  Unexpected(18);\r
+\r
+  Vprintf("%sPROPERTIES OF %s%s\n", co, THING, oc);\r
+\r
+  /* Base and size of significand **************************************/\r
+  /* First repeatedly double until adding 1 has no effect.    */\r
+  /* For instance, if base is 10, with 3 significant digits   */\r
+  /* it will try 1, 2, 4, 8, ... 512, 1024, and stop there,   */\r
+  /* since 1024 is only representable as 1020.        */\r
+  a=1.0;\r
+  if (setjmp(lab)==0) { /* inexact trap? */\r
+    do { a=Sum(a, a); }\r
+    while (Diff(Diff(Sum(a, ONE), a), ONE) == ZERO);\r
+  } else {\r
+    fprintf(stderr, "*** Program got loss-of-precision trap!\n");\r
+    /* And supporting those is just TOO much trouble! */\r
+    farewell(bugs+1);\r
+  }\r
+  Unexpected(19);\r
+  /* Now double until you find a number that can be added to the    */\r
+  /* above number. For 1020 this is 8 or 16, depending whether the  */\r
+  /* result is rounded or truncated.          */\r
+  /* In either case the result is 1030. 1030-1020= the base, 10.    */\r
+  b=1.0;\r
+  do { b=Sum(b, b); } while ((base=Diff(Sum(a, b), a)) == ZERO);\r
+  f_radix=base;\r
+  Vprintf("%sBase = %d%s\n", co, f_radix, oc);\r
+\r
+  /* Sanity check; if base<2, I can't guarantee the rest will work  */\r
+  if (f_radix < 2) {\r
+    eek_a_bug("Function return or parameter passing faulty? (This is a guess.)");\r
+    printf("\n");\r
+    return(0);\r
+  }\r
+\r
+  if (PASS == 1) { /* only for FLT */\r
+    flt_radix= f_radix;\r
+    if (F) i_define(D_FLT_RADIX, "", "FLT", "_RADIX",\r
+        (long) f_radix, 0L, (long) F_RADIX, "");\r
+  } else if (f_radix != flt_radix) {\r
+    printf("\n%s*** WARNING: %s %s (%d) %s%s\n",\r
+           co, thing, "arithmetic has a different radix",\r
+           f_radix, "from float", oc);\r
+    bugs++;\r
+  }\r
+\r
+  /* Now the number of digits precision */\r
+  f_mant_dig=0; b=1.0;\r
+  do { f_mant_dig++; b=Mul(b, base); }\r
+  while (Diff(Diff(Sum(b, ONE), b), ONE) == ZERO);\r
+  f_dig=floor_log(10, (Long_double)(b/base)) + (base==10?1:0);\r
+  Vprintf("%sSignificant base digits = %d %s %d %s%s\n",\r
+    co, f_mant_dig, "(= at least", f_dig, "decimal digits)", oc);\r
+  if (F) i_define(D_MANT_DIG, thing, Fname, "_MANT_DIG",\r
+      (long) f_mant_dig, 0L, (long) F_MANT_DIG, "");\r
+  if (F) i_define(D_DIG, thing, Fname, "_DIG",\r
+      (long) f_dig, 0L, (long) F_DIG, "");\r
+  digs= ceil_log(10, (Long_double)b); /* the number of digits to printf */\r
+\r
+  /* Rounding *******************************************************/\r
+  basem1=Diff(base, HALF);\r
+  if (Diff(Sum(a, basem1), a) != ZERO) {\r
+    if (f_radix == 2) basem1=0.375;\r
+    else basem1=1.0;\r
+    if (Diff(Sum(a, basem1), a) != ZERO) irnd=2; /* away from 0 */\r
+    else irnd=1; /* to nearest */\r
+  } else irnd=0; /* towards 0 */\r
+\r
+  basem1=Diff(base, HALF);\r
+\r
+  if (Diff(Diff(-a, basem1), -a) != ZERO) {\r
+    if (f_radix == 2) basem1=0.375;\r
+    else basem1=1.0;\r
+    if (Diff(Diff(-a, basem1), -a) != ZERO) mrnd=2; /* away from 0*/\r
+    else mrnd=1; /* to nearest */\r
+  } else mrnd=0; /* towards 0 */\r
+\r
+  f_rounds= -1; /* Unknown rounding */\r
+  if (irnd==0 && mrnd==0) f_rounds=0; /* zero = chops */\r
+  if (irnd==1 && mrnd==1) f_rounds=1; /* nearest */\r
+  if (irnd==2 && mrnd==0) f_rounds=2; /* +inf */\r
+  if (irnd==0 && mrnd==2) f_rounds=3; /* -inf */\r
+\r
+  if (f_rounds != -1) {\r
+    Vprintf("%sArithmetic rounds towards ", co);\r
+    switch (f_rounds) {\r
+          case 0: Vprintf("zero (i.e. it chops)"); break;\r
+          case 1: Vprintf("nearest"); break;\r
+          case 2: Vprintf("+infinity"); break;\r
+          case 3: Vprintf("-infinity"); break;\r
+          default: Vprintf("???"); break;\r
+    }\r
+    Vprintf("%s\n", oc);\r
+  } else { /* Hmm, try to give some help here */\r
+    Vprintf("%sArithmetic rounds oddly: %s\n", co, oc);\r
+    Vprintf("%s    Negative numbers %s%s\n",\r
+      co, mrnd==0 ? "towards zero" :\r
+          mrnd==1 ? "to nearest" :\r
+              "away from zero",\r
+      oc);\r
+    Vprintf("%s    Positive numbers %s%s\n",\r
+      co, irnd==0 ? "towards zero" :\r
+          irnd==1 ? "to nearest" :\r
+              "away from zero",\r
+      oc);\r
+  }\r
+  /* An extra goody */\r
+  if (f_radix == 2 && f_rounds == 1) {\r
+    if (Diff(Sum(a, ONE), a) != ZERO) {\r
+      Vprintf("%s   Tie breaking rounds up%s\n", co, oc);\r
+    } else if (Diff(Sum(a, THREE), a) == FOUR) {\r
+      Vprintf("%s   Tie breaking rounds to even%s\n", co, oc);\r
+    } else {\r
+      Vprintf("%s   Tie breaking rounds down%s\n", co, oc);\r
+    }\r
+  }\r
+  if (PASS == 1) { /* only for FLT */\r
+    flt_rounds= f_rounds;\r
+    if (F)\r
+      i_define(D_FLT_ROUNDS, "", "FLT", "_ROUNDS",\r
+         (long) f_rounds, 1L, (long) F_ROUNDS, "");\r
+  } else if (f_rounds != flt_rounds) {\r
+    printf("\n%s*** WARNING: %s %s (%d) %s%s\n\n",\r
+           co, thing, "arithmetic rounds differently",\r
+           f_rounds, "from float", oc);\r
+    bugs++;\r
+  }\r
+\r
+  /* Various flavours of epsilon ************************************/\r
+  negeps=f_mant_dig+f_mant_dig;\r
+  basein=1.0/base;\r
+  a=1.0;\r
+  for(i=1; i<=negeps; i++) a*=basein;\r
+\r
+  b=a;\r
+  while (Diff(Diff(ONE, a), ONE) == ZERO) {\r
+    a*=base;\r
+    negeps--;\r
+  }\r
+  negeps= -negeps;\r
+  Vprintf("%sSmallest x such that 1.0-base**x != 1.0 = %d%s\n",\r
+    co, negeps, oc);\r
+\r
+  etop = ONE;\r
+  ebot = ZERO;\r
+  eps = Sum(ebot, Div(Diff(etop, ebot), TWO));\r
+  /* find the smallest epsneg (1-epsneg != 1) by binary search.\r
+     ebot and etop are the current bounds */\r
+  while (eps != ebot && eps != etop) {\r
+    epsp1 = Diff(ONE, eps);\r
+    if (epsp1 < ONE) etop = eps;\r
+    else ebot = eps;\r
+    eps = Sum(ebot, Div(Diff(etop, ebot), TWO));\r
+  }\r
+  eps= etop;\r
+  /* Sanity check */\r
+  if (Diff(ONE, etop) >= ONE || Diff(ONE, ebot) != ONE) {\r
+    eek_a_bug("internal error calculating epsneg");\r
+  }\r
+  Vprintf("%sSmallest x such that 1.0-x != 1.0 = %s%s\n",\r
+    co, f_rep(digs, (Long_double) eps), oc);\r
+  if (V) F_check(digs, (Long_double) eps);\r
+\r
+  epsneg=a;\r
+  if ((f_radix!=2) && irnd) {\r
+  /*  a=(a*(1.0+a))/(1.0+1.0); => */\r
+    a=Div(Mul(a, Sum(ONE, a)), Sum(ONE, ONE));\r
+  /*  if ((1.0-a)-1.0 != 0.0) epsneg=a; => */\r
+    if (Diff(Diff(ONE, a), ONE) != ZERO) epsneg=a;\r
+  }\r
+  /* epsneg is used later */\r
+  Unexpected(20);\r
+\r
+  machep= -f_mant_dig-f_mant_dig;\r
+  a=b;\r
+  while (Diff(Sum(ONE, a), ONE) == ZERO) { a*=base; machep++; }\r
+  Vprintf("%sSmallest x such that 1.0+base**x != 1.0 = %d%s\n",\r
+    co, machep, oc);\r
+\r
+  etop = ONE;\r
+  ebot = ZERO;\r
+  eps = Sum(ebot, Div(Diff(etop, ebot), TWO));\r
+  /* find the smallest eps (1+eps != 1) by binary search.\r
+     ebot and etop are the current bounds */\r
+  while (eps != ebot && eps != etop) {\r
+    epsp1 = Sum(ONE, eps);\r
+    if (epsp1 > ONE) etop = eps;\r
+    else ebot = eps;\r
+    eps = Sum(ebot, Div(Diff(etop, ebot), TWO));\r
+  }\r
+  /* Sanity check */\r
+  if (Sum(ONE, etop) <= ONE || Sum(ONE, ebot) != ONE) {\r
+    eek_a_bug("internal error calculating eps");\r
+  }\r
+  f_epsilon=etop;\r
+\r
+  Vprintf("%sSmallest x such that 1.0+x != 1.0 = %s%s\n",\r
+    co, f_rep(digs, (Long_double) f_epsilon), oc);\r
+\r
+  f_epsilon= Diff(Sum(ONE, f_epsilon), ONE); /* New C standard defn */\r
+  Vprintf("%s(Above number + 1.0) - 1.0 = %s%s\n",\r
+    co, f_rep(digs, (Long_double) (f_epsilon)), oc);\r
+\r
+  /* Possible loss of precision warnings here from non-stdc compilers */\r
+  if (F) f_define(D_EPSILON, thing,\r
+      Fname, "_EPSILON", digs, (Long_double) f_epsilon, MARK);\r
+  if (V || F) F_check(digs, (Long_double) f_epsilon);\r
+  Unexpected(21);\r
+  if (F) Verify(digs, f_epsilon, F_EPSILON,\r
+          f_epsilon == Self(F_EPSILON),\r
+          (Long_double) f_epsilon == (Long_double) F_EPSILON);\r
+  Unexpected(22);\r
+\r
+  /* Extra chop info *************************************************/\r
+  if (f_rounds == 0) {\r
+    if (Diff(Mul(Sum(ONE,f_epsilon),ONE),ONE) !=  ZERO) {\r
+      Vprintf("%sAlthough arithmetic chops, it uses guard digits%s\n", co, oc);\r
+    }\r
+  }\r
+\r
+  /* Size of and minimum normalised exponent ************************/\r
+  y=0; i=0; k=1; z=basein; z1=(1.0+f_epsilon)/base;\r
+\r
+  /* Coarse search for the largest power of two */\r
+  if (setjmp(lab)==0) { /* for underflow trap */ /* Yields i, k, y, y1 */\r
+    do {\r
+      y=z; y1=z1;\r
+      z=Mul(y,y); z1=Mul(z1, y);\r
+      a=Mul(z,ONE);\r
+      z2=Div(z1,y);\r
+      if (z2 != y1) break;\r
+      if ((Sum(a,a) == ZERO) || (fabs(z) >= y)) break;\r
+      i++;\r
+      k+=k;\r
+    } while(1);\r
+  } else {\r
+    Vprintf("%s%s underflow generates a trap%s\n", co, Thing, oc);\r
+  }\r
+  Unexpected(23);\r
+\r
+  if (f_radix != 10) {\r
+    iexp=i+1; /* for the sign */\r
+    mx=k+k;\r
+  } else {\r
+    iexp=2;\r
+    iz=f_radix;\r
+    while (k >= iz) { iz*=f_radix; iexp++; }\r
+    mx=iz+iz-1;\r
+  }\r
+\r
+  /* Fine tune starting with y and y1 */\r
+  if (setjmp(lab)==0) { /* for underflow trap */ /* Yields k, f_min */\r
+    do {\r
+      f_min=y; z1=y1;\r
+      y=Div(y,base); y1=Div(y1,base);\r
+      a=Mul(y,ONE);\r
+      z2=Mul(y1,base);\r
+      if (z2 != z1) break;\r
+      if ((Sum(a,a) == ZERO) || (fabs(y) >= f_min)) break;\r
+      k++;\r
+    } while (1);\r
+  }\r
+  Unexpected(24);\r
+\r
+  f_min_exp=(-k)+1;\r
+\r
+  if ((mx <= k+k-3) && (f_radix != 10)) { mx+=mx; iexp+=1; }\r
+  Vprintf("%sNumber of bits used for exponent = %d%s\n", co, iexp, oc);\r
+  Vprintf("%sMinimum normalised exponent = %d%s\n", co, f_min_exp-1, oc);\r
+  if (F)\r
+    i_define(D_MIN_EXP, thing, Fname, "_MIN_EXP",\r
+       (long) f_min_exp, (long) maxint, (long) F_MIN_EXP, "");\r
+\r
+  if (setjmp(lab)==0) {\r
+    Vprintf("%sMinimum normalised positive number = %s%s\n",\r
+      co, f_rep(digs, (Long_double) f_min), oc);\r
+  } else {\r
+    eek_a_bug("printf can't print the smallest normalised number");\r
+    printf("\n");\r
+  }\r
+  Unexpected(25);\r
+  /* Possible loss of precision warnings here from non-stdc compilers */\r
+  if (setjmp(lab) == 0) {\r
+    if (F) f_define(D_MIN, thing,\r
+        Fname, "_MIN", digs, (Long_double) f_min, MARK);\r
+    if (V || F) F_check(digs, (Long_double) f_min);\r
+  } else {\r
+    eek_a_bug("xxx_MIN caused a trap");\r
+    printf("\n");\r
+  }\r
+\r
+  if (setjmp(lab) == 0) {\r
+    if (F) Verify(digs, f_min, F_MIN,\r
+            f_min == Self(F_MIN),\r
+            (Long_double) f_min == (Long_double) F_MIN);\r
+  } else {\r
+    printf("%s*** Verify failed for above #define!\n    %s %s\n\n",\r
+           co, "Compiler has an unusable number for value", oc);\r
+    bugs++;\r
+  }\r
+  Unexpected(26);\r
+\r
+  a=1.0; f_min_10_exp=0;\r
+  while (a > f_min*10.0) { a/=10.0; f_min_10_exp--; }\r
+  if (F) i_define(D_MIN_10_EXP, thing, Fname, "_MIN_10_EXP",\r
+      (long) f_min_10_exp, (long) maxint,\r
+      (long) F_MIN_10_EXP, "");\r
+\r
+  /* Minimum exponent ************************************************/\r
+  if (setjmp(lab)==0) { /* for underflow trap */ /* Yields xminner */\r
+    do {\r
+      xminner=y;\r
+      y=Div(y,base);\r
+      a=Mul(y,ONE);\r
+      if ((Sum(a,a) == ZERO) || (fabs(y) >= xminner)) break;\r
+    } while (1);\r
+  }\r
+  Unexpected(27);\r
+\r
+  if (xminner != 0.0 && xminner != f_min) {\r
+    normal= 0;\r
+    Vprintf("%sThe smallest numbers are not kept normalised%s\n",\r
+      co, oc);\r
+    if (setjmp(lab)==0) {\r
+        Vprintf("%sSmallest unnormalised positive number = %s%s\n",\r
+          co, f_rep(digs, (Long_double) xminner), oc);\r
+        if (V) F_check(digs, (Long_double) xminner);\r
+    } else {\r
+      eek_a_bug("printf can't print the smallest unnormalised number.");\r
+      printf("\n");\r
+    }\r
+    Unexpected(28);\r
+  } else {\r
+    normal= 1;\r
+    Vprintf("%sThe smallest numbers are normalised%s\n", co, oc);\r
+  }\r
+\r
+  /* Maximum exponent ************************************************/\r
+  f_max_exp=2; f_max=1.0; newxmax=base+1.0;\r
+  inf=0; trap=0;\r
+  while (f_max<newxmax) {\r
+    f_max=newxmax;\r
+    if (setjmp(lab) == 0) { /* Yields inf, f_max_exp */\r
+      newxmax=Mul(newxmax, base);\r
+    } else {\r
+      trap=1;\r
+      break;\r
+    }\r
+    if (Div(newxmax, base) != f_max) {\r
+      if (newxmax > f_max) inf=1; /* ieee infinity */\r
+      break;\r
+    }\r
+    f_max_exp++;\r
+  }\r
+  Unexpected(29);\r
+  Vprintf("%sMaximum exponent = %d%s\n", co, f_max_exp, oc);\r
+  if (F) i_define(D_MAX_EXP, thing, Fname, "_MAX_EXP",\r
+      (long) f_max_exp, 0L, (long) F_MAX_EXP, "");\r
+\r
+  /* Largest number ***************************************************/\r
+  f_max=Diff(ONE, epsneg);\r
+  if (Mul(f_max,ONE) != f_max) f_max=Diff(ONE, Mul(base,epsneg));\r
+  for (i=1; i<=f_max_exp; i++) f_max=Mul(f_max, base);\r
+\r
+  if (setjmp(lab)==0) {\r
+    Vprintf("%sMaximum number = %s%s\n",\r
+      co, f_rep(digs, (Long_double) f_max), oc);\r
+  } else {\r
+    eek_a_bug("printf can't print the largest double.");\r
+    printf("\n");\r
+  }\r
+  if (setjmp(lab)==0) {\r
+  /* Possible loss of precision warnings here from non-stdc compilers */\r
+    if (F) f_define(D_MAX, thing,\r
+        Fname, "_MAX", digs, (Long_double) f_max, MARK);\r
+    if (V || F) F_check(digs, (Long_double) f_max);\r
+  } else {\r
+    eek_a_bug("xxx_MAX caused a trap");\r
+    printf("\n");\r
+  }\r
+  if (setjmp(lab)==0) {\r
+    if (F) Verify(digs, f_max, F_MAX,\r
+            f_max == Self(F_MAX),\r
+            (Long_double) f_max == (Long_double) F_MAX);\r
+  } else {\r
+    printf("%s*** Verify failed for above #define!\n    %s %s\n\n",\r
+           co, "Compiler has an unusable number for value", oc);\r
+    bugs++;\r
+  }\r
+  Unexpected(30);\r
+\r
+  a=1.0; f_max_10_exp=0;\r
+  while (a < f_max/10.0) { a*=10.0; f_max_10_exp++; }\r
+  if (F) i_define(D_MAX_10_EXP, thing, Fname, "_MAX_10_EXP",\r
+      (long) f_max_10_exp, 0L, (long) F_MAX_10_EXP, "");\r
+\r
+  /* Traps and infinities ********************************************/\r
+  if (trap) {\r
+    Vprintf("%sOverflow generates a trap%s\n", co, oc);\r
+  } else {\r
+    Vprintf("%sOverflow doesn't seem to generate a trap%s\n",\r
+      co, oc);\r
+  }\r
+\r
+  if (inf) { Vprintf("%sThere is an 'infinite' value%s\n", co, oc); }\r
+\r
+#ifdef SIGFPE\r
+  signal(SIGFPE, trap1);\r
+#endif\r
+  if (setjmp(lab) == 0) {\r
+    trapped= 0; /* A global variable */\r
+    b= 0.0;\r
+    a= (1.0/b)/b;\r
+    if (!trapped) {\r
+      Vprintf("%sDivide by zero doesn't generate a trap%s\n",\r
+        co, oc);\r
+    } else {\r
+      Vprintf("%sDivide by zero generates a trap%s\n",\r
+        co, oc);\r
+      Vprintf("%sFP signal handlers return safely%s\n",\r
+        co, oc);\r
+    }\r
+  } else {\r
+    Vprintf("%sDivide by zero generates a trap%s\n", co, oc);\r
+    Vprintf("%sBEWARE! FP signal handlers can NOT return%s\n",\r
+      co, oc);\r
+  }\r
+  setsignals();\r
+  Unexpected(31);\r
+\r
+  /* Hidden bit + sanity check ****************************************/\r
+  if (f_radix != 10) {\r
+    hidden=0;\r
+    mantbits=floor_log(2, (Long_double)f_radix)*f_mant_dig;\r
+    if (mantbits+iexp == (int)sizeof(Number)*byte_size) {\r
+      hidden=1;\r
+      Vprintf("%sArithmetic uses a hidden bit%s\n", co, oc);\r
+    } else if (mantbits+iexp+1 == (int)sizeof(Number)*byte_size) {\r
+      Vprintf("%sArithmetic doesn't use a hidden bit%s\n",\r
+        co, oc);\r
+    } else if (mantbits+iexp+1 < (int)sizeof(Number)*byte_size) {\r
+      Vprintf("%sOnly %d of the %d bits of a %s %s%s\n",\r
+        co,\r
+        mantbits+iexp,\r
+        (int)sizeof(Number)*byte_size,\r
+        thing,\r
+        "are actually used",\r
+        oc);\r
+    } else {\r
+      printf("\n%s%s\n    %s (%d) %s (%d) %s %s (%d)!%s\n\n",\r
+             co,\r
+             "*** Something fishy here!",\r
+             "Exponent size",\r
+             iexp,\r
+             "+ significand size",\r
+             mantbits,\r
+             "doesn't match with the size of a",\r
+             thing,\r
+             (int)sizeof(Number)*byte_size,\r
+             oc);\r
+    }\r
+    if (hidden && f_radix == 2 && f_max_exp+f_min_exp==3) {\r
+      Vprintf("%sIt looks like %s length IEEE format%s\n",\r
+        co, f_mant_dig==24 ? "single" :\r
+            f_mant_dig==53 ? "double" :\r
+            f_mant_dig >53 ? "extended" :\r
+            "some", oc);\r
+      if (f_rounds != 1 || normal) {\r
+        Vprintf("%s   though ", co);\r
+        if (f_rounds != 1) {\r
+          Vprintf("the rounding is unusual");\r
+          if (normal) { Vprintf(" and "); }\r
+        }\r
+        if (normal) {\r
+            Vprintf("the normalisation is unusual");\r
+        }\r
+        Vprintf("%s\n", oc);\r
+      }\r
+    } else {\r
+      Vprintf("%sIt doesn't look like IEEE format%s\n",\r
+        co, oc);\r
+    }\r
+  }\r
+  printf("\n"); /* regardless of verbosity */\r
+  return f_mant_dig;\r
+}\r
+\r
+Void EPROP(int fprec, int dprec, int lprec)\r
+{\r
+  /* See if expressions are evaluated in extended precision.\r
+     Some compilers optimise even if you don't want it,\r
+     and then this function fails to produce the right result.\r
+     We try to diagnose this if it happens.\r
+  */\r
+  Volatile int eprec;\r
+  Volatile double a, b, base, old;\r
+  Volatile Number d, oldd, dbase, one, zero;\r
+  Volatile int bad=0;\r
+\r
+  /* Size of significand **************************************/\r
+  a=1.0;\r
+  if (setjmp(lab) == 0) { /* Yields nothing */\r
+    do { old=a; a=a+a; }\r
+    while ((((a+1.0)-a)-1.0) == 0.0 && a>old);\r
+  } else bad=1;\r
+  if (!bad && a <= old) bad=1;\r
+\r
+  if (!bad) {\r
+    b=1.0;\r
+    if (setjmp(lab) == 0) { /* Yields nothing */\r
+      do { old=b; b=b+b; }\r
+      while ((base=((a+b)-a)) == 0.0 && b>old);\r
+      if (b <= old) bad=1;\r
+    } else bad=1;\r
+  }\r
+\r
+  if (!bad) {\r
+    eprec=0; d=1.0; dbase=base; one=1.0; zero=0.0;\r
+    if (setjmp(lab) == 0) { /* Yields nothing */\r
+      do { eprec++; oldd=d; d=d*dbase; }\r
+      while ((((d+one)-d)-one) == zero && d>oldd);\r
+      if (d <= oldd) bad=1;\r
+    } else bad=1;\r
+  }\r
+\r
+  Unexpected(32);\r
+\r
+  if (bad) {\r
+    Vprintf("%sCan't determine precision for %s expressions:\n%s%s\n",\r
+     co, thing, "   check that you compiled without optimisation!",\r
+     oc);\r
+  } else if (eprec==dprec) {\r
+    Vprintf("%s%s expressions are evaluated in double precision%s\n",\r
+      co, Thing, oc);\r
+  } else if (eprec==fprec) {\r
+    Vprintf("%s%s expressions are evaluated in float precision%s\n",\r
+      co, Thing, oc);\r
+  } else if (eprec==lprec) {\r
+    Vprintf("%s%s expressions are evaluated in long double precision%s\n",\r
+      co, Thing, oc);\r
+  } else {\r
+    Vprintf("%s%s expressions are evaluated in a %s %s %d %s%s\n",\r
+      co, Thing, eprec>dprec ? "higher" : "lower",\r
+      "precision than double,\n   using",\r
+      eprec, "base digits",\r
+      oc);\r
+  }\r
+}\r
+\r
+#else /* not Number */\r
+\r
+#ifdef FPROP /* Then create dummy routines for long double */\r
+/* ARGSUSED */\r
+int FPROP(int byte_size) { return 0; }\r
+#endif\r
+#ifdef EPROP\r
+/* ARGSUSED */\r
+Void EPROP(int fprec, int dprec, int lprec) {}\r
+#endif\r
+\r
+#endif /* ifdef Number */\r
+\r
+/* Increment the pass number */\r
+#undef PASS\r
+\r
+#ifdef PASS2\r
+#undef PASS2\r
+#define PASS 3\r
+#define PASS3 1\r
+#endif\r
+\r
+#ifdef PASS1\r
+#undef PASS1\r
+#define PASS 2\r
+#define PASS2 1\r
+#endif\r
+\r
+#ifdef PASS0\r
+#undef PASS0\r
+#endif\r
+\r
+#ifndef SEP\r
+#ifdef PASS /* then rescan this file */\r
+#ifdef BAD_CPP\r
+#include "enquire.c"\r
+#else\r
+#include FILENAME  /* if this line fails to compile, define BAD_CPP */\r
+#endif\r
+#endif /* PASS */\r
+#endif /* SEP */\r