Home | History | Annotate | Download | only in single
      1 /*
      2  * funder.c - manually provoke SP exceptions for mathlib
      3  *
      4  * Copyright (c) 2009-2018, Arm Limited.
      5  * SPDX-License-Identifier: MIT
      6  */
      7 
      8 #include <fenv.h>
      9 #include "math_private.h"
     10 
     11 __inline float __mathlib_flt_infnan2(float x, float y)
     12 {
     13   return x+y;
     14 }
     15 
     16 __inline float __mathlib_flt_infnan(float x)
     17 {
     18   return x+x;
     19 }
     20 
     21 float __mathlib_flt_underflow(void)
     22 {
     23 #ifdef CLANG_EXCEPTIONS
     24   feraiseexcept(FE_UNDERFLOW);
     25 #endif
     26   return 0x1p-95F * 0x1p-95F;
     27 }
     28 
     29 float __mathlib_flt_overflow(void)
     30 {
     31 #ifdef CLANG_EXCEPTIONS
     32   feraiseexcept(FE_OVERFLOW);
     33 #endif
     34   return 0x1p+97F * 0x1p+97F;
     35 }
     36 
     37 float __mathlib_flt_invalid(void)
     38 {
     39 #ifdef CLANG_EXCEPTIONS
     40   feraiseexcept(FE_INVALID);
     41 #endif
     42   return 0.0f / 0.0f;
     43 }
     44 
     45 float __mathlib_flt_divzero(void)
     46 {
     47 #ifdef CLANG_EXCEPTIONS
     48   feraiseexcept(FE_DIVBYZERO);
     49 #endif
     50   return 1.0f / 0.0f;
     51 }
     52