blob: b472f1a962e9bf34af26c90f73482d0252800a87 [file] [log] [blame]
Daniel Dunbar86030242011-11-16 07:33:00 +00001/* ===-- int_math.h - internal math inlines ---------------------------------===
2 *
3 * The LLVM Compiler Infrastructure
4 *
5 * This file is dual licensed under the MIT and the University of Illinois Open
6 * Source Licenses. See LICENSE.TXT for details.
7 *
8 * ===-----------------------------------------------------------------------===
9 *
10 * This file is not part of the interface of this library.
11 *
12 * This file defines substitutes for the libm functions used in some of the
13 * compiler-rt implementations, defined in such a way that there is not a direct
14 * dependency on libm or math.h. Instead, we use the compiler builtin versions
15 * where available. This reduces our dependencies on the system SDK by foisting
16 * the responsibility onto the compiler.
17 *
18 * ===-----------------------------------------------------------------------===
19 */
20
21#ifndef INT_MATH_H
22#define INT_MATH_H
23
Daniel Dunbarc25c6d12011-11-16 07:33:06 +000024#define CRT_INFINITY __builtin_huge_valf()
25
Daniel Dunbar86030242011-11-16 07:33:00 +000026#define crt_isfinite(x) __builtin_isfinite((x))
27#define crt_isinf(x) __builtin_isinf((x))
28#define crt_isnan(x) __builtin_isnan((x))
29
Daniel Dunbarc25c6d12011-11-16 07:33:06 +000030#define crt_copysign(x, y) __builtin_copysign((x), (y))
31#define crt_copysignf(x, y) __builtin_copysignf((x), (y))
32#define crt_copysignl(x, y) __builtin_copysignl((x), (y))
33
34#define crt_fabs(x) __builtin_fabs((x))
35#define crt_fabsf(x) __builtin_fabsf((x))
36#define crt_fabsl(x) __builtin_fabsl((x))
37
38#define crt_fmax(x, y) __builtin_fmax((x), (y))
39#define crt_fmaxf(x, y) __builtin_fmaxf((x), (y))
40#define crt_fmaxl(x, y) __builtin_fmaxl((x), (y))
41
42#define crt_logb(x) __builtin_logb((x))
43#define crt_logbf(x) __builtin_logbf((x))
44#define crt_logbl(x) __builtin_logbl((x))
45
46#define crt_scalbn(x, y) __builtin_scalbn((x), (y))
47#define crt_scalbnf(x, y) __builtin_scalbnf((x), (y))
48#define crt_scalbnl(x, y) __builtin_scalbnl((x), (y))
49
Daniel Dunbar86030242011-11-16 07:33:00 +000050#endif /* INT_MATH_H */