1 //===-- Definition of macros from math.h ----------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_LIBC_MACROS_MATH_MACROS_H 10 #define LLVM_LIBC_MACROS_MATH_MACROS_H 11 12 #include "limits-macros.h" 13 14 #define FP_NAN 0 15 #define FP_INFINITE 1 16 #define FP_ZERO 2 17 #define FP_SUBNORMAL 3 18 #define FP_NORMAL 4 19 20 #define FP_INT_UPWARD 0 21 #define FP_INT_DOWNWARD 1 22 #define FP_INT_TOWARDZERO 2 23 #define FP_INT_TONEARESTFROMZERO 3 24 #define FP_INT_TONEAREST 4 25 26 #define MATH_ERRNO 1 27 #define MATH_ERREXCEPT 2 28 29 #define HUGE_VAL __builtin_huge_val() 30 #define INFINITY __builtin_inf() 31 #define NAN __builtin_nanf("") 32 33 #define FP_ILOGB0 (-INT_MAX - 1) 34 #define FP_LLOGB0 (-LONG_MAX - 1) 35 36 #ifdef __FP_LOGBNAN_MIN 37 #define FP_ILOGBNAN (-INT_MAX - 1) 38 #define FP_LLOGBNAN (-LONG_MAX - 1) 39 #else 40 #define FP_ILOGBNAN INT_MAX 41 #define FP_LLOGBNAN LONG_MAX 42 #endif 43 44 #ifdef __FAST_MATH__ 45 #define math_errhandling 0 46 #elif defined(__NO_MATH_ERRNO__) 47 #define math_errhandling (MATH_ERREXCEPT) 48 #elif defined(__NVPTX__) || defined(__AMDGPU__) 49 #define math_errhandling (MATH_ERRNO) 50 #else 51 #define math_errhandling (MATH_ERRNO | MATH_ERREXCEPT) 52 #endif 53 54 // TODO: Move generic functional math macros to a separate header file. 55 #define isfinite(x) __builtin_isfinite(x) 56 #define isinf(x) __builtin_isinf(x) 57 #define isnan(x) __builtin_isnan(x) 58 59 #endif // LLVM_LIBC_MACROS_MATH_MACROS_H 60