1 /* 2 * dunder.c - manually provoke FP exceptions for mathlib 3 * 4 * Copyright (c) 2009-2018, Arm Limited. 5 * SPDX-License-Identifier: MIT 6 */ 7 8 9 #include "math_private.h" 10 #include <fenv.h> 11 __mathlib_dbl_infnan(double x)12__inline double __mathlib_dbl_infnan(double x) 13 { 14 return x+x; 15 } 16 __mathlib_dbl_infnan2(double x,double y)17__inline double __mathlib_dbl_infnan2(double x, double y) 18 { 19 return x+y; 20 } 21 __mathlib_dbl_underflow(void)22double __mathlib_dbl_underflow(void) 23 { 24 #ifdef CLANG_EXCEPTIONS 25 feraiseexcept(FE_UNDERFLOW); 26 #endif 27 return 0x1p-767 * 0x1p-767; 28 } 29 __mathlib_dbl_overflow(void)30double __mathlib_dbl_overflow(void) 31 { 32 #ifdef CLANG_EXCEPTIONS 33 feraiseexcept(FE_OVERFLOW); 34 #endif 35 return 0x1p+769 * 0x1p+769; 36 } 37 __mathlib_dbl_invalid(void)38double __mathlib_dbl_invalid(void) 39 { 40 #ifdef CLANG_EXCEPTIONS 41 feraiseexcept(FE_INVALID); 42 #endif 43 return 0.0 / 0.0; 44 } 45 __mathlib_dbl_divzero(void)46double __mathlib_dbl_divzero(void) 47 { 48 #ifdef CLANG_EXCEPTIONS 49 feraiseexcept(FE_DIVBYZERO); 50 #endif 51 return 1.0 / 0.0; 52 } 53