]> git.saurik.com Git - apple/xnu.git/blame - bsd/include/math.h
xnu-201.19.3.tar.gz
[apple/xnu.git] / bsd / include / math.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/* Copyright (c) 1995 by NeXT Computer, Inc. All rights reserved. */
23/*
24 * ====================================================
25 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
26 *
27 * Developed at SunPro, a Sun Microsystems, Inc. business.
28 * Permission to use, copy, modify, and distribute this
29 * software is freely granted, provided that this notice
30 * is preserved.
31 * ====================================================
32 */
33
34#ifndef _MATH_H_
35#define _MATH_H_
36
37/*
38 * ANSI/POSIX
39 */
40#define HUGE_VAL 1e500 /* IEEE: positive infinity */
41
42/*
43 * XOPEN/SVID
44 */
45#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
46#define M_E 2.7182818284590452354 /* e */
47#define M_LOG2E 1.4426950408889634074 /* log 2e */
48#define M_LOG10E 0.43429448190325182765 /* log 10e */
49#define M_LN2 0.69314718055994530942 /* log e2 */
50#define M_LN10 2.30258509299404568402 /* log e10 */
51#define M_PI 3.14159265358979323846 /* pi */
52#define M_PI_2 1.57079632679489661923 /* pi/2 */
53#define M_PI_4 0.78539816339744830962 /* pi/4 */
54#define M_1_PI 0.31830988618379067154 /* 1/pi */
55#define M_2_PI 0.63661977236758134308 /* 2/pi */
56#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
57#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
58#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
59
60#define MAXFLOAT ((float)3.40282346638528860e+38)
61extern int signgam;
62
63#if !defined(_XOPEN_SOURCE)
64enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};
65
66#define _LIB_VERSION_TYPE enum fdversion
67#define _LIB_VERSION _fdlib_version
68
69/* if global variable _LIB_VERSION is not desirable, one may
70 * change the following to be a constant by:
71 * #define _LIB_VERSION_TYPE const enum version
72 * In that case, after one initializes the value _LIB_VERSION (see
73 * s_lib_version.c) during compile time, it cannot be modified
74 * in the middle of a program
75 */
76extern _LIB_VERSION_TYPE _LIB_VERSION;
77
78#define _IEEE_ fdlibm_ieee
79#define _SVID_ fdlibm_svid
80#define _XOPEN_ fdlibm_xopen
81#define _POSIX_ fdlibm_posix
82
83#if !defined(__cplusplus)
84struct exception {
85 int type;
86 char *name;
87 double arg1;
88 double arg2;
89 double retval;
90};
91#endif
92
93#define HUGE MAXFLOAT
94
95/*
96 * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
97 * (one may replace the following line by "#include <values.h>")
98 */
99
100#define X_TLOSS 1.41484755040568800000e+16
101
102#define DOMAIN 1
103#define SING 2
104#define OVERFLOW 3
105#define UNDERFLOW 4
106#define TLOSS 5
107#define PLOSS 6
108
109#endif /* !_XOPEN_SOURCE */
110#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
111
112
113#include <sys/cdefs.h>
114__BEGIN_DECLS
115/*
116 * ANSI/POSIX
117 */
118extern __pure double acos __P((double));
119extern __pure double asin __P((double));
120extern __pure double atan __P((double));
121extern __pure double atan2 __P((double, double));
122extern __pure double cos __P((double));
123extern __pure double sin __P((double));
124extern __pure double tan __P((double));
125
126extern __pure double cosh __P((double));
127extern __pure double sinh __P((double));
128extern __pure double tanh __P((double));
129
130extern __pure double exp __P((double));
131extern double frexp __P((double, int *));
132extern __pure double ldexp __P((double, int));
133extern __pure double log __P((double));
134extern __pure double log10 __P((double));
135extern double modf __P((double, double *));
136
137extern __pure double pow __P((double, double));
138extern __pure double sqrt __P((double));
139
140extern __pure double ceil __P((double));
141extern __pure double fabs __P((double));
142extern __pure double floor __P((double));
143extern __pure double fmod __P((double, double));
144
145#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
146extern __pure double erf __P((double));
147extern __pure double erfc __P((double));
148extern double gamma __P((double));
149extern __pure double hypot __P((double, double));
150extern __pure int isinf __P((double));
151extern __pure int isnan __P((double));
152extern __pure int finite __P((double));
153extern __pure double j0 __P((double));
154extern __pure double j1 __P((double));
155extern __pure double jn __P((int, double));
156extern double lgamma __P((double));
157extern __pure double y0 __P((double));
158extern __pure double y1 __P((double));
159extern __pure double yn __P((int, double));
160
161#if !defined(_XOPEN_SOURCE)
162extern __pure double acosh __P((double));
163extern __pure double asinh __P((double));
164extern __pure double atanh __P((double));
165extern __pure double cbrt __P((double));
166extern __pure double logb __P((double));
167extern __pure double nextafter __P((double, double));
168extern __pure double remainder __P((double, double));
169extern __pure double scalb __P((double, int));
170
171#ifndef __cplusplus
172extern int matherr __P((struct exception *));
173#endif
174
175/*
176 * IEEE Test Vector
177 */
178extern __pure double significand __P((double));
179
180/*
181 * Functions callable from C, intended to support IEEE arithmetic.
182 */
183extern __pure double copysign __P((double, double));
184extern __pure int ilogb __P((double));
185extern __pure double rint __P((double));
186extern __pure double scalbn __P((double, int));
187
188/*
189 * BSD math library entry points
190 */
191extern double cabs();
192extern __pure double drem __P((double, double));
193extern __pure double expm1 __P((double));
194extern __pure double log1p __P((double));
195
196/*
197 * Reentrant version of gamma & lgamma; passes signgam back by reference
198 * as the second argument; user must allocate space for signgam.
199 */
200#ifdef _REENTRANT
201extern double gamma_r __P((double, int *));
202extern double lgamma_r __P((double, int *));
203#endif /* _REENTRANT */
204#endif /* !_XOPEN_SOURCE */
205#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
206__END_DECLS
207
208#endif /* _MATH_H_ */