Relocate the external headers provided by ASan and the common sanitizer
[blocksruntime.git] / lib / int_math.h
blobd6b4bdae162b9136eedbcc5936a0a695d4301dc8
1 /* ===-- int_math.h - internal math inlines ---------------------------------===
3 * The LLVM Compiler Infrastructure
5 * This file is dual licensed under the MIT and the University of Illinois Open
6 * Source Licenses. See LICENSE.TXT for details.
8 * ===-----------------------------------------------------------------------===
10 * This file is not part of the interface of this library.
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.
18 * ===-----------------------------------------------------------------------===
21 #ifndef INT_MATH_H
22 #define INT_MATH_H
24 #ifndef __has_builtin
25 # define __has_builtin(x) 0
26 #endif
28 #define CRT_INFINITY __builtin_huge_valf()
30 #define crt_isinf(x) __builtin_isinf((x))
31 #define crt_isnan(x) __builtin_isnan((x))
33 /* Define crt_isfinite in terms of the builtin if available, otherwise provide
34 * an alternate version in terms of our other functions. This supports some
35 * versions of GCC which didn't have __builtin_isfinite.
37 #if __has_builtin(__builtin_isfinite)
38 # define crt_isfinite(x) __builtin_isfinite((x))
39 #else
40 # define crt_isfinite(x) \
41 __extension__(({ \
42 __typeof((x)) x_ = (x); \
43 !crt_isinf(x_) && !crt_isnan(x_); \
44 }))
45 #endif
47 #define crt_copysign(x, y) __builtin_copysign((x), (y))
48 #define crt_copysignf(x, y) __builtin_copysignf((x), (y))
49 #define crt_copysignl(x, y) __builtin_copysignl((x), (y))
51 #define crt_fabs(x) __builtin_fabs((x))
52 #define crt_fabsf(x) __builtin_fabsf((x))
53 #define crt_fabsl(x) __builtin_fabsl((x))
55 #define crt_fmax(x, y) __builtin_fmax((x), (y))
56 #define crt_fmaxf(x, y) __builtin_fmaxf((x), (y))
57 #define crt_fmaxl(x, y) __builtin_fmaxl((x), (y))
59 #define crt_logb(x) __builtin_logb((x))
60 #define crt_logbf(x) __builtin_logbf((x))
61 #define crt_logbl(x) __builtin_logbl((x))
63 #define crt_scalbn(x, y) __builtin_scalbn((x), (y))
64 #define crt_scalbnf(x, y) __builtin_scalbnf((x), (y))
65 #define crt_scalbnl(x, y) __builtin_scalbnl((x), (y))
67 #endif /* INT_MATH_H */