loader: add skein/edonr support
[unleashed.git] / include / iso / math_c99.h
blob72c4b30fc055332619b09764a9f80d9d4c0aa9bb
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
25 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
29 #ifndef _ISO_MATH_C99_H
30 #define _ISO_MATH_C99_H
32 #include <sys/isa_defs.h>
33 #include <sys/feature_tests.h>
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
39 #ifndef __P
40 #ifdef __STDC__
41 #define __P(p) p
42 #else
43 #define __P(p) ()
44 #endif
45 #endif /* !defined(__P) */
47 #if defined(_STDC_C99) || _XOPEN_SOURCE - 0 >= 600 || defined(__C99FEATURES__)
48 #if defined(__GNUC__)
49 #undef HUGE_VAL
50 #define HUGE_VAL (__builtin_huge_val())
51 #undef HUGE_VALF
52 #define HUGE_VALF (__builtin_huge_valf())
53 #undef HUGE_VALL
54 #define HUGE_VALL (__builtin_huge_vall())
55 #undef INFINITY
56 #define INFINITY (__builtin_inff())
57 #undef NAN
58 #define NAN (__builtin_nanf(""))
61 * C99 7.12.3 classification macros
63 #undef isnan
64 #undef isinf
65 #if __GNUC__ >= 4
66 #define isnan(x) __builtin_isnan(x)
67 #define isinf(x) __builtin_isinf(x)
68 #else
69 #define isnan(x) __extension__( \
70 { __typeof(x) __x_n = (x); \
71 __builtin_isunordered(__x_n, __x_n); })
72 #define isinf(x) __extension__( \
73 { __typeof(x) __x_i = (x); \
74 __x_i == (__typeof(__x_i)) INFINITY || \
75 __x_i == (__typeof(__x_i)) (-INFINITY); })
76 #endif
77 #undef isfinite
78 #define isfinite(x) __extension__( \
79 { __typeof(x) __x_f = (x); \
80 !isnan(__x_f) && !isinf(__x_f); })
81 #undef isnormal
82 #define isnormal(x) __extension__( \
83 { __typeof(x) __x_r = (x); isfinite(__x_r) && \
84 (sizeof (__x_r) == sizeof (float) ? \
85 __builtin_fabsf(__x_r) >= __FLT_MIN__ : \
86 sizeof (__x_r) == sizeof (double) ? \
87 __builtin_fabs(__x_r) >= __DBL_MIN__ : \
88 __builtin_fabsl(__x_r) >= __LDBL_MIN__); })
89 #undef fpclassify
90 #define fpclassify(x) __extension__( \
91 { __typeof(x) __x_c = (x); \
92 isnan(__x_c) ? FP_NAN : \
93 isinf(__x_c) ? FP_INFINITE : \
94 isnormal(__x_c) ? FP_NORMAL : \
95 __x_c == (__typeof(__x_c)) 0 ? FP_ZERO : \
96 FP_SUBNORMAL; })
97 #undef signbit
98 #if defined(_BIG_ENDIAN)
99 #define signbit(x) __extension__( \
100 { __typeof(x) __x_s = (x); \
101 (int) (*(unsigned *) &__x_s >> 31); })
102 #elif defined(_LITTLE_ENDIAN)
103 #define signbit(x) __extension__( \
104 { __typeof(x) __x_s = (x); \
105 (sizeof (__x_s) == sizeof (float) ? \
106 (int) (*(unsigned *) &__x_s >> 31) : \
107 sizeof (__x_s) == sizeof (double) ? \
108 (int) (((unsigned *) &__x_s)[1] >> 31) : \
109 (int) (((unsigned short *) &__x_s)[4] >> 15)); })
110 #endif
113 * C99 7.12.14 comparison macros
115 #undef isgreater
116 #define isgreater(x, y) __builtin_isgreater(x, y)
117 #undef isgreaterequal
118 #define isgreaterequal(x, y) __builtin_isgreaterequal(x, y)
119 #undef isless
120 #define isless(x, y) __builtin_isless(x, y)
121 #undef islessequal
122 #define islessequal(x, y) __builtin_islessequal(x, y)
123 #undef islessgreater
124 #define islessgreater(x, y) __builtin_islessgreater(x, y)
125 #undef isunordered
126 #define isunordered(x, y) __builtin_isunordered(x, y)
127 #else /* defined(__GNUC__) */
128 #undef HUGE_VAL
129 #define HUGE_VAL __builtin_huge_val
130 #undef HUGE_VALF
131 #define HUGE_VALF __builtin_huge_valf
132 #undef HUGE_VALL
133 #define HUGE_VALL __builtin_huge_vall
134 #undef INFINITY
135 #define INFINITY __builtin_infinity
136 #undef NAN
137 #define NAN __builtin_nan
140 * C99 7.12.3 classification macros
142 #undef fpclassify
143 #define fpclassify(x) __builtin_fpclassify(x)
144 #undef isfinite
145 #define isfinite(x) __builtin_isfinite(x)
146 #undef isinf
147 #define isinf(x) __builtin_isinf(x)
148 #undef isnan
149 #define isnan(x) __builtin_isnan(x)
150 #undef isnormal
151 #define isnormal(x) __builtin_isnormal(x)
152 #undef signbit
153 #define signbit(x) __builtin_signbit(x)
156 * C99 7.12.14 comparison macros
158 #undef isgreater
159 #define isgreater(x, y) ((x) __builtin_isgreater(y))
160 #undef isgreaterequal
161 #define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))
162 #undef isless
163 #define isless(x, y) ((x) __builtin_isless(y))
164 #undef islessequal
165 #define islessequal(x, y) ((x) __builtin_islessequal(y))
166 #undef islessgreater
167 #define islessgreater(x, y) ((x) __builtin_islessgreater(y))
168 #undef isunordered
169 #define isunordered(x, y) ((x) __builtin_isunordered(y))
170 #endif /* defined(__GNUC__) */
171 #endif /* defined(_STDC_C99) || _XOPEN_SOURCE - 0 >= 600 || ... */
173 #if defined(__EXTENSIONS__) || defined(_STDC_C99) || \
174 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
175 defined(__C99FEATURES__)
176 #if defined(__FLT_EVAL_METHOD__) && __FLT_EVAL_METHOD__ - 0 == 0
177 typedef float float_t;
178 typedef double double_t;
179 #elif __FLT_EVAL_METHOD__ - 0 == 1
180 typedef double float_t;
181 typedef double double_t;
182 #elif __FLT_EVAL_METHOD__ - 0 == 2
183 typedef long double float_t;
184 typedef long double double_t;
185 #elif defined(__sparc) || defined(__amd64)
186 typedef float float_t;
187 typedef double double_t;
188 #elif defined(__i386)
189 typedef long double float_t;
190 typedef long double double_t;
191 #endif
193 #undef FP_ZERO
194 #define FP_ZERO 0
195 #undef FP_SUBNORMAL
196 #define FP_SUBNORMAL 1
197 #undef FP_NORMAL
198 #define FP_NORMAL 2
199 #undef FP_INFINITE
200 #define FP_INFINITE 3
201 #undef FP_NAN
202 #define FP_NAN 4
204 #undef FP_ILOGB0
205 #define FP_ILOGB0 (-2147483647)
206 #undef FP_ILOGBNAN
207 #define FP_ILOGBNAN 2147483647
209 #undef MATH_ERRNO
210 #define MATH_ERRNO 1
211 #undef MATH_ERREXCEPT
212 #define MATH_ERREXCEPT 2
213 #undef math_errhandling
214 #define math_errhandling MATH_ERREXCEPT
216 extern double acosh __P((double));
217 extern double asinh __P((double));
218 extern double atanh __P((double));
220 extern double exp2 __P((double));
221 extern double expm1 __P((double));
222 extern int ilogb __P((double));
223 extern double log1p __P((double));
224 extern double log2 __P((double));
225 extern double logb __P((double));
226 extern double scalbn __P((double, int));
227 extern double scalbln __P((double, long int));
229 extern double cbrt __P((double));
230 extern double hypot __P((double, double));
232 extern double erf __P((double));
233 extern double erfc __P((double));
234 extern double lgamma __P((double));
235 extern double tgamma __P((double));
237 extern double nearbyint __P((double));
238 extern double rint __P((double));
239 extern long int lrint __P((double));
240 extern double round __P((double));
241 extern long int lround __P((double));
242 extern double trunc __P((double));
244 extern double remainder __P((double, double));
245 extern double remquo __P((double, double, int *));
247 extern double copysign __P((double, double));
248 extern double nan __P((const char *));
249 extern double nextafter __P((double, double));
250 extern double nexttoward __P((double, long double));
252 extern double fdim __P((double, double));
253 extern double fmax __P((double, double));
254 extern double fmin __P((double, double));
256 extern double fma __P((double, double, double));
258 extern float acosf __P((float));
259 extern float asinf __P((float));
260 extern float atanf __P((float));
261 extern float atan2f __P((float, float));
262 extern float cosf __P((float));
263 extern float sinf __P((float));
264 extern float tanf __P((float));
266 extern float acoshf __P((float));
267 extern float asinhf __P((float));
268 extern float atanhf __P((float));
269 extern float coshf __P((float));
270 extern float sinhf __P((float));
271 extern float tanhf __P((float));
273 extern float expf __P((float));
274 extern float exp2f __P((float));
275 extern float expm1f __P((float));
276 extern float frexpf __P((float, int *));
277 extern int ilogbf __P((float));
278 extern float ldexpf __P((float, int));
279 extern float logf __P((float));
280 extern float log10f __P((float));
281 extern float log1pf __P((float));
282 extern float log2f __P((float));
283 extern float logbf __P((float));
284 extern float modff __P((float, float *));
285 extern float scalbnf __P((float, int));
286 extern float scalblnf __P((float, long int));
288 extern float cbrtf __P((float));
289 extern float fabsf __P((float));
290 extern float hypotf __P((float, float));
291 extern float powf __P((float, float));
292 extern float sqrtf __P((float));
294 extern float erff __P((float));
295 extern float erfcf __P((float));
296 extern float lgammaf __P((float));
297 extern float tgammaf __P((float));
299 extern float ceilf __P((float));
300 extern float floorf __P((float));
301 extern float nearbyintf __P((float));
302 extern float rintf __P((float));
303 extern long int lrintf __P((float));
304 extern float roundf __P((float));
305 extern long int lroundf __P((float));
306 extern float truncf __P((float));
308 extern float fmodf __P((float, float));
309 extern float remainderf __P((float, float));
310 extern float remquof __P((float, float, int *));
312 extern float copysignf __P((float, float));
313 extern float nanf __P((const char *));
314 extern float nextafterf __P((float, float));
315 extern float nexttowardf __P((float, long double));
317 extern float fdimf __P((float, float));
318 extern float fmaxf __P((float, float));
319 extern float fminf __P((float, float));
321 extern float fmaf __P((float, float, float));
323 extern long double acosl __P((long double));
324 extern long double asinl __P((long double));
325 extern long double atanl __P((long double));
326 extern long double atan2l __P((long double, long double));
327 extern long double cosl __P((long double));
328 extern long double sinl __P((long double));
329 extern long double tanl __P((long double));
331 extern long double acoshl __P((long double));
332 extern long double asinhl __P((long double));
333 extern long double atanhl __P((long double));
334 extern long double coshl __P((long double));
335 extern long double sinhl __P((long double));
336 extern long double tanhl __P((long double));
338 extern long double expl __P((long double));
339 extern long double exp2l __P((long double));
340 extern long double expm1l __P((long double));
341 extern long double frexpl __P((long double, int *));
342 extern int ilogbl __P((long double));
343 extern long double ldexpl __P((long double, int));
344 extern long double logl __P((long double));
345 extern long double log10l __P((long double));
346 extern long double log1pl __P((long double));
347 extern long double log2l __P((long double));
348 extern long double logbl __P((long double));
349 extern long double modfl __P((long double, long double *));
350 extern long double scalbnl __P((long double, int));
351 extern long double scalblnl __P((long double, long int));
353 extern long double cbrtl __P((long double));
354 extern long double fabsl __P((long double));
355 extern long double hypotl __P((long double, long double));
356 extern long double powl __P((long double, long double));
357 extern long double sqrtl __P((long double));
359 extern long double erfl __P((long double));
360 extern long double erfcl __P((long double));
361 extern long double lgammal __P((long double));
362 extern long double tgammal __P((long double));
364 extern long double ceill __P((long double));
365 extern long double floorl __P((long double));
366 extern long double nearbyintl __P((long double));
367 extern long double rintl __P((long double));
368 extern long int lrintl __P((long double));
369 extern long double roundl __P((long double));
370 extern long int lroundl __P((long double));
371 extern long double truncl __P((long double));
373 extern long double fmodl __P((long double, long double));
374 extern long double remainderl __P((long double, long double));
375 extern long double remquol __P((long double, long double, int *));
377 extern long double copysignl __P((long double, long double));
378 extern long double nanl __P((const char *));
379 extern long double nextafterl __P((long double, long double));
380 extern long double nexttowardl __P((long double, long double));
382 extern long double fdiml __P((long double, long double));
383 extern long double fmaxl __P((long double, long double));
384 extern long double fminl __P((long double, long double));
386 extern long double fmal __P((long double, long double, long double));
388 #if !defined(_STRICT_STDC) && !defined(_NO_LONGLONG) || defined(_STDC_C99) || \
389 defined(__C99FEATURES__)
390 extern long long int llrint __P((double));
391 extern long long int llround __P((double));
393 extern long long int llrintf __P((float));
394 extern long long int llroundf __P((float));
396 extern long long int llrintl __P((long double));
397 extern long long int llroundl __P((long double));
398 #endif
400 #if !defined(__cplusplus)
401 #pragma does_not_read_global_data(asinh, exp2, expm1)
402 #pragma does_not_read_global_data(ilogb, log2)
403 #pragma does_not_read_global_data(scalbn, scalbln, cbrt)
404 #pragma does_not_read_global_data(erf, erfc, tgamma)
405 #pragma does_not_read_global_data(nearbyint, rint, lrint, round, lround, trunc)
406 #pragma does_not_read_global_data(remquo)
407 #pragma does_not_read_global_data(copysign, nan, nexttoward)
408 #pragma does_not_read_global_data(fdim, fmax, fmin, fma)
409 #pragma does_not_write_global_data(asinh, exp2, expm1)
410 #pragma does_not_write_global_data(ilogb, log2)
411 #pragma does_not_write_global_data(scalbn, scalbln, cbrt)
412 #pragma does_not_write_global_data(erf, erfc, tgamma)
413 #pragma does_not_write_global_data(nearbyint, rint, lrint, round, lround, trunc)
414 #pragma does_not_write_global_data(copysign, nan, nexttoward)
415 #pragma does_not_write_global_data(fdim, fmax, fmin, fma)
417 #pragma does_not_read_global_data(acosf, asinf, atanf, atan2f)
418 #pragma does_not_read_global_data(cosf, sinf, tanf)
419 #pragma does_not_read_global_data(acoshf, asinhf, atanhf, coshf, sinhf, tanhf)
420 #pragma does_not_read_global_data(expf, exp2f, expm1f, frexpf, ilogbf, ldexpf)
421 #pragma does_not_read_global_data(logf, log10f, log1pf, log2f, logbf)
422 #pragma does_not_read_global_data(modff, scalbnf, scalblnf)
423 #pragma does_not_read_global_data(cbrtf, fabsf, hypotf, powf, sqrtf)
424 #pragma does_not_read_global_data(erff, erfcf, lgammaf, tgammaf)
425 #pragma does_not_read_global_data(ceilf, floorf, nearbyintf)
426 #pragma does_not_read_global_data(rintf, lrintf, roundf, lroundf, truncf)
427 #pragma does_not_read_global_data(fmodf, remainderf, remquof)
428 #pragma does_not_read_global_data(copysignf, nanf, nextafterf, nexttowardf)
429 #pragma does_not_read_global_data(fdimf, fmaxf, fminf, fmaf)
430 #pragma does_not_write_global_data(acosf, asinf, atanf, atan2f)
431 #pragma does_not_write_global_data(cosf, sinf, tanf)
432 #pragma does_not_write_global_data(acoshf, asinhf, atanhf, coshf, sinhf, tanhf)
433 #pragma does_not_write_global_data(expf, exp2f, expm1f, ilogbf, ldexpf)
434 #pragma does_not_write_global_data(logf, log10f, log1pf, log2f, logbf)
435 #pragma does_not_write_global_data(cbrtf, fabsf, hypotf, powf, sqrtf)
436 #pragma does_not_write_global_data(erff, erfcf, tgammaf)
437 #pragma does_not_write_global_data(ceilf, floorf, nearbyintf)
438 #pragma does_not_write_global_data(rintf, lrintf, roundf, lroundf, truncf)
439 #pragma does_not_write_global_data(fmodf, remainderf)
440 #pragma does_not_write_global_data(copysignf, nanf, nextafterf, nexttowardf)
441 #pragma does_not_write_global_data(fdimf, fmaxf, fminf, fmaf)
443 #pragma does_not_read_global_data(acosl, asinl, atanl, atan2l)
444 #pragma does_not_read_global_data(cosl, sinl, tanl)
445 #pragma does_not_read_global_data(acoshl, asinhl, atanhl, coshl, sinhl, tanhl)
446 #pragma does_not_read_global_data(expl, exp2l, expm1l, frexpl, ilogbl, ldexpl)
447 #pragma does_not_read_global_data(logl, log10l, log1pl, log2l, logbl)
448 #pragma does_not_read_global_data(modfl, scalbnl, scalblnl)
449 #pragma does_not_read_global_data(cbrtl, fabsl, hypotl, powl, sqrtl)
450 #pragma does_not_read_global_data(erfl, erfcl, lgammal, tgammal)
451 #pragma does_not_read_global_data(ceill, floorl, nearbyintl)
452 #pragma does_not_read_global_data(rintl, lrintl, roundl, lroundl, truncl)
453 #pragma does_not_read_global_data(fmodl, remainderl, remquol)
454 #pragma does_not_read_global_data(copysignl, nanl, nextafterl, nexttowardl)
455 #pragma does_not_read_global_data(fdiml, fmaxl, fminl, fmal)
456 #pragma does_not_write_global_data(acosl, asinl, atanl, atan2l)
457 #pragma does_not_write_global_data(cosl, sinl, tanl)
458 #pragma does_not_write_global_data(acoshl, asinhl, atanhl, coshl, sinhl, tanhl)
459 #pragma does_not_write_global_data(expl, exp2l, expm1l, ilogbl, ldexpl)
460 #pragma does_not_write_global_data(logl, log10l, log1pl, log2l, logbl)
461 #pragma does_not_write_global_data(cbrtl, fabsl, hypotl, powl, sqrtl)
462 #pragma does_not_write_global_data(erfl, erfcl, tgammal)
463 #pragma does_not_write_global_data(ceill, floorl, nearbyintl)
464 #pragma does_not_write_global_data(rintl, lrintl, roundl, lroundl, truncl)
465 #pragma does_not_write_global_data(fmodl, remainderl)
466 #pragma does_not_write_global_data(copysignl, nanl, nextafterl, nexttowardl)
467 #pragma does_not_write_global_data(fdiml, fmaxl, fminl, fmal)
469 #if !defined(_STRICT_STDC) && !defined(_NO_LONGLONG) || defined(_STDC_C99) || \
470 defined(__C99FEATURES__)
471 #pragma does_not_read_global_data(llrint, llround)
472 #pragma does_not_read_global_data(llrintf, llroundf, llrintl, llroundl)
473 #pragma does_not_write_global_data(llrint, llround)
474 #pragma does_not_write_global_data(llrintf, llroundf, llrintl, llroundl)
475 #endif
476 #endif /* !defined(__cplusplus) */
478 #if defined(__MATHERR_ERRNO_DONTCARE)
479 #pragma does_not_read_global_data(acosh, atanh, hypot, lgamma, log1p, logb)
480 #pragma does_not_read_global_data(nextafter, remainder)
481 #pragma does_not_write_global_data(acosh, atanh, hypot, log1p, logb)
482 #pragma does_not_write_global_data(nextafter, remainder)
484 #pragma no_side_effect(acosh, asinh, atanh, exp2, expm1)
485 #pragma no_side_effect(ilogb, log1p, log2, logb)
486 #pragma no_side_effect(scalbn, scalbln, cbrt, hypot)
487 #pragma no_side_effect(erf, erfc, tgamma)
488 #pragma no_side_effect(nearbyint, rint, lrint, round, lround, trunc)
489 #pragma no_side_effect(remainder)
490 #pragma no_side_effect(copysign, nan, nextafter, nexttoward)
491 #pragma no_side_effect(fdim, fmax, fmin, fma)
493 #pragma no_side_effect(acosf, asinf, atanf, atan2f)
494 #pragma no_side_effect(cosf, sinf, tanf, coshf, sinhf, tanhf)
495 #pragma no_side_effect(acoshf, asinhf, atanhf, coshf, sinhf, tanhf)
496 #pragma no_side_effect(expf, exp2f, expm1f, ilogbf, ldexpf)
497 #pragma no_side_effect(logf, log10f, log1pf, log2f, logbf)
498 #pragma no_side_effect(cbrtf, fabsf, hypotf, powf, sqrtf)
499 #pragma no_side_effect(erff, erfcf, tgammaf)
500 #pragma no_side_effect(ceilf, floorf, nearbyintf)
501 #pragma no_side_effect(rintf, lrintf, roundf, lroundf, truncf)
502 #pragma no_side_effect(fmodf, remainderf)
503 #pragma no_side_effect(copysignf, nanf, nextafterf, nexttowardf)
504 #pragma no_side_effect(fdimf, fmaxf, fminf, fmaf)
506 #pragma no_side_effect(acosl, asinl, atanl, atan2l)
507 #pragma no_side_effect(cosl, sinl, tanl, coshl, sinhl, tanhl)
508 #pragma no_side_effect(acoshl, asinhl, atanhl, coshl, sinhl, tanhl)
509 #pragma no_side_effect(expl, exp2l, expm1l, ilogbl, ldexpl)
510 #pragma no_side_effect(logl, log10l, log1pl, log2l, logbl)
511 #pragma no_side_effect(cbrtl, fabsl, hypotl, powl, sqrtl)
512 #pragma no_side_effect(erfl, erfcl, tgammal)
513 #pragma no_side_effect(ceill, floorl, nearbyintl)
514 #pragma no_side_effect(rintl, lrintl, roundl, lroundl, truncl)
515 #pragma no_side_effect(fmodl, remainderl)
516 #pragma no_side_effect(copysignl, nanl, nextafterl, nexttowardl)
517 #pragma no_side_effect(fdiml, fmaxl, fminl, fmal)
519 #if !defined(_STRICT_STDC) && !defined(_NO_LONGLONG) || defined(_STDC_C99) || \
520 defined(__C99FEATURES__)
521 #pragma no_side_effect(llrint, llround, llrintf, llroundf, llrintl, llroundl)
522 #endif
523 #endif /* defined(__MATHERR_ERRNO_DONTCARE) */
524 #endif /* defined(__EXTENSIONS__) || defined(_STDC_C99) || ... */
526 #ifdef __cplusplus
528 #endif
530 #endif /* _ISO_MATH_C99_H */