tzsetup: Fix VERBOSE reporting when removing _PATH_LOCALTIME for UTC.
[dragonfly.git] / include / math.h
CommitLineData
b34b60bc
JS
1/*
2 * ====================================================
3 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
4 *
5 * Developed at SunPro, a Sun Microsystems, Inc. business.
6 * Permission to use, copy, modify, and distribute this
7 * software is freely granted, provided that this notice
8 * is preserved.
9 * ====================================================
10 *
18e9dc33 11 * $NetBSD: math.h,v 1.46 2007/02/22 22:08:19 drochner Exp $
b34b60bc
JS
12 */
13
14/*
15 * @(#)fdlibm.h 5.1 93/09/24
16 */
17
18#ifndef _MATH_H_
19#define _MATH_H_
20
21#include <sys/cdefs.h>
e654a273 22#include <machine/limits.h>
b34b60bc 23
1ce93220
JS
24#if __GNUC_PREREQ__(3, 3) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800)
25#define __MATH_BUILTIN_CONSTANTS
26#endif
27
28#if __GNUC_PREREQ__(3, 0) && !defined(__INTEL_COMPILER)
29#define __MATH_BUILTIN_RELOPS
30#endif
31
b34b60bc
JS
32union __float_u {
33 unsigned char __dummy[sizeof(float)];
34 float __val;
35};
36
37union __double_u {
38 unsigned char __dummy[sizeof(double)];
39 double __val;
40};
41
42union __long_double_u {
43 unsigned char __dummy[sizeof(long double)];
44 long double __val;
45};
46
47#include <machine/math.h>
48
49#ifdef __HAVE_LONG_DOUBLE
50#define __fpmacro_unary_floating(__name, __arg0) \
51 /* LINTED */ \
52 ((sizeof (__arg0) == sizeof (float)) \
53 ? __ ## __name ## f (__arg0) \
54 : (sizeof (__arg0) == sizeof (double)) \
55 ? __ ## __name ## d (__arg0) \
56 : __ ## __name ## l (__arg0))
57#else
58#define __fpmacro_unary_floating(__name, __arg0) \
59 /* LINTED */ \
60 ((sizeof (__arg0) == sizeof (float)) \
61 ? __ ## __name ## f (__arg0) \
62 : __ ## __name ## d (__arg0))
63#endif /* __HAVE_LONG_DOUBLE */
64
65/*
66 * ANSI/POSIX
67 */
68/* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */
18e9dc33 69extern const union __double_u __infinity;
1ce93220
JS
70#ifdef __MATH_BUILTIN_CONSTANTS
71#define HUGE_VAL __builtin_huge_val()
72#else
73#define HUGE_VAL __infinity.__val
74#endif
b34b60bc
JS
75
76/*
77 * ISO C99
78 */
79#if __ISO_C_VISIBLE >= 1999
80/* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */
18e9dc33 81extern const union __float_u __infinityf;
1ce93220
JS
82#ifdef __MATH_BUILTIN_CONSTANTS
83#define HUGE_VALF __builtin_huge_valf()
84#else
b34b60bc 85#define HUGE_VALF __infinityf.__val
1ce93220 86#endif
b34b60bc 87
18e9dc33 88extern const union __long_double_u __infinityl;
d1c42bb2
SK
89#ifdef __MATH_BUILTIN_CONSTANTS
90#define HUGE_VALL __builtin_huge_vall()
91#else
b34b60bc 92#define HUGE_VALL __infinityl.__val
d1c42bb2 93#endif
b34b60bc
JS
94
95/* 7.12#4 INFINITY */
1ce93220 96#ifdef __MATH_BUILTIN_CONSTANTS
f2be1b3f 97#define INFINITY __builtin_inf()
1ce93220 98#elif defined(__INFINITY)
b34b60bc
JS
99#define INFINITY __INFINITY /* float constant which overflows */
100#else
101#define INFINITY HUGE_VALF /* positive infinity */
102#endif /* __INFINITY */
103
104/* 7.12#5 NAN: a quiet NaN, if supported */
1ce93220
JS
105#ifdef __MATH_BUILTIN_CONSTANTS
106#define NAN __builtin_nan("")
107#elif defined(__HAVE_NANF)
18e9dc33 108extern const union __float_u __nanf;
b34b60bc
JS
109#define NAN __nanf.__val
110#endif /* __HAVE_NANF */
111
112/* 7.12#6 number classification macros */
113#define FP_INFINITE 0x00
114#define FP_NAN 0x01
115#define FP_NORMAL 0x02
116#define FP_SUBNORMAL 0x03
117#define FP_ZERO 0x04
118/* NetBSD extensions */
119#define _FP_LOMD 0x80 /* range for machine-specific classes */
120#define _FP_HIMD 0xff
121
e654a273
SW
122/* 7.12#8 values returned by ilogb(0) or ilogb(NAN), respectively */
123#define FP_ILOGB0 INT_MIN
124#define FP_ILOGBNAN INT_MIN
125
b34b60bc
JS
126#endif /* ISO C99 */
127
128/*
129 * XOPEN/SVID
130 */
131#if __XSI_VISIBLE > 0
132#define M_E 2.7182818284590452354 /* e */
133#define M_LOG2E 1.4426950408889634074 /* log 2e */
134#define M_LOG10E 0.43429448190325182765 /* log 10e */
135#define M_LN2 0.69314718055994530942 /* log e2 */
136#define M_LN10 2.30258509299404568402 /* log e10 */
137#define M_PI 3.14159265358979323846 /* pi */
138#define M_PI_2 1.57079632679489661923 /* pi/2 */
139#define M_PI_4 0.78539816339744830962 /* pi/4 */
140#define M_1_PI 0.31830988618379067154 /* 1/pi */
141#define M_2_PI 0.63661977236758134308 /* 2/pi */
142#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
143#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
144#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
145
146#define MAXFLOAT ((float)3.40282346638528860e+38)
147extern int signgam;
148#endif /* _XSI_VISIBLE */
149
150#if __DF_VISIBLE
151#define HUGE MAXFLOAT
152
153/*
154 * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
155 * (one may replace the following line by "#include <values.h>")
156 */
157
158#define X_TLOSS 1.41484755040568800000e+16
159
160#define DOMAIN 1
161#define SING 2
162#define OVERFLOW 3
163#define UNDERFLOW 4
164#define TLOSS 5
165#define PLOSS 6
166
167#endif /* __DF_VISIBLE */
168
169__BEGIN_DECLS
170/*
171 * ANSI/POSIX
172 */
173double acos(double);
174double asin(double);
175double atan(double);
176double atan2(double, double);
177double cos(double);
178double sin(double);
179double tan(double);
180
181double cosh(double);
182double sinh(double);
183double tanh(double);
184
185double exp(double);
74dfd0cf 186double exp2(double);
b34b60bc
JS
187double frexp(double, int *);
188double ldexp(double, int);
189double log(double);
54f91c64 190double log2(double);
b34b60bc
JS
191double log10(double);
192double modf(double, double *);
193
194double pow(double, double);
195double sqrt(double);
196
197double ceil(double);
198double fabs(double);
199double floor(double);
200double fmod(double, double);
201
202#if __XSI_VISIBLE > 0
203double erf(double);
204double erfc(double);
205double gamma(double);
206double hypot(double, double);
207int finite(double);
208double j0(double);
209double j1(double);
210double jn(int, double);
211double lgamma(double);
1a3b704c 212double tgamma(double);
b34b60bc
JS
213double y0(double);
214double y1(double);
215double yn(int, double);
216#endif /* __XSI_VISIBLE */
217
218#if __XSI_VISIBLE >= 500
219double acosh(double);
220double asinh(double);
221double atanh(double);
222double cbrt(double);
223double expm1(double);
224int ilogb(double);
225double log1p(double);
226double logb(double);
227double nextafter(double, double);
228double remainder(double, double);
229double rint(double);
230double scalb(double, double);
231#endif /* __XSI_VISIBLE >= 500 */
232
233/*
234 * ISO C99
235 */
236#if __ISO_C_VISIBLE >= 1999
237/* 7.12.3.1 int fpclassify(real-floating x) */
238#define fpclassify(__x) __fpmacro_unary_floating(fpclassify, __x)
239
240/* 7.12.3.2 int isfinite(real-floating x) */
241#define isfinite(__x) __fpmacro_unary_floating(isfinite, __x)
242
243/* 7.12.3.5 int isnormal(real-floating x) */
244#define isnormal(__x) (fpclassify(__x) == FP_NORMAL)
245
246/* 7.12.3.6 int signbit(real-floating x) */
247#define signbit(__x) __fpmacro_unary_floating(signbit, __x)
248
249/* 7.12.4 trigonometric */
250
251float acosf(float);
252float asinf(float);
253float atanf(float);
254float atan2f(float, float);
255float cosf(float);
256float sinf(float);
257float tanf(float);
258
259/* 7.12.5 hyperbolic */
260
261float acoshf(float);
262float asinhf(float);
263float atanhf(float);
264float coshf(float);
265float sinhf(float);
266float tanhf(float);
267
268/* 7.12.6 exp / log */
269
270float expf(float);
74dfd0cf 271float exp2f(float);
b34b60bc
JS
272float expm1f(float);
273float frexpf(float, int *);
274int ilogbf(float);
275float ldexpf(float, int);
276float logf(float);
54f91c64 277float log2f(float);
b34b60bc
JS
278float log10f(float);
279float log1pf(float);
280float logbf(float);
281float modff(float, float *);
1a3b704c 282float scalblnf(float, long);
b34b60bc
JS
283float scalbnf(float, int);
284
285/* 7.12.7 power / absolute */
286
287float cbrtf(float);
288float fabsf(float);
289float hypotf(float, float);
290float powf(float, float);
291float sqrtf(float);
292
293/* 7.12.8 error / gamma */
294
295float erff(float);
296float erfcf(float);
297float lgammaf(float);
1a3b704c 298float tgammaf(float);
b34b60bc
JS
299
300/* 7.12.9 nearest integer */
301
302float ceilf(float);
303float floorf(float);
32119651
SK
304float nearbyintf(float);
305double nearbyint(double);
b34b60bc
JS
306float rintf(float);
307double round(double);
308float roundf(float);
d0090fae
PA
309double trunc(double);
310float truncf(float);
b34b60bc
JS
311long int lrint(double);
312long int lrintf(float);
313/* LONGLONG */
314long long int llrint(double);
315/* LONGLONG */
316long long int llrintf(float);
317long int lround(double);
318long int lroundf(float);
319/* LONGLONG */
320long long int llround(double);
321/* LONGLONG */
322long long int llroundf(float);
323
324/* 7.12.10 remainder */
325
326float fmodf(float, float);
327float remainderf(float, float);
328
74dfd0cf
JM
329/* 7.12.10.3 The remquo functions */
330double remquo(double, double, int *);
331float remquof(float, float, int *);
332
18e9dc33 333/* 7.12.11 manipulation */
b34b60bc
JS
334
335float copysignf(float, float);
e2519c07
PA
336double nan(const char *);
337float nanf(const char *);
b34b60bc
JS
338float nextafterf(float, float);
339
00d61692 340/* 7.12.12 maximum, minimum, positive difference */
56a964a0
SK
341double fdim(double, double);
342float fdimf(float, float);
56a964a0 343
00d61692
SK
344double fmax(double, double);
345float fmaxf(float, float);
00d61692
SK
346
347double fmin(double, double);
348float fminf(float, float);
1a3b704c
JM
349
350
351/* isoC99 */
352double fma (double, double, double);
353float fmaf (float, float, float);
354
355
356
00d61692 357
b34b60bc
JS
358#endif /* __ISO_C_VISIBLE >= 1999 */
359
360#if __ISO_C_VISIBLE >= 1999
361/* 7.12.3.3 int isinf(real-floating x) */
362#ifdef __isinf
363#define isinf(__x) __isinf(__x)
364#else
365#define isinf(__x) __fpmacro_unary_floating(isinf, __x)
366#endif
367
368/* 7.12.3.4 int isnan(real-floating x) */
369#ifdef __isnan
370#define isnan(__x) __isnan(__x)
371#else
372#define isnan(__x) __fpmacro_unary_floating(isnan, __x)
373#endif
1ce93220
JS
374
375/* 7.12.14 Comparision macros */
376#ifdef __MATH_BUILTIN_RELOPS
377#define isgreater(x, y) __builtin_isgreater((x), (y))
378#define isgreaterequal(x, y) __builtin_isgreaterequal((x), (y))
379#define isless(x, y) __builtin_isless((x), (y))
380#define islessequal(x, y) __builtin_islessequal((x), (y))
381#define islessgreater(x, y) __builtin_islessgreater((x), (y))
382#define isunordered(x, y) __builtin_isunordered((x), (y))
383#else
384#define isgreater(x, y) (!isunordered((x), (y)) && (x) > (y))
385#define isgreaterequal(x, y) (!isunordered((x), (y)) && (x) >= (y))
386#define isless(x, y) (!isunordered((x), (y)) && (x) < (y))
387#define islessequal(x, y) (!isunordered((x), (y)) && (x) <= (y))
388#define islessgreater(x, y) (!isunordered((x), (y)) && \
389 ((x) > (y) || (y) > (x)))
390#define isunordered(x, y) (isnan(x) || isnan(y))
391#endif /* __MATH_BUILTIN_RELOPS */
392
b34b60bc
JS
393#endif /* __ISO_C_VISIBLE >= 1999 */
394
395#if __DF_VISIBLE
396/*
397 * IEEE Test Vector
398 */
399double significand(double);
400
401/*
402 * Functions callable from C, intended to support IEEE arithmetic.
403 */
404double copysign(double, double);
1a3b704c 405double scalbln(double, long);
b34b60bc
JS
406double scalbn(double, int);
407
408/*
409 * BSD math library entry points
410 */
411double drem(double, double);
412
413/*
414 * Reentrant version of gamma & lgamma; passes signgam back by reference
415 * as the second argument; user must allocate space for signgam.
416 */
417double gamma_r(double, int *);
418double lgamma_r(double, int *);
419#endif /* __DF_VISIBLE */
420
421
422#if __DF_VISIBLE
423
424/* float versions of ANSI/POSIX functions */
425
426float gammaf(float);
b34b60bc
JS
427int finitef(float);
428float j0f(float);
429float j1f(float);
430float jnf(int, float);
431float y0f(float);
432float y1f(float);
433float ynf(int, float);
434
435float scalbf(float, float);
436
437/*
438 * float version of IEEE Test Vector
439 */
440float significandf(float);
441
442/*
443 * float versions of BSD math library entry points
444 */
445float dremf(float, float);
446
447/*
448 * Float versions of reentrant version of gamma & lgamma; passes
449 * signgam back by reference as the second argument; user must
450 * allocate space for signgam.
451 */
452float gammaf_r(float, int *);
453float lgammaf_r(float, int *);
454#endif /* __DF_VISIBLE */
455
456/*
457 * Library implementation
458 */
459int __fpclassifyf(float);
460int __fpclassifyd(double);
461int __isfinitef(float);
462int __isfinited(double);
463int __isinff(float);
464int __isinfd(double);
465int __isnanf(float);
466int __isnand(double);
467int __signbitf(float);
468int __signbitd(double);
469
470#ifdef __HAVE_LONG_DOUBLE
1a3b704c
JM
471int __fpclassifyl (long double);
472int __isfinitel (long double);
473int __isinfl (long double);
474int __isnanl (long double);
475int __signbitl (long double);
476
477long double acosl (long double);
478long double asinl (long double);
479long double atan2l (long double, long double);
480long double atanl (long double);
481long double ceill (long double);
482long double cosl (long double);
483long double cbrtl (long double);
484long double copysignl (long double, long double);
485long double fdiml (long double, long double);
486long double exp2l (long double);
487long double fabsl (long double);
488long double floorl (long double);
489long double fmal (long double, long double, long double);
490long double frexpl (long double, int *);
491long double fmaxl (long double, long double);
492long double fminl (long double, long double);
493long double fmodl (long double, long double);
494long double hypotl (long double, long double);
495int ilogbl (long double);
496long double ldexpl (long double, int);
ec514dfc 497long long llrintl (long double);
1a3b704c
JM
498long long llroundl (long double);
499long double logbl (long double);
500long lrintl (long double);
501long lroundl (long double);
502long double modfl (long double, long double *);
503long double nanl (const char *);
ec514dfc 504long double nearbyintl (long double);
1a3b704c
JM
505long double nextafterl (long double, long double);
506double nexttoward (double, long double);
507float nexttowardf (float, long double);
508long double remainderl (long double, long double);
509long double remquol (long double, long double, int *);
510long double rintl (long double);
511long double roundl (long double);
512long double scalblnl (long double, long);
513long double scalbnl (long double, int);
514long double sinl (long double);
515long double sqrtl (long double);
516long double tanl (long double);
517long double truncl (long double);
b34b60bc
JS
518#endif
519__END_DECLS
520
521#endif /* _MATH_H_ */