SDL_exp
authorEthan Lee <flibitijibibo@flibitijibibo.com>
Sat, 04 Aug 2018 11:52:46 -0400
changeset 120721e46699fa470
parent 12071 1f8341f599c4
child 12073 59004900db7f
SDL_exp
CMakeLists.txt
VisualC/SDL/SDL.vcxproj
VisualC/SDL/SDL.vcxproj.filters
configure
configure.in
include/SDL_config.h.cmake
include/SDL_config.h.in
include/SDL_config_android.h
include/SDL_config_iphoneos.h
include/SDL_config_macosx.h
include/SDL_config_pandora.h
include/SDL_config_psp.h
include/SDL_config_windows.h
include/SDL_config_winrt.h
include/SDL_config_wiz.h
include/SDL_stdinc.h
src/dynapi/SDL_dynapi_overrides.h
src/dynapi/SDL_dynapi_procs.h
src/libm/e_exp.c
src/libm/math_libm.h
src/libm/math_private.h
src/stdlib/SDL_stdlib.c
     1.1 --- a/CMakeLists.txt	Thu Aug 02 16:21:43 2018 -0400
     1.2 +++ b/CMakeLists.txt	Sat Aug 04 11:52:46 2018 -0400
     1.3 @@ -650,7 +650,7 @@
     1.4              _ultoa strtol strtoul strtoll strtod atoi atof strcmp strncmp
     1.5              _stricmp _strnicmp sscanf
     1.6              acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf
     1.7 -            copysign copysignf cos cosf fabs fabsf floor floorf fmod fmodf
     1.8 +            copysign copysignf cos cosf exp expf fabs fabsf floor floorf fmod fmodf
     1.9              log logf log10 log10f pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf)
    1.10        string(TOUPPER ${_FN} _UPPER)
    1.11        set(HAVE_${_UPPER} 1)
     2.1 --- a/VisualC/SDL/SDL.vcxproj	Thu Aug 02 16:21:43 2018 -0400
     2.2 +++ b/VisualC/SDL/SDL.vcxproj	Sat Aug 04 11:52:46 2018 -0400
     2.3 @@ -418,6 +418,7 @@
     2.4      <ClCompile Include="..\..\src\joystick\windows\SDL_windowsjoystick.c" />
     2.5      <ClCompile Include="..\..\src\joystick\windows\SDL_xinputjoystick.c" />
     2.6      <ClCompile Include="..\..\src\libm\e_atan2.c" />
     2.7 +    <ClCompile Include="..\..\src\libm\e_exp.c" />
     2.8      <ClCompile Include="..\..\src\libm\e_fmod.c" />
     2.9      <ClCompile Include="..\..\src\libm\e_log.c" />
    2.10      <ClCompile Include="..\..\src\libm\e_log10.c" />
     3.1 --- a/VisualC/SDL/SDL.vcxproj.filters	Thu Aug 02 16:21:43 2018 -0400
     3.2 +++ b/VisualC/SDL/SDL.vcxproj.filters	Sat Aug 04 11:52:46 2018 -0400
     3.3 @@ -316,6 +316,7 @@
     3.4    </ItemGroup>
     3.5    <ItemGroup>
     3.6      <ClCompile Include="..\..\src\libm\e_atan2.c" />
     3.7 +    <ClCompile Include="..\..\src\libm\e_exp.c" />
     3.8      <ClCompile Include="..\..\src\libm\e_log.c" />
     3.9      <ClCompile Include="..\..\src\libm\e_log10.c" />
    3.10      <ClCompile Include="..\..\src\libm\e_pow.c" />
     4.1 --- a/configure	Thu Aug 02 16:21:43 2018 -0400
     4.2 +++ b/configure	Sat Aug 04 11:52:46 2018 -0400
     4.3 @@ -16699,7 +16699,7 @@
     4.4    LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"
     4.5  fi
     4.6  
     4.7 -    for ac_func in acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf fabs fabsf floor floorf fmod fmodf log logf log10 log10f pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf
     4.8 +    for ac_func in acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf exp expf fabs fabsf floor floorf fmod fmodf log logf log10 log10f pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf
     4.9  do :
    4.10    as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
    4.11  ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
     5.1 --- a/configure.in	Thu Aug 02 16:21:43 2018 -0400
     5.2 +++ b/configure.in	Sat Aug 04 11:52:46 2018 -0400
     5.3 @@ -278,7 +278,7 @@
     5.4      AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcscmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval poll)
     5.5  
     5.6      AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
     5.7 -    AC_CHECK_FUNCS(acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf fabs fabsf floor floorf fmod fmodf log logf log10 log10f pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf)
     5.8 +    AC_CHECK_FUNCS(acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf exp expf fabs fabsf floor floorf fmod fmodf log logf log10 log10f pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf)
     5.9  
    5.10      AC_CHECK_LIB(iconv, iconv_open, [LIBS="$LIBS -liconv"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv"])
    5.11      AC_CHECK_FUNCS(iconv)
     6.1 --- a/include/SDL_config.h.cmake	Thu Aug 02 16:21:43 2018 -0400
     6.2 +++ b/include/SDL_config.h.cmake	Sat Aug 04 11:52:46 2018 -0400
     6.3 @@ -144,6 +144,8 @@
     6.4  #cmakedefine HAVE_COPYSIGNF 1
     6.5  #cmakedefine HAVE_COS 1
     6.6  #cmakedefine HAVE_COSF 1
     6.7 +#cmakedefine HAVE_EXP 1
     6.8 +#cmakedefine HAVE_EXPF 1
     6.9  #cmakedefine HAVE_FABS 1
    6.10  #cmakedefine HAVE_FABSF 1
    6.11  #cmakedefine HAVE_FLOOR 1
     7.1 --- a/include/SDL_config.h.in	Thu Aug 02 16:21:43 2018 -0400
     7.2 +++ b/include/SDL_config.h.in	Sat Aug 04 11:52:46 2018 -0400
     7.3 @@ -149,6 +149,8 @@
     7.4  #undef HAVE_COPYSIGNF
     7.5  #undef HAVE_COS
     7.6  #undef HAVE_COSF
     7.7 +#undef HAVE_EXP
     7.8 +#undef HAVE_EXPF
     7.9  #undef HAVE_FABS
    7.10  #undef HAVE_FABSF
    7.11  #undef HAVE_FLOOR
     8.1 --- a/include/SDL_config_android.h	Thu Aug 02 16:21:43 2018 -0400
     8.2 +++ b/include/SDL_config_android.h	Sat Aug 04 11:52:46 2018 -0400
     8.3 @@ -98,6 +98,8 @@
     8.4  #define HAVE_COPYSIGNF  1
     8.5  #define HAVE_COS    1
     8.6  #define HAVE_COSF   1
     8.7 +#define HAVE_EXP    1
     8.8 +#define HAVE_EXPF   1
     8.9  #define HAVE_FABS   1
    8.10  #define HAVE_FABSF  1
    8.11  #define HAVE_FLOOR  1
     9.1 --- a/include/SDL_config_iphoneos.h	Thu Aug 02 16:21:43 2018 -0400
     9.2 +++ b/include/SDL_config_iphoneos.h	Sat Aug 04 11:52:46 2018 -0400
     9.3 @@ -99,6 +99,8 @@
     9.4  #define HAVE_COPYSIGNF  1
     9.5  #define HAVE_COS    1
     9.6  #define HAVE_COSF   1
     9.7 +#define HAVE_EXP    1
     9.8 +#define HAVE_EXPF   1
     9.9  #define HAVE_FABS   1
    9.10  #define HAVE_FABSF  1
    9.11  #define HAVE_FLOOR  1
    10.1 --- a/include/SDL_config_macosx.h	Thu Aug 02 16:21:43 2018 -0400
    10.2 +++ b/include/SDL_config_macosx.h	Sat Aug 04 11:52:46 2018 -0400
    10.3 @@ -102,6 +102,8 @@
    10.4  #define HAVE_COPYSIGNF  1
    10.5  #define HAVE_COS    1
    10.6  #define HAVE_COSF   1
    10.7 +#define HAVE_EXP    1
    10.8 +#define HAVE_EXPF   1
    10.9  #define HAVE_FABS   1
   10.10  #define HAVE_FABSF  1
   10.11  #define HAVE_FLOOR  1
    11.1 --- a/include/SDL_config_pandora.h	Thu Aug 02 16:21:43 2018 -0400
    11.2 +++ b/include/SDL_config_pandora.h	Sat Aug 04 11:52:46 2018 -0400
    11.3 @@ -90,6 +90,7 @@
    11.4  #define HAVE_COPYSIGN 1
    11.5  #define HAVE_COS 1
    11.6  #define HAVE_COSF 1
    11.7 +#define HAVE_EXP 1
    11.8  #define HAVE_FABS 1
    11.9  #define HAVE_FLOOR 1
   11.10  #define HAVE_LOG 1
    12.1 --- a/include/SDL_config_psp.h	Thu Aug 02 16:21:43 2018 -0400
    12.2 +++ b/include/SDL_config_psp.h	Sat Aug 04 11:52:46 2018 -0400
    12.3 @@ -97,6 +97,8 @@
    12.4  #define HAVE_COPYSIGNF  1
    12.5  #define HAVE_COS    1
    12.6  #define HAVE_COSF   1
    12.7 +#define HAVE_EXP    1
    12.8 +#define HAVE_EXPF   1
    12.9  #define HAVE_FABS   1
   12.10  #define HAVE_FABSF  1
   12.11  #define HAVE_FLOOR  1
    13.1 --- a/include/SDL_config_windows.h	Thu Aug 02 16:21:43 2018 -0400
    13.2 +++ b/include/SDL_config_windows.h	Sat Aug 04 11:52:46 2018 -0400
    13.3 @@ -139,6 +139,8 @@
    13.4  #define HAVE__COPYSIGN  1
    13.5  #define HAVE_COS    1
    13.6  #define HAVE_COSF   1
    13.7 +#define HAVE_EXP    1
    13.8 +#define HAVE_EXPF   1
    13.9  #define HAVE_FABS   1
   13.10  #define HAVE_FABSF  1
   13.11  #define HAVE_FLOOR  1
    14.1 --- a/include/SDL_config_winrt.h	Thu Aug 02 16:21:43 2018 -0400
    14.2 +++ b/include/SDL_config_winrt.h	Sat Aug 04 11:52:46 2018 -0400
    14.3 @@ -155,6 +155,8 @@
    14.4  #define HAVE__COPYSIGN 1
    14.5  #define HAVE_COS    1
    14.6  #define HAVE_COSF   1
    14.7 +#define HAVE_EXP    1
    14.8 +#define HAVE_EXPF   1
    14.9  #define HAVE_FABS   1
   14.10  #define HAVE_FABSF  1
   14.11  #define HAVE_FLOOR  1
    15.1 --- a/include/SDL_config_wiz.h	Thu Aug 02 16:21:43 2018 -0400
    15.2 +++ b/include/SDL_config_wiz.h	Sat Aug 04 11:52:46 2018 -0400
    15.3 @@ -94,6 +94,8 @@
    15.4  #define HAVE_COPYSIGNF  1
    15.5  #define HAVE_COS    1
    15.6  #define HAVE_COSF   1
    15.7 +#define HAVE_EXP    1
    15.8 +#define HAVE_EXPF   1
    15.9  #define HAVE_FABS   1
   15.10  #define HAVE_FABSF  1
   15.11  #define HAVE_FLOOR  1
    16.1 --- a/include/SDL_stdinc.h	Thu Aug 02 16:21:43 2018 -0400
    16.2 +++ b/include/SDL_stdinc.h	Sat Aug 04 11:52:46 2018 -0400
    16.3 @@ -513,6 +513,8 @@
    16.4  extern DECLSPEC float SDLCALL SDL_copysignf(float x, float y);
    16.5  extern DECLSPEC double SDLCALL SDL_cos(double x);
    16.6  extern DECLSPEC float SDLCALL SDL_cosf(float x);
    16.7 +extern DECLSPEC double SDLCALL SDL_exp(double x);
    16.8 +extern DECLSPEC float SDLCALL SDL_expf(float x);
    16.9  extern DECLSPEC double SDLCALL SDL_fabs(double x);
   16.10  extern DECLSPEC float SDLCALL SDL_fabsf(float x);
   16.11  extern DECLSPEC double SDLCALL SDL_floor(double x);
    17.1 --- a/src/dynapi/SDL_dynapi_overrides.h	Thu Aug 02 16:21:43 2018 -0400
    17.2 +++ b/src/dynapi/SDL_dynapi_overrides.h	Sat Aug 04 11:52:46 2018 -0400
    17.3 @@ -675,3 +675,5 @@
    17.4  #define SDL_IsChromebook SDL_IsChromebook_REAL
    17.5  #define SDL_IsDeXMode SDL_IsDeXMode_REAL
    17.6  #define SDL_AndroidBackButton SDL_AndroidBackButton_REAL
    17.7 +#define SDL_exp SDL_exp_REAL
    17.8 +#define SDL_expf SDL_expf_REAL
    18.1 --- a/src/dynapi/SDL_dynapi_procs.h	Thu Aug 02 16:21:43 2018 -0400
    18.2 +++ b/src/dynapi/SDL_dynapi_procs.h	Sat Aug 04 11:52:46 2018 -0400
    18.3 @@ -719,3 +719,5 @@
    18.4  #ifdef __ANDROID__
    18.5  SDL_DYNAPI_PROC(void,SDL_AndroidBackButton,(void),(),return)
    18.6  #endif
    18.7 +SDL_DYNAPI_PROC(double,SDL_exp,(double a),(a),return)
    18.8 +SDL_DYNAPI_PROC(float,SDL_expf,(float a),(a),return)
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/src/libm/e_exp.c	Sat Aug 04 11:52:46 2018 -0400
    19.3 @@ -0,0 +1,182 @@
    19.4 +/*
    19.5 + * ====================================================
    19.6 + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
    19.7 + *
    19.8 + * Developed at SunPro, a Sun Microsystems, Inc. business.
    19.9 + * Permission to use, copy, modify, and distribute this
   19.10 + * software is freely granted, provided that this notice
   19.11 + * is preserved.
   19.12 + * ====================================================
   19.13 + */
   19.14 +
   19.15 +/* __ieee754_exp(x)
   19.16 + * Returns the exponential of x.
   19.17 + *
   19.18 + * Method
   19.19 + *   1. Argument reduction:
   19.20 + *      Reduce x to an r so that |r| <= 0.5*ln2 ~ 0.34658.
   19.21 + *	Given x, find r and integer k such that
   19.22 + *
   19.23 + *               x = k*ln2 + r,  |r| <= 0.5*ln2.
   19.24 + *
   19.25 + *      Here r will be represented as r = hi-lo for better
   19.26 + *	accuracy.
   19.27 + *
   19.28 + *   2. Approximation of exp(r) by a special rational function on
   19.29 + *	the interval [0,0.34658]:
   19.30 + *	Write
   19.31 + *	    R(r**2) = r*(exp(r)+1)/(exp(r)-1) = 2 + r*r/6 - r**4/360 + ...
   19.32 + *      We use a special Reme algorithm on [0,0.34658] to generate
   19.33 + * 	a polynomial of degree 5 to approximate R. The maximum error
   19.34 + *	of this polynomial approximation is bounded by 2**-59. In
   19.35 + *	other words,
   19.36 + *	    R(z) ~ 2.0 + P1*z + P2*z**2 + P3*z**3 + P4*z**4 + P5*z**5
   19.37 + *  	(where z=r*r, and the values of P1 to P5 are listed below)
   19.38 + *	and
   19.39 + *	    |                  5          |     -59
   19.40 + *	    | 2.0+P1*z+...+P5*z   -  R(z) | <= 2
   19.41 + *	    |                             |
   19.42 + *	The computation of exp(r) thus becomes
   19.43 + *                             2*r
   19.44 + *		exp(r) = 1 + -------
   19.45 + *		              R - r
   19.46 + *                                 r*R1(r)
   19.47 + *		       = 1 + r + ----------- (for better accuracy)
   19.48 + *		                  2 - R1(r)
   19.49 + *	where
   19.50 + *			         2       4             10
   19.51 + *		R1(r) = r - (P1*r  + P2*r  + ... + P5*r   ).
   19.52 + *
   19.53 + *   3. Scale back to obtain exp(x):
   19.54 + *	From step 1, we have
   19.55 + *	   exp(x) = 2^k * exp(r)
   19.56 + *
   19.57 + * Special cases:
   19.58 + *	exp(INF) is INF, exp(NaN) is NaN;
   19.59 + *	exp(-INF) is 0, and
   19.60 + *	for finite argument, only exp(0)=1 is exact.
   19.61 + *
   19.62 + * Accuracy:
   19.63 + *	according to an error analysis, the error is always less than
   19.64 + *	1 ulp (unit in the last place).
   19.65 + *
   19.66 + * Misc. info.
   19.67 + *	For IEEE double
   19.68 + *	    if x >  7.09782712893383973096e+02 then exp(x) overflow
   19.69 + *	    if x < -7.45133219101941108420e+02 then exp(x) underflow
   19.70 + *
   19.71 + * Constants:
   19.72 + * The hexadecimal values are the intended ones for the following
   19.73 + * constants. The decimal values may be used, provided that the
   19.74 + * compiler will convert from decimal to binary accurately enough
   19.75 + * to produce the hexadecimal values shown.
   19.76 + */
   19.77 +
   19.78 +#include "math_libm.h"
   19.79 +#include "math_private.h"
   19.80 +
   19.81 +static const double
   19.82 +one	= 1.0,
   19.83 +halF[2]	= {0.5,-0.5,},
   19.84 +huge	= 1.0e+300,
   19.85 +twom1000= 9.33263618503218878990e-302,     /* 2**-1000=0x01700000,0*/
   19.86 +o_threshold=  7.09782712893383973096e+02,  /* 0x40862E42, 0xFEFA39EF */
   19.87 +u_threshold= -7.45133219101941108420e+02,  /* 0xc0874910, 0xD52D3051 */
   19.88 +ln2HI[2]   ={ 6.93147180369123816490e-01,  /* 0x3fe62e42, 0xfee00000 */
   19.89 +	     -6.93147180369123816490e-01,},/* 0xbfe62e42, 0xfee00000 */
   19.90 +ln2LO[2]   ={ 1.90821492927058770002e-10,  /* 0x3dea39ef, 0x35793c76 */
   19.91 +	     -1.90821492927058770002e-10,},/* 0xbdea39ef, 0x35793c76 */
   19.92 +invln2 =  1.44269504088896338700e+00, /* 0x3ff71547, 0x652b82fe */
   19.93 +P1   =  1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */
   19.94 +P2   = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */
   19.95 +P3   =  6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
   19.96 +P4   = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
   19.97 +P5   =  4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
   19.98 +
   19.99 +double __ieee754_exp(double x)	/* default IEEE double exp */
  19.100 +{
  19.101 +	double y;
  19.102 +	double hi = 0.0;
  19.103 +	double lo = 0.0;
  19.104 +	double c;
  19.105 +	double t;
  19.106 +	int32_t k=0;
  19.107 +	int32_t xsb;
  19.108 +	u_int32_t hx;
  19.109 +
  19.110 +	GET_HIGH_WORD(hx,x);
  19.111 +	xsb = (hx>>31)&1;		/* sign bit of x */
  19.112 +	hx &= 0x7fffffff;		/* high word of |x| */
  19.113 +
  19.114 +    /* filter out non-finite argument */
  19.115 +	if(hx >= 0x40862E42) {			/* if |x|>=709.78... */
  19.116 +            if(hx>=0x7ff00000) {
  19.117 +	        u_int32_t lx;
  19.118 +		GET_LOW_WORD(lx,x);
  19.119 +		if(((hx&0xfffff)|lx)!=0)
  19.120 +		     return x+x; 		/* NaN */
  19.121 +		else return (xsb==0)? x:0.0;	/* exp(+-inf)={inf,0} */
  19.122 +	    }
  19.123 +	    if(x > o_threshold) return huge*huge; /* overflow */
  19.124 +	    if(x < u_threshold) return twom1000*twom1000; /* underflow */
  19.125 +	}
  19.126 +
  19.127 +    /* argument reduction */
  19.128 +	if(hx > 0x3fd62e42) {		/* if  |x| > 0.5 ln2 */
  19.129 +	    if(hx < 0x3FF0A2B2) {	/* and |x| < 1.5 ln2 */
  19.130 +		hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb;
  19.131 +	    } else {
  19.132 +		k  = invln2*x+halF[xsb];
  19.133 +		t  = k;
  19.134 +		hi = x - t*ln2HI[0];	/* t*ln2HI is exact here */
  19.135 +		lo = t*ln2LO[0];
  19.136 +	    }
  19.137 +	    x  = hi - lo;
  19.138 +	}
  19.139 +	else if(hx < 0x3e300000)  {	/* when |x|<2**-28 */
  19.140 +	    if(huge+x>one) return one+x;/* trigger inexact */
  19.141 +	}
  19.142 +	else k = 0;
  19.143 +
  19.144 +    /* x is now in primary range */
  19.145 +	t  = x*x;
  19.146 +	c  = x - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
  19.147 +	if(k==0) 	return one-((x*c)/(c-2.0)-x);
  19.148 +	else 		y = one-((lo-(x*c)/(2.0-c))-hi);
  19.149 +	if(k >= -1021) {
  19.150 +	    u_int32_t hy;
  19.151 +	    GET_HIGH_WORD(hy,y);
  19.152 +	    SET_HIGH_WORD(y,hy+(k<<20));	/* add k to y's exponent */
  19.153 +	    return y;
  19.154 +	} else {
  19.155 +	    u_int32_t hy;
  19.156 +	    GET_HIGH_WORD(hy,y);
  19.157 +	    SET_HIGH_WORD(y,hy+((k+1000)<<20));	/* add k to y's exponent */
  19.158 +	    return y*twom1000;
  19.159 +	}
  19.160 +}
  19.161 +
  19.162 +/*
  19.163 + * wrapper exp(x)
  19.164 + */
  19.165 +#ifndef _IEEE_LIBM
  19.166 +double exp(double x)
  19.167 +{
  19.168 +	static const double o_threshold =  7.09782712893383973096e+02; /* 0x40862E42, 0xFEFA39EF */
  19.169 +	static const double u_threshold = -7.45133219101941108420e+02; /* 0xc0874910, 0xD52D3051 */
  19.170 +
  19.171 +	double z = __ieee754_exp(x);
  19.172 +	if (_LIB_VERSION == _IEEE_)
  19.173 +		return z;
  19.174 +	if (isfinite(x)) {
  19.175 +		if (x > o_threshold)
  19.176 +			return __kernel_standard(x, x, 6); /* exp overflow */
  19.177 +		if (x < u_threshold)
  19.178 +			return __kernel_standard(x, x, 7); /* exp underflow */
  19.179 +	}
  19.180 +	return z;
  19.181 +}
  19.182 +#else
  19.183 +strong_alias(__ieee754_exp, exp)
  19.184 +#endif
  19.185 +libm_hidden_def(exp)
    20.1 --- a/src/libm/math_libm.h	Thu Aug 02 16:21:43 2018 -0400
    20.2 +++ b/src/libm/math_libm.h	Sat Aug 04 11:52:46 2018 -0400
    20.3 @@ -26,6 +26,7 @@
    20.4  double SDL_uclibc_atan2(double y, double x);    
    20.5  double SDL_uclibc_copysign(double x, double y);       
    20.6  double SDL_uclibc_cos(double x);         
    20.7 +double SDL_uclibc_exp(double x);
    20.8  double SDL_uclibc_fabs(double x);        
    20.9  double SDL_uclibc_floor(double x);
   20.10  double SDL_uclibc_fmod(double x, double y);
    21.1 --- a/src/libm/math_private.h	Thu Aug 02 16:21:43 2018 -0400
    21.2 +++ b/src/libm/math_private.h	Sat Aug 04 11:52:46 2018 -0400
    21.3 @@ -35,6 +35,7 @@
    21.4  #define __ieee754_atan2 SDL_uclibc_atan2
    21.5  #define copysign        SDL_uclibc_copysign
    21.6  #define cos             SDL_uclibc_cos
    21.7 +#define __ieee754_exp   SDL_uclibc_exp
    21.8  #define fabs            SDL_uclibc_fabs
    21.9  #define floor           SDL_uclibc_floor
   21.10  #define __ieee754_fmod  SDL_uclibc_fmod
    22.1 --- a/src/stdlib/SDL_stdlib.c	Thu Aug 02 16:21:43 2018 -0400
    22.2 +++ b/src/stdlib/SDL_stdlib.c	Sat Aug 04 11:52:46 2018 -0400
    22.3 @@ -201,6 +201,26 @@
    22.4  }
    22.5  
    22.6  double
    22.7 +SDL_exp(double x)
    22.8 +{
    22.9 +#if defined(HAVE_EXP)
   22.10 +    return exp(x);
   22.11 +#else
   22.12 +    return SDL_uclibc_exp(x);
   22.13 +#endif
   22.14 +}
   22.15 +
   22.16 +float
   22.17 +SDL_expf(float x)
   22.18 +{
   22.19 +#if defined(HAVE_EXPF)
   22.20 +    return expf(x);
   22.21 +#else
   22.22 +    return (float)SDL_uclibc_exp((double)x);
   22.23 +#endif
   22.24 +}
   22.25 +
   22.26 +double
   22.27  SDL_fabs(double x)
   22.28  {
   22.29  #if defined(HAVE_FABS)