Added SDL_round(), contributed by Benoit Pierre - thanks!
authorSam Lantinga <slouken@libsdl.org>
Sat, 16 Aug 2014 23:23:15 -0700
changeset 9075257a6793aaf5
parent 9074 86a6f6d92960
child 9076 5e713281410c
Added SDL_round(), contributed by Benoit Pierre - thanks!
CMakeLists.txt
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/math_libm.h
src/libm/math_private.h
src/stdlib/SDL_stdlib.c
     1.1 --- a/CMakeLists.txt	Sat Aug 16 23:17:47 2014 -0700
     1.2 +++ b/CMakeLists.txt	Sat Aug 16 23:23:15 2014 -0700
     1.3 @@ -495,7 +495,7 @@
     1.4              strlen _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa
     1.5              _ultoa strtol strtoul strtoll strtod atoi atof strcmp strncmp
     1.6              _stricmp _strnicmp sscanf atan atan2 acos asin ceil copysign cos
     1.7 -            cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf)
     1.8 +            cosf fabs floor log pow round scalbn sin sinf sqrt sqrtf tan tanf)
     1.9        string(TOUPPER ${_FN} _UPPER)
    1.10        set(HAVE_${_UPPER} 1)
    1.11      endforeach()
    1.12 @@ -541,7 +541,7 @@
    1.13      if(HAVE_LIBM)
    1.14        set(CMAKE_REQUIRED_LIBRARIES m)
    1.15        foreach(_FN
    1.16 -              atan atan2 ceil copysign cos cosf fabs floor log pow scalbn sin
    1.17 +              atan atan2 ceil copysign cos cosf fabs floor log pow round scalbn sin
    1.18                sinf sqrt sqrtf tan tanf)
    1.19          string(TOUPPER ${_FN} _UPPER)
    1.20          set(_HAVEVAR "HAVE_${_UPPER}")
     2.1 --- a/configure	Sat Aug 16 23:17:47 2014 -0700
     2.2 +++ b/configure	Sat Aug 16 23:23:15 2014 -0700
     2.3 @@ -16641,7 +16641,7 @@
     2.4    LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"
     2.5  fi
     2.6  
     2.7 -    for ac_func in atan atan2 acos asin ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf
     2.8 +    for ac_func in atan atan2 acos asin ceil copysign cos cosf fabs floor log pow round scalbn sin sinf sqrt sqrtf tan tanf
     2.9  do :
    2.10    as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
    2.11  ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
     3.1 --- a/configure.in	Sat Aug 16 23:17:47 2014 -0700
     3.2 +++ b/configure.in	Sat Aug 16 23:23:15 2014 -0700
     3.3 @@ -271,7 +271,7 @@
     3.4      AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _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 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname)
     3.5  
     3.6      AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
     3.7 -    AC_CHECK_FUNCS(atan atan2 acos asin ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf)
     3.8 +    AC_CHECK_FUNCS(atan atan2 acos asin ceil copysign cos cosf fabs floor log pow round scalbn sin sinf sqrt sqrtf tan tanf)
     3.9  
    3.10      AC_CHECK_LIB(iconv, iconv_open, [LIBS="$LIBS -liconv"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv"])
    3.11      AC_CHECK_FUNCS(iconv)
     4.1 --- a/include/SDL_config.h.cmake	Sat Aug 16 23:17:47 2014 -0700
     4.2 +++ b/include/SDL_config.h.cmake	Sat Aug 16 23:23:15 2014 -0700
     4.3 @@ -140,6 +140,7 @@
     4.4  #cmakedefine HAVE_FLOOR 1
     4.5  #cmakedefine HAVE_LOG 1
     4.6  #cmakedefine HAVE_POW 1
     4.7 +#cmakedefine HAVE_ROUND 1
     4.8  #cmakedefine HAVE_SCALBN 1
     4.9  #cmakedefine HAVE_SIN 1
    4.10  #cmakedefine HAVE_SINF 1
     5.1 --- a/include/SDL_config.h.in	Sat Aug 16 23:17:47 2014 -0700
     5.2 +++ b/include/SDL_config.h.in	Sat Aug 16 23:23:15 2014 -0700
     5.3 @@ -150,6 +150,7 @@
     5.4  #undef HAVE_FLOOR
     5.5  #undef HAVE_LOG
     5.6  #undef HAVE_POW
     5.7 +#undef HAVE_ROUND
     5.8  #undef HAVE_SCALBN
     5.9  #undef HAVE_SIN
    5.10  #undef HAVE_SINF
     6.1 --- a/include/SDL_config_android.h	Sat Aug 16 23:17:47 2014 -0700
     6.2 +++ b/include/SDL_config_android.h	Sat Aug 16 23:23:15 2014 -0700
     6.3 @@ -96,6 +96,7 @@
     6.4  #define HAVE_FLOOR  1
     6.5  #define HAVE_LOG    1
     6.6  #define HAVE_POW    1
     6.7 +#define HAVE_ROUND  1
     6.8  #define HAVE_SCALBN 1
     6.9  #define HAVE_SIN    1
    6.10  #define HAVE_SINF   1
     7.1 --- a/include/SDL_config_iphoneos.h	Sat Aug 16 23:17:47 2014 -0700
     7.2 +++ b/include/SDL_config_iphoneos.h	Sat Aug 16 23:23:15 2014 -0700
     7.3 @@ -94,6 +94,7 @@
     7.4  #define HAVE_FLOOR  1
     7.5  #define HAVE_LOG    1
     7.6  #define HAVE_POW    1
     7.7 +#define HAVE_ROUND  1
     7.8  #define HAVE_SCALBN 1
     7.9  #define HAVE_SIN    1
    7.10  #define HAVE_SINF   1
     8.1 --- a/include/SDL_config_macosx.h	Sat Aug 16 23:17:47 2014 -0700
     8.2 +++ b/include/SDL_config_macosx.h	Sat Aug 16 23:23:15 2014 -0700
     8.3 @@ -92,6 +92,7 @@
     8.4  #define HAVE_FLOOR  1
     8.5  #define HAVE_LOG    1
     8.6  #define HAVE_POW    1
     8.7 +#define HAVE_ROUND  1
     8.8  #define HAVE_SCALBN 1
     8.9  #define HAVE_SIN    1
    8.10  #define HAVE_SINF   1
     9.1 --- a/include/SDL_config_pandora.h	Sat Aug 16 23:17:47 2014 -0700
     9.2 +++ b/include/SDL_config_pandora.h	Sat Aug 16 23:23:15 2014 -0700
     9.3 @@ -91,6 +91,7 @@
     9.4  #define HAVE_FABS 1
     9.5  #define HAVE_FLOOR 1
     9.6  #define HAVE_LOG 1
     9.7 +#define HAVE_ROUND  1
     9.8  #define HAVE_SCALBN 1
     9.9  #define HAVE_SIN 1
    9.10  #define HAVE_SINF 1
    10.1 --- a/include/SDL_config_psp.h	Sat Aug 16 23:17:47 2014 -0700
    10.2 +++ b/include/SDL_config_psp.h	Sat Aug 16 23:23:15 2014 -0700
    10.3 @@ -94,6 +94,7 @@
    10.4  #define HAVE_FLOOR  1
    10.5  #define HAVE_LOG    1
    10.6  #define HAVE_POW    1
    10.7 +#define HAVE_ROUND  1
    10.8  #define HAVE_SCALBN 1
    10.9  #define HAVE_SIN    1
   10.10  #define HAVE_SINF   1
    11.1 --- a/include/SDL_config_windows.h	Sat Aug 16 23:17:47 2014 -0700
    11.2 +++ b/include/SDL_config_windows.h	Sat Aug 16 23:23:15 2014 -0700
    11.3 @@ -133,6 +133,7 @@
    11.4  #define HAVE_FLOOR 1
    11.5  #define HAVE_LOG 1
    11.6  #define HAVE_POW 1
    11.7 +#define HAVE_ROUND  1
    11.8  #define HAVE_SIN 1
    11.9  #define HAVE_SINF 1
   11.10  #define HAVE_SQRT 1
    12.1 --- a/include/SDL_config_winrt.h	Sat Aug 16 23:17:47 2014 -0700
    12.2 +++ b/include/SDL_config_winrt.h	Sat Aug 16 23:23:15 2014 -0700
    12.3 @@ -135,6 +135,7 @@
    12.4  #define HAVE_FLOOR 1
    12.5  #define HAVE_LOG 1
    12.6  #define HAVE_POW 1
    12.7 +#define HAVE_ROUND 1
    12.8  //#define HAVE_SCALBN 1
    12.9  #define HAVE__SCALB 1
   12.10  #define HAVE_SIN 1
    13.1 --- a/include/SDL_config_wiz.h	Sat Aug 16 23:17:47 2014 -0700
    13.2 +++ b/include/SDL_config_wiz.h	Sat Aug 16 23:23:15 2014 -0700
    13.3 @@ -85,6 +85,7 @@
    13.4  #define HAVE_FABS 1
    13.5  #define HAVE_FLOOR 1
    13.6  #define HAVE_LOG 1
    13.7 +#define HAVE_ROUND 1
    13.8  #define HAVE_SCALBN 1
    13.9  #define HAVE_SIN 1
   13.10  #define HAVE_SINF 1
    14.1 --- a/include/SDL_stdinc.h	Sat Aug 16 23:17:47 2014 -0700
    14.2 +++ b/include/SDL_stdinc.h	Sat Aug 16 23:23:15 2014 -0700
    14.3 @@ -428,6 +428,7 @@
    14.4  extern DECLSPEC double SDLCALL SDL_floor(double x);
    14.5  extern DECLSPEC double SDLCALL SDL_log(double x);
    14.6  extern DECLSPEC double SDLCALL SDL_pow(double x, double y);
    14.7 +extern DECLSPEC double SDLCALL SDL_round(double x);
    14.8  extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n);
    14.9  extern DECLSPEC double SDLCALL SDL_sin(double x);
   14.10  extern DECLSPEC float SDLCALL SDL_sinf(float x);
    15.1 --- a/src/dynapi/SDL_dynapi_overrides.h	Sat Aug 16 23:17:47 2014 -0700
    15.2 +++ b/src/dynapi/SDL_dynapi_overrides.h	Sat Aug 16 23:23:15 2014 -0700
    15.3 @@ -591,3 +591,4 @@
    15.4  #define SDL_QueueAudio SDL_QueueAudio_REAL
    15.5  #define SDL_GetQueuedAudioSize SDL_GetQueuedAudioSize_REAL
    15.6  #define SDL_ClearQueuedAudio SDL_ClearQueuedAudio_REAL
    15.7 +#define SDL_round SDL_round_REAL
    16.1 --- a/src/dynapi/SDL_dynapi_procs.h	Sat Aug 16 23:17:47 2014 -0700
    16.2 +++ b/src/dynapi/SDL_dynapi_procs.h	Sat Aug 16 23:23:15 2014 -0700
    16.3 @@ -623,3 +623,4 @@
    16.4  SDL_DYNAPI_PROC(int,SDL_QueueAudio,(SDL_AudioDeviceID a, const void *b, Uint32 c),(a,b,c),return)
    16.5  SDL_DYNAPI_PROC(Uint32,SDL_GetQueuedAudioSize,(SDL_AudioDeviceID a),(a),return)
    16.6  SDL_DYNAPI_PROC(void,SDL_ClearQueuedAudio,(SDL_AudioDeviceID a),(a),)
    16.7 +SDL_DYNAPI_PROC(double,SDL_round,(double a),(a),return)
    17.1 --- a/src/libm/math_libm.h	Sat Aug 16 23:17:47 2014 -0700
    17.2 +++ b/src/libm/math_libm.h	Sat Aug 16 23:23:15 2014 -0700
    17.3 @@ -30,6 +30,7 @@
    17.4  double SDL_uclibc_floor(double x);
    17.5  double SDL_uclibc_log(double x);
    17.6  double SDL_uclibc_pow(double x, double y);    
    17.7 +double SDL_uclibc_round(double x);
    17.8  double SDL_uclibc_scalbn(double x, int n);
    17.9  double SDL_uclibc_sin(double x);
   17.10  double SDL_uclibc_sqrt(double x);
    18.1 --- a/src/libm/math_private.h	Sat Aug 16 23:17:47 2014 -0700
    18.2 +++ b/src/libm/math_private.h	Sat Aug 16 23:23:15 2014 -0700
    18.3 @@ -37,6 +37,7 @@
    18.4  #define floor           SDL_uclibc_floor
    18.5  #define __ieee754_log   SDL_uclibc_log
    18.6  #define __ieee754_pow   SDL_uclibc_pow
    18.7 +#define round           SDL_uclibc_round
    18.8  #define scalbn          SDL_uclibc_scalbn
    18.9  #define sin             SDL_uclibc_sin
   18.10  #define __ieee754_sqrt  SDL_uclibc_sqrt
    19.1 --- a/src/stdlib/SDL_stdlib.c	Sat Aug 16 23:17:47 2014 -0700
    19.2 +++ b/src/stdlib/SDL_stdlib.c	Sat Aug 16 23:23:15 2014 -0700
    19.3 @@ -170,6 +170,16 @@
    19.4  }
    19.5  
    19.6  double
    19.7 +SDL_round(double x)
    19.8 +{
    19.9 +#if defined(HAVE_ROUND)
   19.10 +    return round(x);
   19.11 +#else
   19.12 +    return SDL_uclibc_round(x);
   19.13 +#endif /* HAVE_ROUND */
   19.14 +}
   19.15 +
   19.16 +double
   19.17  SDL_scalbn(double x, int n)
   19.18  {
   19.19  #if defined(HAVE_SCALBN)