xref: /llvm-project/libc/include/llvm-libc-macros/math-function-macros.h (revision 4e33afee5a167d5293edeef15e414c0dbbcf3cef)
1b6e41c15SPetr Hosek //===-- Definition of function macros from math.h -------------------------===//
2b6e41c15SPetr Hosek //
3b6e41c15SPetr Hosek // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4b6e41c15SPetr Hosek // See https://llvm.org/LICENSE.txt for license information.
5b6e41c15SPetr Hosek // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6b6e41c15SPetr Hosek //
7b6e41c15SPetr Hosek //===----------------------------------------------------------------------===//
8b6e41c15SPetr Hosek 
9b6e41c15SPetr Hosek #ifndef LLVM_LIBC_MACROS_MATH_FUNCTION_MACROS_H
10b6e41c15SPetr Hosek #define LLVM_LIBC_MACROS_MATH_FUNCTION_MACROS_H
11b6e41c15SPetr Hosek 
1256124feeSShourya Goel #include "math-macros.h"
1356124feeSShourya Goel 
14*4e33afeeSShourya Goel #ifndef __cplusplus
15*4e33afeeSShourya Goel #define issignaling(x)                                                         \
16*4e33afeeSShourya Goel   _Generic((x),                                                                \
17*4e33afeeSShourya Goel       float: issignalingf,                                                     \
18*4e33afeeSShourya Goel       double: issignaling,                                                     \
19*4e33afeeSShourya Goel       long double: issignalingl)(x)
20*4e33afeeSShourya Goel #define iscanonical(x)                                                         \
21*4e33afeeSShourya Goel   _Generic((x),                                                                \
22*4e33afeeSShourya Goel       float: iscanonicalf,                                                     \
23*4e33afeeSShourya Goel       double: iscanonical,                                                     \
24*4e33afeeSShourya Goel       long double: iscanonicall)(x)
25*4e33afeeSShourya Goel #endif
26*4e33afeeSShourya Goel 
27b6e41c15SPetr Hosek #define isfinite(x) __builtin_isfinite(x)
28b6e41c15SPetr Hosek #define isinf(x) __builtin_isinf(x)
29b6e41c15SPetr Hosek #define isnan(x) __builtin_isnan(x)
303604c23dSAkiel #define signbit(x) __builtin_signbit(x)
31739ede40SShourya Goel #define iszero(x) (x == 0)
3256124feeSShourya Goel #define fpclassify(x)                                                          \
3356124feeSShourya Goel   __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)
34aaa637d8SShourya Goel #define isnormal(x) __builtin_isnormal(x)
35ba5e1958SShourya Goel #define issubnormal(x) (fpclassify(x) == FP_SUBNORMAL)
36b6e41c15SPetr Hosek 
37b6e41c15SPetr Hosek #endif // LLVM_LIBC_MACROS_MATH_FUNCTION_MACROS_H
38