OpenLIBM math.h: change __XPG_VISIBLE => __XSI_VISIBLE
[dragonfly.git] / contrib / openbsd_libm / include / global / math.h
CommitLineData
05a0b428
JM
1/* $OpenBSD: math.h,v 1.33 2014/05/03 16:13:03 martynas Exp $ */
2/*
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 *
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
9 * is preserved.
10 * ====================================================
11 */
12
13/*
14 * from: @(#)fdlibm.h 5.1 93/09/24
15 */
16
17#ifndef _MATH_H_
18#define _MATH_H_
19
74b7c7a8 20#include <sys/types.h>
05a0b428
JM
21#include <sys/limits.h>
22
23__BEGIN_DECLS
24/*
25 * ANSI/POSIX
26 */
27extern char __infinity[];
28#if __GNUC_PREREQ__(3, 3) && !defined(__vax__)
29#define HUGE_VAL __builtin_huge_val()
30#else /* __GNUC_PREREQ__(3, 3) && !__vax__ */
31#define HUGE_VAL (*(double *)(void *)__infinity)
32#endif /* __GNUC_PREREQ__(3, 3) && !__vax__ */
33
34/*
35 * C99
36 */
37#if __ISO_C_VISIBLE >= 1999
74b7c7a8
JM
38typedef double double_t;
39typedef float float_t;
05a0b428
JM
40
41#if __GNUC_PREREQ__(3, 3) && !defined(__vax__)
42#define HUGE_VALF __builtin_huge_valf()
43#define HUGE_VALL __builtin_huge_vall()
44#define INFINITY __builtin_inff()
45#define NAN __builtin_nanf("")
46#else /* __GNUC_PREREQ__(3, 3) && !__vax__ */
47#ifdef __vax__
48extern char __infinityf[];
49#define HUGE_VALF (*(float *)(void *)__infinityf)
50#else /* __vax__ */
51#define HUGE_VALF ((float)HUGE_VAL)
52#endif /* __vax__ */
53#define HUGE_VALL ((long double)HUGE_VAL)
54#define INFINITY HUGE_VALF
55#ifndef __vax__
56extern char __nan[];
57#define NAN (*(float *)(void *)__nan)
58#endif /* !__vax__ */
59#endif /* __GNUC_PREREQ__(3, 3) && !__vax__ */
60
61#define FP_INFINITE 0x01
62#define FP_NAN 0x02
63#define FP_NORMAL 0x04
64#define FP_SUBNORMAL 0x08
65#define FP_ZERO 0x10
66
67#define FP_ILOGB0 (-INT_MAX)
68#define FP_ILOGBNAN INT_MAX
69
70#define fpclassify(x) \
71 ((sizeof (x) == sizeof (float)) ? \
72 __fpclassifyf(x) \
73 : (sizeof (x) == sizeof (double)) ? \
74b7c7a8 74 __fpclassifyd(x) \
05a0b428
JM
75 : __fpclassifyl(x))
76#define isfinite(x) \
77 ((sizeof (x) == sizeof (float)) ? \
78 __isfinitef(x) \
79 : (sizeof (x) == sizeof (double)) ? \
80 __isfinite(x) \
81 : __isfinitel(x))
82#define isnormal(x) \
83 ((sizeof (x) == sizeof (float)) ? \
84 __isnormalf(x) \
85 : (sizeof (x) == sizeof (double)) ? \
86 __isnormal(x) \
87 : __isnormall(x))
88#define signbit(x) \
89 ((sizeof (x) == sizeof (float)) ? \
90 __signbitf(x) \
91 : (sizeof (x) == sizeof (double)) ? \
92 __signbit(x) \
93 : __signbitl(x))
94
95#define isgreater(x, y) (!isunordered((x), (y)) && (x) > (y))
96#define isgreaterequal(x, y) (!isunordered((x), (y)) && (x) >= (y))
97#define isless(x, y) (!isunordered((x), (y)) && (x) < (y))
98#define islessequal(x, y) (!isunordered((x), (y)) && (x) <= (y))
99#define islessgreater(x, y) (!isunordered((x), (y)) && \
100 ((x) > (y) || (y) > (x)))
101#define isunordered(x, y) (isnan(x) || isnan(y))
102#endif /* __ISO_C_VISIBLE >= 1999 */
103
104#define isinf(x) \
105 ((sizeof (x) == sizeof (float)) ? \
106 __isinff(x) \
107 : (sizeof (x) == sizeof (double)) ? \
108 __isinf(x) \
109 : __isinfl(x))
110#define isnan(x) \
111 ((sizeof (x) == sizeof (float)) ? \
112 __isnanf(x) \
113 : (sizeof (x) == sizeof (double)) ? \
114 __isnan(x) \
115 : __isnanl(x))
116
117/*
118 * XOPEN/SVID
119 */
68c3dbac 120#if __BSD_VISIBLE || __XSI_VISIBLE
05a0b428
JM
121#define M_E ((double)2.7182818284590452354) /* e */
122#define M_LOG2E ((double)1.4426950408889634074) /* log 2e */
123#define M_LOG10E ((double)0.43429448190325182765) /* log 10e */
124#define M_LN2 ((double)0.69314718055994530942) /* log e2 */
125#define M_LN10 ((double)2.30258509299404568402) /* log e10 */
126#define M_PI ((double)3.14159265358979323846) /* pi */
127#define M_PI_2 ((double)1.57079632679489661923) /* pi/2 */
128#define M_PI_4 ((double)0.78539816339744830962) /* pi/4 */
129#define M_1_PI ((double)0.31830988618379067154) /* 1/pi */
130#define M_2_PI ((double)0.63661977236758134308) /* 2/pi */
131#define M_2_SQRTPI ((double)1.12837916709551257390) /* 2/sqrt(pi) */
132#define M_SQRT2 ((double)1.41421356237309504880) /* sqrt(2) */
133#define M_SQRT1_2 ((double)0.70710678118654752440) /* 1/sqrt(2) */
134
135#ifdef __vax__
136#define MAXFLOAT ((float)1.70141173319264430e+38)
137#else
138#define MAXFLOAT ((float)3.40282346638528860e+38)
139#endif /* __vax__ */
140
141extern int signgam;
68c3dbac 142#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
05a0b428
JM
143
144#if __POSIX_VISIBLE >= 201403
145#define M_El 2.718281828459045235360287471352662498L /* e */
146#define M_LOG2El 1.442695040888963407359924681001892137L /* log 2e */
147#define M_LOG10El 0.434294481903251827651128918916605082L /* log 10e */
148#define M_LN2l 0.693147180559945309417232121458176568L /* log e2 */
149#define M_LN10l 2.302585092994045684017991454684364208L /* log e10 */
150#define M_PIl 3.141592653589793238462643383279502884L /* pi */
151#define M_PI_2l 1.570796326794896619231321691639751442L /* pi/2 */
152#define M_PI_4l 0.785398163397448309615660845819875721L /* pi/4 */
153#define M_1_PIl 0.318309886183790671537767526745028724L /* 1/pi */
154#define M_2_PIl 0.636619772367581343075535053490057448L /* 2/pi */
155#define M_2_SQRTPIl 1.128379167095512573896158903121545172L /* 2/sqrt(pi) */
156#define M_SQRT2l 1.414213562373095048801688724209698079L /* sqrt(2) */
157#define M_SQRT1_2l 0.707106781186547524400844362104849039L /* 1/sqrt(2) */
158#endif /* __POSIX_VISIBLE >= 201403 */
159
160#if __BSD_VISIBLE
161#define HUGE MAXFLOAT
162#endif /* __BSD_VISIBLE */
163
164/*
165 * ANSI/POSIX
166 */
167double acos(double);
168double asin(double);
169double atan(double);
170double atan2(double, double);
171double cos(double);
172double sin(double);
173double tan(double);
174
175double cosh(double);
176double sinh(double);
177double tanh(double);
178
179double exp(double);
180double frexp(double, int *);
181double ldexp(double, int);
182double log(double);
183double log10(double);
184double modf(double, double *);
185
186double pow(double, double);
187double sqrt(double);
188
189double ceil(double);
190double fabs(double);
191double floor(double);
192double fmod(double, double);
193
194/*
195 * C99
196 */
68c3dbac 197#if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE
05a0b428
JM
198double acosh(double);
199double asinh(double);
200double atanh(double);
201
202double exp2(double);
203double expm1(double);
204int ilogb(double);
205double log1p(double);
206double log2(double);
207double logb(double);
208double scalbn(double, int);
209double scalbln(double, long int);
210
211double cbrt(double);
212double hypot(double, double);
213
214double erf(double);
215double erfc(double);
216double lgamma(double);
217double tgamma(double);
218
219double nearbyint(double);
220double rint(double);
221long int lrint(double);
222long long int llrint(double);
223double round(double);
224long int lround(double);
225long long int llround(double);
226double trunc(double);
227
228double remainder(double, double);
229double remquo(double, double, int *);
230
231double copysign(double, double);
232double nan(const char *);
233double nextafter(double, double);
234double nexttoward(double, long double);
235
236double fdim(double, double);
237double fmax(double, double);
238double fmin(double, double);
239
240double fma(double, double, double);
68c3dbac 241#endif /* __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE */
05a0b428 242
68c3dbac 243#if __BSD_VISIBLE || __XSI_VISIBLE
05a0b428
JM
244double j0(double);
245double j1(double);
246double jn(int, double);
247double scalb(double, double);
248double y0(double);
249double y1(double);
250double yn(int, double);
68c3dbac 251#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
05a0b428 252
68c3dbac 253#if __BSD_VISIBLE || __XSI_VISIBLE <= 500
05a0b428 254double gamma(double);
68c3dbac 255#endif /* __BSD_VISIBLE || __XSI_VISIBLE <= 500 */
05a0b428
JM
256
257/*
258 * BSD math library entry points
259 */
260#if __BSD_VISIBLE
261double drem(double, double);
262int finite(double);
263
264/*
265 * Reentrant version of gamma & lgamma; passes signgam back by reference
266 * as the second argument; user must allocate space for signgam.
267 */
268double gamma_r(double, int *);
269double lgamma_r(double, int *);
270
271/*
272 * IEEE Test Vector
273 */
274double significand(double);
275#endif /* __BSD_VISIBLE */
276
277/*
278 * Float versions of C99 functions
279 */
280#if __ISO_C_VISIBLE >= 1999
281float acosf(float);
282float asinf(float);
283float atanf(float);
284float atan2f(float, float);
285float cosf(float);
286float sinf(float);
287float tanf(float);
288
289float acoshf(float);
290float asinhf(float);
291float atanhf(float);
292float coshf(float);
293float sinhf(float);
294float tanhf(float);
295
296float expf(float);
297float exp2f(float);
298float expm1f(float);
299float frexpf(float, int *);
300int ilogbf(float);
301float ldexpf(float, int);
302float logf(float);
303float log10f(float);
304float log1pf(float);
305float log2f(float);
306float logbf(float);
307float modff(float, float *);
308float scalbnf(float, int);
309float scalblnf(float, long int);
310
311float cbrtf(float);
312float fabsf(float);
313float hypotf(float, float);
314float powf(float, float);
315float sqrtf(float);
316
317float erff(float);
318float erfcf(float);
319float lgammaf(float);
320float tgammaf(float);
321
322float ceilf(float);
323float floorf(float);
324float nearbyintf(float);
325float rintf(float);
326long int lrintf(float);
327long long int llrintf(float);
328float roundf(float);
329long int lroundf(float);
330long long int llroundf(float);
331float truncf(float);
332
333float fmodf(float, float);
334float remainderf(float, float);
335float remquof(float, float, int *);
336
337float copysignf(float, float);
338float nanf(const char *);
339float nextafterf(float, float);
340float nexttowardf(float, long double);
341
342float fdimf(float, float);
343float fmaxf(float, float);
344float fminf(float, float);
345
346float fmaf(float, float, float);
347#endif /* __ISO_C_VISIBLE >= 1999 */
348
68c3dbac 349#if __BSD_VISIBLE || __XSI_VISIBLE
05a0b428
JM
350float j0f(float);
351float j1f(float);
352float jnf(int, float);
353float scalbf(float, float);
354float y0f(float);
355float y1f(float);
356float ynf(int, float);
68c3dbac 357#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
05a0b428 358
68c3dbac 359#if __BSD_VISIBLE || __XSI_VISIBLE <= 500
05a0b428 360float gammaf(float);
68c3dbac 361#endif /* __BSD_VISIBLE || __XSI_VISIBLE <= 500 */
05a0b428
JM
362
363/*
364 * Float versions of BSD math library entry points
365 */
366#if __BSD_VISIBLE
367float dremf(float, float);
368int finitef(float);
369int isinff(float);
370int isnanf(float);
371
372/*
373 * Float versions of reentrant version of gamma & lgamma; passes
374 * signgam back by reference as the second argument; user must
375 * allocate space for signgam.
376 */
377float gammaf_r(float, int *);
378float lgammaf_r(float, int *);
379
380/*
381 * Float version of IEEE Test Vector
382 */
383float significandf(float);
384#endif /* __BSD_VISIBLE */
385
386/*
387 * Long double versions of C99 functions
388 */
389#if __ISO_C_VISIBLE >= 1999
390long double acosl(long double);
391long double asinl(long double);
392long double atanl(long double);
393long double atan2l(long double, long double);
394long double cosl(long double);
395long double sinl(long double);
396long double tanl(long double);
397
398long double acoshl(long double);
399long double asinhl(long double);
400long double atanhl(long double);
401long double coshl(long double);
402long double sinhl(long double);
403long double tanhl(long double);
404
405long double expl(long double);
406long double exp2l(long double);
407long double expm1l(long double);
408long double frexpl(long double, int *);
409int ilogbl(long double);
410long double ldexpl(long double, int);
411long double logl(long double);
412long double log10l(long double);
413long double log1pl(long double);
414long double log2l(long double);
415long double logbl(long double);
416long double modfl(long double, long double *);
417long double scalbnl(long double, int);
418long double scalblnl(long double, long int);
419
420long double cbrtl(long double);
421long double fabsl(long double);
422long double hypotl(long double, long double);
423long double powl(long double, long double);
424long double sqrtl(long double);
425
426long double erfl(long double);
427long double erfcl(long double);
428long double lgammal(long double);
429long double tgammal(long double);
430
431long double ceill(long double);
432long double floorl(long double);
433long double nearbyintl(long double);
434long double rintl(long double);
435long int lrintl(long double);
436long long int llrintl(long double);
437long double roundl(long double);
438long int lroundl(long double);
439long long int llroundl(long double);
440long double truncl(long double);
441
442long double fmodl(long double, long double);
443long double remainderl(long double, long double);
444long double remquol(long double, long double, int *);
445
446long double copysignl(long double, long double);
447long double nanl(const char *);
448long double nextafterl(long double, long double);
449long double nexttowardl(long double, long double);
450
451long double fdiml(long double, long double);
452long double fmaxl(long double, long double);
453long double fminl(long double, long double);
454
455long double fmal(long double, long double, long double);
456#endif /* __ISO_C_VISIBLE >= 1999 */
457
458/*
459 * Library implementation
460 */
2fa870f1 461int __fpclassifyd(double);
05a0b428
JM
462int __fpclassifyf(float);
463int __fpclassifyl(long double);
464int __isfinite(double);
465int __isfinitef(float);
466int __isfinitel(long double);
467int __isinf(double);
468int __isinff(float);
469int __isinfl(long double);
470int __isnan(double);
471int __isnanf(float);
472int __isnanl(long double);
473int __isnormal(double);
474int __isnormalf(float);
475int __isnormall(long double);
476int __signbit(double);
477int __signbitf(float);
478int __signbitl(long double);
479
480#if __BSD_VISIBLE && defined(__vax__)
481double infnan(int);
482#endif /* __BSD_VISIBLE && defined(__vax__) */
483__END_DECLS
484
485#endif /* !_MATH_H_ */