xref: /openbsd/regress/lib/libc/cephes/mconf.h (revision 73471bf0)
1 /*	$OpenBSD: mconf.h,v 1.3 2017/07/27 15:08:37 bluhm Exp $	*/
2 
3 /*
4  * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /*							mconf.h
20  *
21  *	Common include file for math routines
22  *
23  *
24  *
25  * SYNOPSIS:
26  *
27  * #include "mconf.h"
28  *
29  *
30  *
31  * DESCRIPTION:
32  *
33  * This file contains definitions for error codes that are
34  * passed to the common error handling routine mtherr()
35  * (which see).
36  *
37  * The file also includes a conditional assembly definition
38  * for the type of computer arithmetic (IEEE, DEC, Motorola
39  * IEEE, or UNKnown).
40  *
41  * For Digital Equipment PDP-11 and VAX computers, certain
42  * IBM systems, and others that use numbers with a 56-bit
43  * significand, the symbol DEC should be defined.  In this
44  * mode, most floating point constants are given as arrays
45  * of octal integers to eliminate decimal to binary conversion
46  * errors that might be introduced by the compiler.
47  *
48  * For little-endian computers, such as IBM PC, that follow the
49  * IEEE Standard for Binary Floating Point Arithmetic (ANSI/IEEE
50  * Std 754-1985), the symbol IBMPC should be defined.  These
51  * numbers have 53-bit significands.  In this mode, constants
52  * are provided as arrays of hexadecimal 16 bit integers.
53  *
54  * Big-endian IEEE format is denoted MIEEE.  On some RISC
55  * systems such as Sun SPARC, double precision constants
56  * must be stored on 8-byte address boundaries.  Since integer
57  * arrays may be aligned differently, the MIEEE configuration
58  * may fail on such machines.
59  *
60  * To accommodate other types of computer arithmetic, all
61  * constants are also provided in a normal decimal radix
62  * which one can hope are correctly converted to a suitable
63  * format by the available C language compiler.  To invoke
64  * this mode, define the symbol UNK.
65  *
66  * An important difference among these modes is a predefined
67  * set of machine arithmetic constants for each.  The numbers
68  * MACHEP (the machine roundoff error), MAXNUM (largest number
69  * represented), and several other parameters are preset by
70  * the configuration symbol.  Check the file const.c to
71  * ensure that these values are correct for your computer.
72  *
73  * Configurations NANS, INFINITIES, MINUSZERO, and DENORMAL
74  * may fail on many systems.  Verify that they are supposed
75  * to work on your computer.
76  */
77 
78 #include <sys/types.h>
79 #include <endian.h>
80 
81 /* Constant definitions for math error conditions
82  */
83 
84 #define DOMAIN		1	/* argument domain error */
85 #define SING		2	/* argument singularity */
86 #define OVERFLOW	3	/* overflow range error */
87 #define UNDERFLOW	4	/* underflow range error */
88 #define TLOSS		5	/* total loss of precision */
89 #define PLOSS		6	/* partial loss of precision */
90 
91 #define EDOM		33
92 #define ERANGE		34
93 
94 /* Complex numeral.  */
95 typedef struct
96 	{
97 	double r;
98 	double i;
99 	} cmplx;
100 
101 /* Long double complex numeral.  */
102 typedef struct
103 	{
104 	double r;
105 	double i;
106 	} cmplxl;
107 
108 /* Type of computer arithmetic */
109 
110 /* PDP-11, Pro350, VAX:
111  */
112 #ifdef	__vax__
113 #define DEC 1
114 #endif	/* __vax__ */
115 
116 /* Intel IEEE, low order words come first:
117  */
118 /* #define IBMPC 1 */
119 
120 /* Motorola IEEE, high order words come first
121  * (Sun 680x0 workstation):
122  */
123 /* #define MIEEE 1 */
124 
125 /* UNKnown arithmetic, invokes coefficients given in
126  * normal decimal format.  Beware of range boundary
127  * problems (MACHEP, MAXLOG, etc. in const.c) and
128  * roundoff problems in pow.c:
129  * (Sun SPARCstation)
130  */
131 #ifndef	__vax__
132 #define UNK 1
133 #endif	/* !__vax__ */
134 
135 /* If you define UNK, then be sure to set BIGENDIAN properly. */
136 #if	BYTE_ORDER == BIG_ENDIAN
137 #define BIGENDIAN 1
138 #endif	/* BYTE_ORDER == BIG_ENDIAN */
139 
140 /* Define this `volatile' if your compiler thinks
141  * that floating point arithmetic obeys the associative
142  * and distributive laws.  It will defeat some optimizations
143  * (but probably not enough of them).
144  *
145  * #define VOLATILE volatile
146  */
147 #define VOLATILE
148 
149 /* For 12-byte long doubles on an i386, pad a 16-bit short 0
150  * to the end of real constants initialized by integer arrays.
151  *
152  * #define XPD 0,
153  *
154  * Otherwise, the type is 10 bytes long and XPD should be
155  * defined blank (e.g., Microsoft C).
156  *
157  * #define XPD
158  */
159 #define XPD 0,
160 
161 /* Define to support tiny denormal numbers, else undefine. */
162 #ifndef	__vax__
163 #define DENORMAL 1
164 #endif	/* !__vax__ */
165 
166 /* Define to ask for infinity support, else undefine. */
167 #ifndef	__vax__
168 #define INFINITIES 1
169 #endif	/* !__vax__ */
170 
171 /* Define to ask for support of numbers that are Not-a-Number,
172    else undefine.  This may automatically define INFINITIES in some files. */
173 #ifndef	__vax__
174 #define NANS 1
175 #endif	/* !__vax__ */
176 
177 /* Define to distinguish between -0.0 and +0.0.  */
178 #define MINUSZERO 1
179 
180 /* Define 1 for ANSI C atan2() function
181    See atan.c and clog.c. */
182 #define ANSIC 1
183 
184 int mtherr();
185 
186 /* Variable for error reporting.  See mtherr.c.  */
187 extern int merror;
188 
189 int drand(double *);
190