xref: /titanic_41/usr/src/lib/libbc/inc/include/math.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1988 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  */
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate /*      Copyright (c) 1984 AT&T */
27*7c478bd9Sstevel@tonic-gate /*        All Rights Reserved   */
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate /*
33*7c478bd9Sstevel@tonic-gate  * Math library definitions for all the public functions implemented in libm.a.
34*7c478bd9Sstevel@tonic-gate  */
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #ifndef	__math_h
37*7c478bd9Sstevel@tonic-gate #define	__math_h
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate /*
40*7c478bd9Sstevel@tonic-gate  * Posix (actually ansi C) section
41*7c478bd9Sstevel@tonic-gate  */
42*7c478bd9Sstevel@tonic-gate #define	HUGE_VAL	(__infinity())	/* Produces IEEE Infinity. */
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate extern double	__infinity();
46*7c478bd9Sstevel@tonic-gate extern double	acos(/* double x */);
47*7c478bd9Sstevel@tonic-gate extern double	asin(/* double x */);
48*7c478bd9Sstevel@tonic-gate extern double	atan(/* double x */);
49*7c478bd9Sstevel@tonic-gate extern double	atan2(/* double y, double x */);
50*7c478bd9Sstevel@tonic-gate extern double	ceil(/* double x */);
51*7c478bd9Sstevel@tonic-gate extern double	cos(/* double x */);
52*7c478bd9Sstevel@tonic-gate extern double	cosh(/* double x */);
53*7c478bd9Sstevel@tonic-gate extern double	exp(/* double x */);
54*7c478bd9Sstevel@tonic-gate extern double	fabs(/* double x */);
55*7c478bd9Sstevel@tonic-gate extern double	floor(/* double x */);
56*7c478bd9Sstevel@tonic-gate extern double	fmod(/* double x, double y */);
57*7c478bd9Sstevel@tonic-gate extern double	frexp(/* double value, int *exp */);
58*7c478bd9Sstevel@tonic-gate extern double	ldexp(/* double value, int exp */);
59*7c478bd9Sstevel@tonic-gate extern double	log(/* double x */);
60*7c478bd9Sstevel@tonic-gate extern double	log10(/* double x */);
61*7c478bd9Sstevel@tonic-gate extern double	modf(/* double value, double *iptr */);
62*7c478bd9Sstevel@tonic-gate extern double	pow(/* double x, double y */);
63*7c478bd9Sstevel@tonic-gate extern double	sin(/* double x */);
64*7c478bd9Sstevel@tonic-gate extern double	sinh(/* double x */);
65*7c478bd9Sstevel@tonic-gate extern double	sqrt(/* double x */);
66*7c478bd9Sstevel@tonic-gate extern double	tan(/* double x */);
67*7c478bd9Sstevel@tonic-gate extern double	tanh(/* double x */);
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate #ifndef	_POSIX_SOURCE			/* the rest of the file is !POSIX */
70*7c478bd9Sstevel@tonic-gate #include <floatingpoint.h>		/* Contains definitions for types and
71*7c478bd9Sstevel@tonic-gate 					 * functions implemented in libc.a.
72*7c478bd9Sstevel@tonic-gate 					 */
73*7c478bd9Sstevel@tonic-gate extern double	acosh();
74*7c478bd9Sstevel@tonic-gate extern double	asinh();
75*7c478bd9Sstevel@tonic-gate extern double	atanh();
76*7c478bd9Sstevel@tonic-gate extern double	cbrt();
77*7c478bd9Sstevel@tonic-gate extern double	copysign();
78*7c478bd9Sstevel@tonic-gate extern double	erf();
79*7c478bd9Sstevel@tonic-gate extern double	erfc();
80*7c478bd9Sstevel@tonic-gate extern double	expm1();
81*7c478bd9Sstevel@tonic-gate extern int	finite();
82*7c478bd9Sstevel@tonic-gate extern double	hypot();
83*7c478bd9Sstevel@tonic-gate extern double	j0();
84*7c478bd9Sstevel@tonic-gate extern double	j1();
85*7c478bd9Sstevel@tonic-gate extern double	jn();
86*7c478bd9Sstevel@tonic-gate extern double	lgamma();
87*7c478bd9Sstevel@tonic-gate extern double	log1p();
88*7c478bd9Sstevel@tonic-gate extern double	rint();
89*7c478bd9Sstevel@tonic-gate extern double	y0();
90*7c478bd9Sstevel@tonic-gate extern double	y1();
91*7c478bd9Sstevel@tonic-gate extern double	yn();
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate /*
94*7c478bd9Sstevel@tonic-gate  * Sun definitions.
95*7c478bd9Sstevel@tonic-gate  */
96*7c478bd9Sstevel@tonic-gate 
97*7c478bd9Sstevel@tonic-gate /*
98*7c478bd9Sstevel@tonic-gate  * Implemented precisions for trigonometric argument reduction.
99*7c478bd9Sstevel@tonic-gate  */
100*7c478bd9Sstevel@tonic-gate enum fp_pi_type {
101*7c478bd9Sstevel@tonic-gate 	fp_pi_infinite	= 0,	/* Infinite-precision approximation to pi. */
102*7c478bd9Sstevel@tonic-gate 	fp_pi_66	= 1,	/* 66-bit approximation to pi. */
103*7c478bd9Sstevel@tonic-gate 	fp_pi_53	= 2	/* 53-bit approximation to pi. */
104*7c478bd9Sstevel@tonic-gate };
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate /*
107*7c478bd9Sstevel@tonic-gate  * Pi precision to use for trigonometric argument reduction.
108*7c478bd9Sstevel@tonic-gate  */
109*7c478bd9Sstevel@tonic-gate extern enum	fp_pi_type fp_pi;
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate /*
112*7c478bd9Sstevel@tonic-gate  * Functions callable from C, intended to support IEEE arithmetic.
113*7c478bd9Sstevel@tonic-gate  */
114*7c478bd9Sstevel@tonic-gate extern enum	fp_class_type fp_class();
115*7c478bd9Sstevel@tonic-gate extern int	ieee_flags();
116*7c478bd9Sstevel@tonic-gate extern int	ieee_handler();
117*7c478bd9Sstevel@tonic-gate extern void	ieee_retrospective();
118*7c478bd9Sstevel@tonic-gate extern int	ilogb();
119*7c478bd9Sstevel@tonic-gate extern double	infinity();
120*7c478bd9Sstevel@tonic-gate extern int	irint();
121*7c478bd9Sstevel@tonic-gate extern int	isinf();
122*7c478bd9Sstevel@tonic-gate extern int	isnan();
123*7c478bd9Sstevel@tonic-gate extern int	isnormal();
124*7c478bd9Sstevel@tonic-gate extern int	issubnormal();
125*7c478bd9Sstevel@tonic-gate extern int	iszero();
126*7c478bd9Sstevel@tonic-gate extern double	logb();
127*7c478bd9Sstevel@tonic-gate extern double	max_normal();
128*7c478bd9Sstevel@tonic-gate extern double	max_subnormal();
129*7c478bd9Sstevel@tonic-gate extern double	min_normal();
130*7c478bd9Sstevel@tonic-gate extern double	min_subnormal();
131*7c478bd9Sstevel@tonic-gate extern double	nextafter();
132*7c478bd9Sstevel@tonic-gate extern void	nonstandard_arithmetic();
133*7c478bd9Sstevel@tonic-gate extern double	quiet_nan();
134*7c478bd9Sstevel@tonic-gate extern double	remainder();
135*7c478bd9Sstevel@tonic-gate extern double	scalb();
136*7c478bd9Sstevel@tonic-gate extern double	scalbn();
137*7c478bd9Sstevel@tonic-gate extern double	signaling_nan();
138*7c478bd9Sstevel@tonic-gate extern int	signbit();
139*7c478bd9Sstevel@tonic-gate extern double	significand();
140*7c478bd9Sstevel@tonic-gate extern void	standard_arithmetic();
141*7c478bd9Sstevel@tonic-gate 
142*7c478bd9Sstevel@tonic-gate /*
143*7c478bd9Sstevel@tonic-gate  * Other functions for C programmers.
144*7c478bd9Sstevel@tonic-gate  */
145*7c478bd9Sstevel@tonic-gate extern double	acospi();
146*7c478bd9Sstevel@tonic-gate extern double	aint();
147*7c478bd9Sstevel@tonic-gate extern double	anint();
148*7c478bd9Sstevel@tonic-gate extern double	annuity();
149*7c478bd9Sstevel@tonic-gate extern double	asinpi();
150*7c478bd9Sstevel@tonic-gate extern double	atan2pi();
151*7c478bd9Sstevel@tonic-gate extern double	atanpi();
152*7c478bd9Sstevel@tonic-gate extern double	compound();
153*7c478bd9Sstevel@tonic-gate extern double	cospi();
154*7c478bd9Sstevel@tonic-gate extern double	exp10();
155*7c478bd9Sstevel@tonic-gate extern double	exp2();
156*7c478bd9Sstevel@tonic-gate extern double	log2();
157*7c478bd9Sstevel@tonic-gate extern int	nint();
158*7c478bd9Sstevel@tonic-gate extern void	sincos();
159*7c478bd9Sstevel@tonic-gate extern void	sincospi();
160*7c478bd9Sstevel@tonic-gate extern double	sinpi();
161*7c478bd9Sstevel@tonic-gate extern double	tanpi();
162*7c478bd9Sstevel@tonic-gate extern int	matherr();
163*7c478bd9Sstevel@tonic-gate 
164*7c478bd9Sstevel@tonic-gate 
165*7c478bd9Sstevel@tonic-gate /*
166*7c478bd9Sstevel@tonic-gate  *	Single-precision functions callable from Fortran, Pascal, Modula-2, etc,
167*7c478bd9Sstevel@tonic-gate  *	take float* arguments instead of double and
168*7c478bd9Sstevel@tonic-gate  *	return FLOATFUNCTIONTYPE results instead of double.
169*7c478bd9Sstevel@tonic-gate  *	RETURNFLOAT is used to return a float function value without conversion
170*7c478bd9Sstevel@tonic-gate  *	to double.
171*7c478bd9Sstevel@tonic-gate  *	ASSIGNFLOAT is used to get the float value out of a FLOATFUNCTIONTYPE
172*7c478bd9Sstevel@tonic-gate  *	result.
173*7c478bd9Sstevel@tonic-gate  *	We don't want you to have to think about -fsingle2.
174*7c478bd9Sstevel@tonic-gate  *
175*7c478bd9Sstevel@tonic-gate  *	Some internal library functions pass float parameters as 32-bit values,
176*7c478bd9Sstevel@tonic-gate  *	disguised as FLOATPARAMETER.  FLOATPARAMETERVALUE(x) extracts the
177*7c478bd9Sstevel@tonic-gate  *	float value from the FLOATPARAMETER.
178*7c478bd9Sstevel@tonic-gate  */
179*7c478bd9Sstevel@tonic-gate 
180*7c478bd9Sstevel@tonic-gate /*	mc68000 returns float results in d0, same as int	*/
181*7c478bd9Sstevel@tonic-gate 
182*7c478bd9Sstevel@tonic-gate #ifdef	mc68000
183*7c478bd9Sstevel@tonic-gate #define	FLOATFUNCTIONTYPE	int
184*7c478bd9Sstevel@tonic-gate #define	RETURNFLOAT(x) 		return (*(int *)(&(x)))
185*7c478bd9Sstevel@tonic-gate #define	ASSIGNFLOAT(x,y)	*(int *)(&x) = y
186*7c478bd9Sstevel@tonic-gate #endif
187*7c478bd9Sstevel@tonic-gate 
188*7c478bd9Sstevel@tonic-gate /*	sparc returns float results in %f0, same as top half of double	*/
189*7c478bd9Sstevel@tonic-gate 
190*7c478bd9Sstevel@tonic-gate #ifdef	sparc
191*7c478bd9Sstevel@tonic-gate #define	FLOATFUNCTIONTYPE	double
192*7c478bd9Sstevel@tonic-gate #define	RETURNFLOAT(x) 		{ union {double _d; float _f } _kluge; _kluge._f = (x); return _kluge._d; }
193*7c478bd9Sstevel@tonic-gate #define	ASSIGNFLOAT(x,y)	{ union {double _d; float _f } _kluge; _kluge._d = (y); x = _kluge._f; }
194*7c478bd9Sstevel@tonic-gate #endif
195*7c478bd9Sstevel@tonic-gate 
196*7c478bd9Sstevel@tonic-gate /*	i386 returns float results on stack as extendeds, same as double */
197*7c478bd9Sstevel@tonic-gate 
198*7c478bd9Sstevel@tonic-gate #ifdef	i386
199*7c478bd9Sstevel@tonic-gate #define	FLOATFUNCTIONTYPE	float
200*7c478bd9Sstevel@tonic-gate #define	RETURNFLOAT(x) 		return (x)
201*7c478bd9Sstevel@tonic-gate #define	ASSIGNFLOAT(x,y)	x = y
202*7c478bd9Sstevel@tonic-gate #endif
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate /* So far everybody passes float parameters as 32 bits on stack, same as int. */
205*7c478bd9Sstevel@tonic-gate 
206*7c478bd9Sstevel@tonic-gate #define	FLOATPARAMETER		int
207*7c478bd9Sstevel@tonic-gate #define	FLOATPARAMETERVALUE(x)	(*(float *)(&(x)))
208*7c478bd9Sstevel@tonic-gate 
209*7c478bd9Sstevel@tonic-gate extern int		 ir_finite_();
210*7c478bd9Sstevel@tonic-gate extern enum fp_class_type ir_fp_class_();
211*7c478bd9Sstevel@tonic-gate extern int		 ir_ilogb_();
212*7c478bd9Sstevel@tonic-gate extern int		 ir_irint_();
213*7c478bd9Sstevel@tonic-gate extern int		 ir_isinf_();
214*7c478bd9Sstevel@tonic-gate extern int		 ir_isnan_();
215*7c478bd9Sstevel@tonic-gate extern int		 ir_isnormal_();
216*7c478bd9Sstevel@tonic-gate extern int		 ir_issubnormal_();
217*7c478bd9Sstevel@tonic-gate extern int		 ir_iszero_();
218*7c478bd9Sstevel@tonic-gate extern int		 ir_nint_();
219*7c478bd9Sstevel@tonic-gate extern int		 ir_signbit_();
220*7c478bd9Sstevel@tonic-gate extern void		 r_sincos_();
221*7c478bd9Sstevel@tonic-gate extern void		 r_sincospi_();
222*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_acos_();
223*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_acosh_();
224*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_acospi_();
225*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_aint_();
226*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_anint_();
227*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_annuity_();
228*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_asin_();
229*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_asinh_();
230*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_asinpi_();
231*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_atan2_();
232*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_atan2pi_();
233*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_atan_();
234*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_atanh_();
235*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_atanpi_();
236*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_cbrt_();
237*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_ceil_();
238*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_compound_();
239*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_copysign_();
240*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_cos_();
241*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_cosh_();
242*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_cospi_();
243*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_erf_();
244*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_erfc_();
245*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_exp10_();
246*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_exp2_();
247*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_exp_();
248*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_expm1_();
249*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_fabs_();
250*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_floor_();
251*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_fmod_();
252*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_hypot_();
253*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_infinity_();
254*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_j0_();
255*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_j1_();
256*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_jn_();
257*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_lgamma_();
258*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_log10_();
259*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_log1p_();
260*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_log2_();
261*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_log_();
262*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_logb_();
263*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_max_normal_();
264*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_max_subnormal_();
265*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_min_normal_();
266*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_min_subnormal_();
267*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_nextafter_();
268*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_pow_();
269*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_quiet_nan_();
270*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_remainder_();
271*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_rint_();
272*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_scalb_();
273*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_scalbn_();
274*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_signaling_nan_();
275*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_significand_();
276*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_sin_();
277*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_sinh_();
278*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_sinpi_();
279*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_sqrt_();
280*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_tan_();
281*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_tanh_();
282*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_tanpi_();
283*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_y0_();
284*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_y1_();
285*7c478bd9Sstevel@tonic-gate extern FLOATFUNCTIONTYPE r_yn_();
286*7c478bd9Sstevel@tonic-gate 
287*7c478bd9Sstevel@tonic-gate /* 	Constants, variables, and functions from System V */
288*7c478bd9Sstevel@tonic-gate 
289*7c478bd9Sstevel@tonic-gate #define	_ABS(x) ((x) < 0 ? -(x) : (x))
290*7c478bd9Sstevel@tonic-gate 
291*7c478bd9Sstevel@tonic-gate #define	HUGE		(infinity())	/* For historical compatibility. */
292*7c478bd9Sstevel@tonic-gate 
293*7c478bd9Sstevel@tonic-gate #define	DOMAIN		1
294*7c478bd9Sstevel@tonic-gate #define	SING		2
295*7c478bd9Sstevel@tonic-gate #define	OVERFLOW	3
296*7c478bd9Sstevel@tonic-gate #define	UNDERFLOW	4
297*7c478bd9Sstevel@tonic-gate #define	TLOSS		5
298*7c478bd9Sstevel@tonic-gate #define	PLOSS		6
299*7c478bd9Sstevel@tonic-gate 
300*7c478bd9Sstevel@tonic-gate struct exception {
301*7c478bd9Sstevel@tonic-gate 	int type;
302*7c478bd9Sstevel@tonic-gate 	char *name;
303*7c478bd9Sstevel@tonic-gate 	double arg1;
304*7c478bd9Sstevel@tonic-gate 	double arg2;
305*7c478bd9Sstevel@tonic-gate 	double retval;
306*7c478bd9Sstevel@tonic-gate };
307*7c478bd9Sstevel@tonic-gate 
308*7c478bd9Sstevel@tonic-gate /*
309*7c478bd9Sstevel@tonic-gate  * First three have to be defined exactly as in values.h including spacing!
310*7c478bd9Sstevel@tonic-gate  */
311*7c478bd9Sstevel@tonic-gate #define	M_LN2	0.69314718055994530942
312*7c478bd9Sstevel@tonic-gate #define	M_PI	3.14159265358979323846
313*7c478bd9Sstevel@tonic-gate #define	M_SQRT2	1.41421356237309504880
314*7c478bd9Sstevel@tonic-gate 
315*7c478bd9Sstevel@tonic-gate #define	M_E		2.7182818284590452354
316*7c478bd9Sstevel@tonic-gate #define	M_LOG2E		1.4426950408889634074
317*7c478bd9Sstevel@tonic-gate #define	M_LOG10E	0.43429448190325182765
318*7c478bd9Sstevel@tonic-gate #define	M_LN10		2.30258509299404568402
319*7c478bd9Sstevel@tonic-gate #define	M_PI_2		1.57079632679489661923
320*7c478bd9Sstevel@tonic-gate #define	M_PI_4		0.78539816339744830962
321*7c478bd9Sstevel@tonic-gate #define	M_1_PI		0.31830988618379067154
322*7c478bd9Sstevel@tonic-gate #define	M_2_PI		0.63661977236758134308
323*7c478bd9Sstevel@tonic-gate #define	M_2_SQRTPI	1.12837916709551257390
324*7c478bd9Sstevel@tonic-gate #define	M_SQRT1_2	0.70710678118654752440
325*7c478bd9Sstevel@tonic-gate #define	_REDUCE(TYPE, X, XN, C1, C2)	{ \
326*7c478bd9Sstevel@tonic-gate 	double x1 = (double)(TYPE)X, x2 = X - x1; \
327*7c478bd9Sstevel@tonic-gate 	X = x1 - (XN) * (C1); X += x2; X -= (XN) * (C2); }
328*7c478bd9Sstevel@tonic-gate #define	_POLY1(x, c)    ((c)[0] * (x) + (c)[1])
329*7c478bd9Sstevel@tonic-gate #define	_POLY2(x, c)    (_POLY1((x), (c)) * (x) + (c)[2])
330*7c478bd9Sstevel@tonic-gate #define	_POLY3(x, c)    (_POLY2((x), (c)) * (x) + (c)[3])
331*7c478bd9Sstevel@tonic-gate #define	_POLY4(x, c)    (_POLY3((x), (c)) * (x) + (c)[4])
332*7c478bd9Sstevel@tonic-gate #define	_POLY5(x, c)    (_POLY4((x), (c)) * (x) + (c)[5])
333*7c478bd9Sstevel@tonic-gate #define	_POLY6(x, c)    (_POLY5((x), (c)) * (x) + (c)[6])
334*7c478bd9Sstevel@tonic-gate #define	_POLY7(x, c)    (_POLY6((x), (c)) * (x) + (c)[7])
335*7c478bd9Sstevel@tonic-gate #define	_POLY8(x, c)    (_POLY7((x), (c)) * (x) + (c)[8])
336*7c478bd9Sstevel@tonic-gate #define	_POLY9(x, c)    (_POLY8((x), (c)) * (x) + (c)[9])
337*7c478bd9Sstevel@tonic-gate 
338*7c478bd9Sstevel@tonic-gate extern int	signgam;
339*7c478bd9Sstevel@tonic-gate /*
340*7c478bd9Sstevel@tonic-gate  *	Deprecated functions for compatibility with past.
341*7c478bd9Sstevel@tonic-gate  *	Changes planned for future.
342*7c478bd9Sstevel@tonic-gate  */
343*7c478bd9Sstevel@tonic-gate 
344*7c478bd9Sstevel@tonic-gate extern double cabs();	/* Use double hypot(x,y)
345*7c478bd9Sstevel@tonic-gate 			 * Traditional cabs usage is confused -
346*7c478bd9Sstevel@tonic-gate 			 * is its argument two doubles or one struct?
347*7c478bd9Sstevel@tonic-gate 			 */
348*7c478bd9Sstevel@tonic-gate extern double drem();	/* Use double remainder(x,y)
349*7c478bd9Sstevel@tonic-gate 			 * drem will disappear in a future release.
350*7c478bd9Sstevel@tonic-gate 			 */
351*7c478bd9Sstevel@tonic-gate extern double gamma();	/* Use double lgamma(x)
352*7c478bd9Sstevel@tonic-gate 			 * to compute log of gamma function.
353*7c478bd9Sstevel@tonic-gate 			 * Name gamma is reserved for true gamma function
354*7c478bd9Sstevel@tonic-gate 			 * to appear in a future release.
355*7c478bd9Sstevel@tonic-gate 			 */
356*7c478bd9Sstevel@tonic-gate #endif	/* !_POSIX_SOURCE */
357*7c478bd9Sstevel@tonic-gate #endif	/* !__math_h */
358