SDL_log10
authorEthan Lee <flibitijibibo@flibitijibibo.com>
Wed, 17 Jan 2018 11:53:09 -0500
changeset 11852c3fc99758ad2
parent 11851 8f295e7acefd
child 11853 c7946b873fe8
SDL_log10
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
src/libm/e_log10.c
src/libm/math_libm.h
src/libm/math_private.h
src/stdlib/SDL_stdlib.c
     1.1 --- a/CMakeLists.txt	Wed Feb 07 14:12:26 2018 -0800
     1.2 +++ b/CMakeLists.txt	Wed Jan 17 11:53:09 2018 -0500
     1.3 @@ -643,7 +643,7 @@
     1.4              _stricmp _strnicmp sscanf
     1.5              acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf
     1.6              copysign copysignf cos cosf fabs fabsf floor floorf fmod fmodf
     1.7 -            log logf pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf)
     1.8 +            log logf log10 log10f pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf)
     1.9        string(TOUPPER ${_FN} _UPPER)
    1.10        set(HAVE_${_UPPER} 1)
    1.11      endforeach()
     2.1 --- a/VisualC/SDL/SDL.vcxproj	Wed Feb 07 14:12:26 2018 -0800
     2.2 +++ b/VisualC/SDL/SDL.vcxproj	Wed Jan 17 11:53:09 2018 -0500
     2.3 @@ -420,6 +420,7 @@
     2.4      <ClCompile Include="..\..\src\libm\e_atan2.c" />
     2.5      <ClCompile Include="..\..\src\libm\e_fmod.c" />
     2.6      <ClCompile Include="..\..\src\libm\e_log.c" />
     2.7 +    <ClCompile Include="..\..\src\libm\e_log10.c" />
     2.8      <ClCompile Include="..\..\src\libm\e_pow.c" />
     2.9      <ClCompile Include="..\..\src\libm\e_rem_pio2.c" />
    2.10      <ClCompile Include="..\..\src\libm\e_sqrt.c" />
     3.1 --- a/VisualC/SDL/SDL.vcxproj.filters	Wed Feb 07 14:12:26 2018 -0800
     3.2 +++ b/VisualC/SDL/SDL.vcxproj.filters	Wed Jan 17 11:53:09 2018 -0500
     3.3 @@ -317,6 +317,7 @@
     3.4    <ItemGroup>
     3.5      <ClCompile Include="..\..\src\libm\e_atan2.c" />
     3.6      <ClCompile Include="..\..\src\libm\e_log.c" />
     3.7 +    <ClCompile Include="..\..\src\libm\e_log10.c" />
     3.8      <ClCompile Include="..\..\src\libm\e_pow.c" />
     3.9      <ClCompile Include="..\..\src\libm\e_rem_pio2.c" />
    3.10      <ClCompile Include="..\..\src\libm\e_sqrt.c" />
     4.1 --- a/configure	Wed Feb 07 14:12:26 2018 -0800
     4.2 +++ b/configure	Wed Jan 17 11:53:09 2018 -0500
     4.3 @@ -16690,7 +16690,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 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 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	Wed Feb 07 14:12:26 2018 -0800
     5.2 +++ b/configure.in	Wed Jan 17 11:53:09 2018 -0500
     5.3 @@ -271,7 +271,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 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 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	Wed Feb 07 14:12:26 2018 -0800
     6.2 +++ b/include/SDL_config.h.cmake	Wed Jan 17 11:53:09 2018 -0500
     6.3 @@ -152,6 +152,8 @@
     6.4  #cmakedefine HAVE_FMODF 1
     6.5  #cmakedefine HAVE_LOG 1
     6.6  #cmakedefine HAVE_LOGF 1
     6.7 +#cmakedefine HAVE_LOG10 1
     6.8 +#cmakedefine HAVE_LOG10F 1
     6.9  #cmakedefine HAVE_POW 1
    6.10  #cmakedefine HAVE_POWF 1
    6.11  #cmakedefine HAVE_SCALBN 1
     7.1 --- a/include/SDL_config.h.in	Wed Feb 07 14:12:26 2018 -0800
     7.2 +++ b/include/SDL_config.h.in	Wed Jan 17 11:53:09 2018 -0500
     7.3 @@ -157,6 +157,8 @@
     7.4  #undef HAVE_FMODF
     7.5  #undef HAVE_LOG
     7.6  #undef HAVE_LOGF
     7.7 +#undef HAVE_LOG10
     7.8 +#undef HAVE_LOG10F
     7.9  #undef HAVE_POW
    7.10  #undef HAVE_POWF
    7.11  #undef HAVE_SCALBN
     8.1 --- a/include/SDL_config_android.h	Wed Feb 07 14:12:26 2018 -0800
     8.2 +++ b/include/SDL_config_android.h	Wed Jan 17 11:53:09 2018 -0500
     8.3 @@ -106,6 +106,8 @@
     8.4  #define HAVE_FMODF  1
     8.5  #define HAVE_LOG    1
     8.6  #define HAVE_LOGF   1
     8.7 +#define HAVE_LOG10  1
     8.8 +#define HAVE_LOG10F 1
     8.9  #define HAVE_POW    1
    8.10  #define HAVE_POWF   1
    8.11  #define HAVE_SCALBN 1
     9.1 --- a/include/SDL_config_iphoneos.h	Wed Feb 07 14:12:26 2018 -0800
     9.2 +++ b/include/SDL_config_iphoneos.h	Wed Jan 17 11:53:09 2018 -0500
     9.3 @@ -107,6 +107,8 @@
     9.4  #define HAVE_FMODF  1
     9.5  #define HAVE_LOG    1
     9.6  #define HAVE_LOGF   1
     9.7 +#define HAVE_LOG10  1
     9.8 +#define HAVE_LOG10F 1
     9.9  #define HAVE_POW    1
    9.10  #define HAVE_POWF   1
    9.11  #define HAVE_SCALBN 1
    10.1 --- a/include/SDL_config_macosx.h	Wed Feb 07 14:12:26 2018 -0800
    10.2 +++ b/include/SDL_config_macosx.h	Wed Jan 17 11:53:09 2018 -0500
    10.3 @@ -110,6 +110,8 @@
    10.4  #define HAVE_FMODF  1
    10.5  #define HAVE_LOG    1
    10.6  #define HAVE_LOGF   1
    10.7 +#define HAVE_LOG10  1
    10.8 +#define HAVE_LOG10F 1
    10.9  #define HAVE_POW    1
   10.10  #define HAVE_POWF   1
   10.11  #define HAVE_SCALBN 1
    11.1 --- a/include/SDL_config_pandora.h	Wed Feb 07 14:12:26 2018 -0800
    11.2 +++ b/include/SDL_config_pandora.h	Wed Jan 17 11:53:09 2018 -0500
    11.3 @@ -93,6 +93,7 @@
    11.4  #define HAVE_FABS 1
    11.5  #define HAVE_FLOOR 1
    11.6  #define HAVE_LOG 1
    11.7 +#define HAVE_LOG10 1
    11.8  #define HAVE_SCALBN 1
    11.9  #define HAVE_SIN 1
   11.10  #define HAVE_SINF 1
    12.1 --- a/include/SDL_config_psp.h	Wed Feb 07 14:12:26 2018 -0800
    12.2 +++ b/include/SDL_config_psp.h	Wed Jan 17 11:53:09 2018 -0500
    12.3 @@ -105,6 +105,8 @@
    12.4  #define HAVE_FMODF  1
    12.5  #define HAVE_LOG    1
    12.6  #define HAVE_LOGF   1
    12.7 +#define HAVE_LOG10  1
    12.8 +#define HAVE_LOG10F 1
    12.9  #define HAVE_POW    1
   12.10  #define HAVE_POWF   1
   12.11  #define HAVE_SCALBN 1
    13.1 --- a/include/SDL_config_windows.h	Wed Feb 07 14:12:26 2018 -0800
    13.2 +++ b/include/SDL_config_windows.h	Wed Jan 17 11:53:09 2018 -0500
    13.3 @@ -147,6 +147,8 @@
    13.4  #define HAVE_FMODF  1
    13.5  #define HAVE_LOG    1
    13.6  #define HAVE_LOGF   1
    13.7 +#define HAVE_LOG10  1
    13.8 +#define HAVE_LOG10F 1
    13.9  #define HAVE_POW    1
   13.10  #define HAVE_POWF   1
   13.11  #define HAVE_SIN    1
    14.1 --- a/include/SDL_config_winrt.h	Wed Feb 07 14:12:26 2018 -0800
    14.2 +++ b/include/SDL_config_winrt.h	Wed Jan 17 11:53:09 2018 -0500
    14.3 @@ -163,6 +163,8 @@
    14.4  #define HAVE_FMODF  1
    14.5  #define HAVE_LOG    1
    14.6  #define HAVE_LOGF   1
    14.7 +#define HAVE_LOG10  1
    14.8 +#define HAVE_LOG10F 1
    14.9  #define HAVE_POW    1
   14.10  #define HAVE_POWF   1
   14.11  #define HAVE__SCALB 1
    15.1 --- a/include/SDL_config_wiz.h	Wed Feb 07 14:12:26 2018 -0800
    15.2 +++ b/include/SDL_config_wiz.h	Wed Jan 17 11:53:09 2018 -0500
    15.3 @@ -102,6 +102,8 @@
    15.4  #define HAVE_FMODF  1
    15.5  #define HAVE_LOG    1
    15.6  #define HAVE_LOGF   1
    15.7 +#define HAVE_LOG10  1
    15.8 +#define HAVE_LOG10F 1
    15.9  #define HAVE_POW    1
   15.10  #define HAVE_POWF   1
   15.11  #define HAVE_SCALBN 1
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/src/libm/e_log10.c	Wed Jan 17 11:53:09 2018 -0500
    16.3 @@ -0,0 +1,106 @@
    16.4 +/*
    16.5 + * ====================================================
    16.6 + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
    16.7 + *
    16.8 + * Developed at SunPro, a Sun Microsystems, Inc. business.
    16.9 + * Permission to use, copy, modify, and distribute this
   16.10 + * software is freely granted, provided that this notice
   16.11 + * is preserved.
   16.12 + * ====================================================
   16.13 + */
   16.14 +
   16.15 +#if defined(_MSC_VER)           /* Handle Microsoft VC++ compiler specifics. */
   16.16 +/* C4723: potential divide by zero. */
   16.17 +#pragma warning ( disable : 4723 )
   16.18 +#endif
   16.19 +
   16.20 +/* __ieee754_log10(x)
   16.21 + * Return the base 10 logarithm of x
   16.22 + *
   16.23 + * Method :
   16.24 + *	Let log10_2hi = leading 40 bits of log10(2) and
   16.25 + *	    log10_2lo = log10(2) - log10_2hi,
   16.26 + *	    ivln10   = 1/log(10) rounded.
   16.27 + *	Then
   16.28 + *		n = ilogb(x),
   16.29 + *		if(n<0)  n = n+1;
   16.30 + *		x = scalbn(x,-n);
   16.31 + *		log10(x) := n*log10_2hi + (n*log10_2lo + ivln10*log(x))
   16.32 + *
   16.33 + * Note 1:
   16.34 + *	To guarantee log10(10**n)=n, where 10**n is normal, the rounding
   16.35 + *	mode must set to Round-to-Nearest.
   16.36 + * Note 2:
   16.37 + *	[1/log(10)] rounded to 53 bits has error  .198   ulps;
   16.38 + *	log10 is monotonic at all binary break points.
   16.39 + *
   16.40 + * Special cases:
   16.41 + *	log10(x) is NaN with signal if x < 0;
   16.42 + *	log10(+INF) is +INF with no signal; log10(0) is -INF with signal;
   16.43 + *	log10(NaN) is that NaN with no signal;
   16.44 + *	log10(10**N) = N  for N=0,1,...,22.
   16.45 + *
   16.46 + * Constants:
   16.47 + * The hexadecimal values are the intended ones for the following constants.
   16.48 + * The decimal values may be used, provided that the compiler will convert
   16.49 + * from decimal to binary accurately enough to produce the hexadecimal values
   16.50 + * shown.
   16.51 + */
   16.52 +
   16.53 +#include "math_libm.h"
   16.54 +#include "math_private.h"
   16.55 +
   16.56 +static const double
   16.57 +two54      =  1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
   16.58 +ivln10     =  4.34294481903251816668e-01, /* 0x3FDBCB7B, 0x1526E50E */
   16.59 +log10_2hi  =  3.01029995663611771306e-01, /* 0x3FD34413, 0x509F6000 */
   16.60 +log10_2lo  =  3.69423907715893078616e-13; /* 0x3D59FEF3, 0x11F12B36 */
   16.61 +
   16.62 +static const double zero = 0.0;
   16.63 +
   16.64 +double attribute_hidden __ieee754_log10(double x)
   16.65 +{
   16.66 +	double y,z;
   16.67 +	int32_t i,k,hx;
   16.68 +	u_int32_t lx;
   16.69 +
   16.70 +	EXTRACT_WORDS(hx,lx,x);
   16.71 +
   16.72 +        k=0;
   16.73 +        if (hx < 0x00100000) {                  /* x < 2**-1022  */
   16.74 +            if (((hx&0x7fffffff)|lx)==0)
   16.75 +                return -two54/zero;             /* log(+-0)=-inf */
   16.76 +            if (hx<0) return (x-x)/zero;        /* log(-#) = NaN */
   16.77 +            k -= 54; x *= two54; /* subnormal number, scale up x */
   16.78 +	    GET_HIGH_WORD(hx,x);
   16.79 +        }
   16.80 +	if (hx >= 0x7ff00000) return x+x;
   16.81 +	k += (hx>>20)-1023;
   16.82 +	i  = ((u_int32_t)k&0x80000000)>>31;
   16.83 +        hx = (hx&0x000fffff)|((0x3ff-i)<<20);
   16.84 +        y  = (double)(k+i);
   16.85 +	SET_HIGH_WORD(x,hx);
   16.86 +	z  = y*log10_2lo + ivln10*__ieee754_log(x);
   16.87 +	return  z+y*log10_2hi;
   16.88 +}
   16.89 +
   16.90 +/*
   16.91 + * wrapper log10(X)
   16.92 + */
   16.93 +#ifndef _IEEE_LIBM
   16.94 +double log10(double x)
   16.95 +{
   16.96 +	double z = __ieee754_log10(x);
   16.97 +	if (_LIB_VERSION == _IEEE_ || isnan(x))
   16.98 +		return z;
   16.99 +	if (x <= 0.0) {
  16.100 +		if(x == 0.0)
  16.101 +			return __kernel_standard(x, x, 18); /* log10(0) */
  16.102 +		return __kernel_standard(x, x, 19); /* log10(x<0) */
  16.103 +	}
  16.104 +	return z;
  16.105 +}
  16.106 +#else
  16.107 +strong_alias(__ieee754_log10, log10)
  16.108 +#endif
  16.109 +libm_hidden_def(log10)
    17.1 --- a/src/libm/math_libm.h	Wed Feb 07 14:12:26 2018 -0800
    17.2 +++ b/src/libm/math_libm.h	Wed Jan 17 11:53:09 2018 -0500
    17.3 @@ -30,6 +30,7 @@
    17.4  double SDL_uclibc_floor(double x);
    17.5  double SDL_uclibc_fmod(double x, double y);
    17.6  double SDL_uclibc_log(double x);
    17.7 +double SDL_uclibc_log10(double x);
    17.8  double SDL_uclibc_pow(double x, double y);    
    17.9  double SDL_uclibc_scalbn(double x, int n);
   17.10  double SDL_uclibc_sin(double x);
    18.1 --- a/src/libm/math_private.h	Wed Feb 07 14:12:26 2018 -0800
    18.2 +++ b/src/libm/math_private.h	Wed Jan 17 11:53:09 2018 -0500
    18.3 @@ -39,6 +39,7 @@
    18.4  #define floor           SDL_uclibc_floor
    18.5  #define __ieee754_fmod  SDL_uclibc_fmod
    18.6  #define __ieee754_log   SDL_uclibc_log
    18.7 +#define __ieee754_log10 SDL_uclibc_log10
    18.8  #define __ieee754_pow   SDL_uclibc_pow
    18.9  #define scalbln         SDL_uclibc_scalbln
   18.10  #define scalbn          SDL_uclibc_scalbn
    19.1 --- a/src/stdlib/SDL_stdlib.c	Wed Feb 07 14:12:26 2018 -0800
    19.2 +++ b/src/stdlib/SDL_stdlib.c	Wed Jan 17 11:53:09 2018 -0500
    19.3 @@ -281,6 +281,26 @@
    19.4  }
    19.5  
    19.6  double
    19.7 +SDL_log10(double x)
    19.8 +{
    19.9 +#if defined(HAVE_LOG10)
   19.10 +    return log10(x);
   19.11 +#else
   19.12 +    return SDL_uclibc_log10(x);
   19.13 +#endif
   19.14 +}
   19.15 +
   19.16 +float
   19.17 +SDL_log10f(float x)
   19.18 +{
   19.19 +#if defined(HAVE_LOG10F)
   19.20 +    return log10f(x);
   19.21 +#else
   19.22 +    return (float)SDL_log10((double)x);
   19.23 +#endif
   19.24 +}
   19.25 +
   19.26 +double
   19.27  SDL_pow(double x, double y)
   19.28  {
   19.29  #if defined(HAVE_POW)