Added SDL_round(), contributed by Benoit Pierre - thanks!
authorSam Lantinga <slouken@libsdl.org>
Sat, 16 Aug 2014 23:23:15 -0700
changeset 9075 257a6793aaf5
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
--- a/CMakeLists.txt	Sat Aug 16 23:17:47 2014 -0700
+++ b/CMakeLists.txt	Sat Aug 16 23:23:15 2014 -0700
@@ -495,7 +495,7 @@
             strlen _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa
             _ultoa strtol strtoul strtoll strtod atoi atof strcmp strncmp
             _stricmp _strnicmp sscanf atan atan2 acos asin ceil copysign cos
-            cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf)
+            cosf fabs floor log pow round scalbn sin sinf sqrt sqrtf tan tanf)
       string(TOUPPER ${_FN} _UPPER)
       set(HAVE_${_UPPER} 1)
     endforeach()
@@ -541,7 +541,7 @@
     if(HAVE_LIBM)
       set(CMAKE_REQUIRED_LIBRARIES m)
       foreach(_FN
-              atan atan2 ceil copysign cos cosf fabs floor log pow scalbn sin
+              atan atan2 ceil copysign cos cosf fabs floor log pow round scalbn sin
               sinf sqrt sqrtf tan tanf)
         string(TOUPPER ${_FN} _UPPER)
         set(_HAVEVAR "HAVE_${_UPPER}")
--- a/configure	Sat Aug 16 23:17:47 2014 -0700
+++ b/configure	Sat Aug 16 23:23:15 2014 -0700
@@ -16641,7 +16641,7 @@
   LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"
 fi
 
-    for ac_func in atan atan2 acos asin ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf
+    for ac_func in atan atan2 acos asin ceil copysign cos cosf fabs floor log pow round scalbn sin sinf sqrt sqrtf tan tanf
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
--- a/configure.in	Sat Aug 16 23:17:47 2014 -0700
+++ b/configure.in	Sat Aug 16 23:23:15 2014 -0700
@@ -271,7 +271,7 @@
     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)
 
     AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
-    AC_CHECK_FUNCS(atan atan2 acos asin ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf)
+    AC_CHECK_FUNCS(atan atan2 acos asin ceil copysign cos cosf fabs floor log pow round scalbn sin sinf sqrt sqrtf tan tanf)
 
     AC_CHECK_LIB(iconv, iconv_open, [LIBS="$LIBS -liconv"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv"])
     AC_CHECK_FUNCS(iconv)
--- a/include/SDL_config.h.cmake	Sat Aug 16 23:17:47 2014 -0700
+++ b/include/SDL_config.h.cmake	Sat Aug 16 23:23:15 2014 -0700
@@ -140,6 +140,7 @@
 #cmakedefine HAVE_FLOOR 1
 #cmakedefine HAVE_LOG 1
 #cmakedefine HAVE_POW 1
+#cmakedefine HAVE_ROUND 1
 #cmakedefine HAVE_SCALBN 1
 #cmakedefine HAVE_SIN 1
 #cmakedefine HAVE_SINF 1
--- a/include/SDL_config.h.in	Sat Aug 16 23:17:47 2014 -0700
+++ b/include/SDL_config.h.in	Sat Aug 16 23:23:15 2014 -0700
@@ -150,6 +150,7 @@
 #undef HAVE_FLOOR
 #undef HAVE_LOG
 #undef HAVE_POW
+#undef HAVE_ROUND
 #undef HAVE_SCALBN
 #undef HAVE_SIN
 #undef HAVE_SINF
--- a/include/SDL_config_android.h	Sat Aug 16 23:17:47 2014 -0700
+++ b/include/SDL_config_android.h	Sat Aug 16 23:23:15 2014 -0700
@@ -96,6 +96,7 @@
 #define HAVE_FLOOR  1
 #define HAVE_LOG    1
 #define HAVE_POW    1
+#define HAVE_ROUND  1
 #define HAVE_SCALBN 1
 #define HAVE_SIN    1
 #define HAVE_SINF   1
--- a/include/SDL_config_iphoneos.h	Sat Aug 16 23:17:47 2014 -0700
+++ b/include/SDL_config_iphoneos.h	Sat Aug 16 23:23:15 2014 -0700
@@ -94,6 +94,7 @@
 #define HAVE_FLOOR  1
 #define HAVE_LOG    1
 #define HAVE_POW    1
+#define HAVE_ROUND  1
 #define HAVE_SCALBN 1
 #define HAVE_SIN    1
 #define HAVE_SINF   1
--- a/include/SDL_config_macosx.h	Sat Aug 16 23:17:47 2014 -0700
+++ b/include/SDL_config_macosx.h	Sat Aug 16 23:23:15 2014 -0700
@@ -92,6 +92,7 @@
 #define HAVE_FLOOR  1
 #define HAVE_LOG    1
 #define HAVE_POW    1
+#define HAVE_ROUND  1
 #define HAVE_SCALBN 1
 #define HAVE_SIN    1
 #define HAVE_SINF   1
--- a/include/SDL_config_pandora.h	Sat Aug 16 23:17:47 2014 -0700
+++ b/include/SDL_config_pandora.h	Sat Aug 16 23:23:15 2014 -0700
@@ -91,6 +91,7 @@
 #define HAVE_FABS 1
 #define HAVE_FLOOR 1
 #define HAVE_LOG 1
+#define HAVE_ROUND  1
 #define HAVE_SCALBN 1
 #define HAVE_SIN 1
 #define HAVE_SINF 1
--- a/include/SDL_config_psp.h	Sat Aug 16 23:17:47 2014 -0700
+++ b/include/SDL_config_psp.h	Sat Aug 16 23:23:15 2014 -0700
@@ -94,6 +94,7 @@
 #define HAVE_FLOOR  1
 #define HAVE_LOG    1
 #define HAVE_POW    1
+#define HAVE_ROUND  1
 #define HAVE_SCALBN 1
 #define HAVE_SIN    1
 #define HAVE_SINF   1
--- a/include/SDL_config_windows.h	Sat Aug 16 23:17:47 2014 -0700
+++ b/include/SDL_config_windows.h	Sat Aug 16 23:23:15 2014 -0700
@@ -133,6 +133,7 @@
 #define HAVE_FLOOR 1
 #define HAVE_LOG 1
 #define HAVE_POW 1
+#define HAVE_ROUND  1
 #define HAVE_SIN 1
 #define HAVE_SINF 1
 #define HAVE_SQRT 1
--- a/include/SDL_config_winrt.h	Sat Aug 16 23:17:47 2014 -0700
+++ b/include/SDL_config_winrt.h	Sat Aug 16 23:23:15 2014 -0700
@@ -135,6 +135,7 @@
 #define HAVE_FLOOR 1
 #define HAVE_LOG 1
 #define HAVE_POW 1
+#define HAVE_ROUND 1
 //#define HAVE_SCALBN 1
 #define HAVE__SCALB 1
 #define HAVE_SIN 1
--- a/include/SDL_config_wiz.h	Sat Aug 16 23:17:47 2014 -0700
+++ b/include/SDL_config_wiz.h	Sat Aug 16 23:23:15 2014 -0700
@@ -85,6 +85,7 @@
 #define HAVE_FABS 1
 #define HAVE_FLOOR 1
 #define HAVE_LOG 1
+#define HAVE_ROUND 1
 #define HAVE_SCALBN 1
 #define HAVE_SIN 1
 #define HAVE_SINF 1
--- a/include/SDL_stdinc.h	Sat Aug 16 23:17:47 2014 -0700
+++ b/include/SDL_stdinc.h	Sat Aug 16 23:23:15 2014 -0700
@@ -428,6 +428,7 @@
 extern DECLSPEC double SDLCALL SDL_floor(double x);
 extern DECLSPEC double SDLCALL SDL_log(double x);
 extern DECLSPEC double SDLCALL SDL_pow(double x, double y);
+extern DECLSPEC double SDLCALL SDL_round(double x);
 extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n);
 extern DECLSPEC double SDLCALL SDL_sin(double x);
 extern DECLSPEC float SDLCALL SDL_sinf(float x);
--- a/src/dynapi/SDL_dynapi_overrides.h	Sat Aug 16 23:17:47 2014 -0700
+++ b/src/dynapi/SDL_dynapi_overrides.h	Sat Aug 16 23:23:15 2014 -0700
@@ -591,3 +591,4 @@
 #define SDL_QueueAudio SDL_QueueAudio_REAL
 #define SDL_GetQueuedAudioSize SDL_GetQueuedAudioSize_REAL
 #define SDL_ClearQueuedAudio SDL_ClearQueuedAudio_REAL
+#define SDL_round SDL_round_REAL
--- a/src/dynapi/SDL_dynapi_procs.h	Sat Aug 16 23:17:47 2014 -0700
+++ b/src/dynapi/SDL_dynapi_procs.h	Sat Aug 16 23:23:15 2014 -0700
@@ -623,3 +623,4 @@
 SDL_DYNAPI_PROC(int,SDL_QueueAudio,(SDL_AudioDeviceID a, const void *b, Uint32 c),(a,b,c),return)
 SDL_DYNAPI_PROC(Uint32,SDL_GetQueuedAudioSize,(SDL_AudioDeviceID a),(a),return)
 SDL_DYNAPI_PROC(void,SDL_ClearQueuedAudio,(SDL_AudioDeviceID a),(a),)
+SDL_DYNAPI_PROC(double,SDL_round,(double a),(a),return)
--- a/src/libm/math_libm.h	Sat Aug 16 23:17:47 2014 -0700
+++ b/src/libm/math_libm.h	Sat Aug 16 23:23:15 2014 -0700
@@ -30,6 +30,7 @@
 double SDL_uclibc_floor(double x);
 double SDL_uclibc_log(double x);
 double SDL_uclibc_pow(double x, double y);    
+double SDL_uclibc_round(double x);
 double SDL_uclibc_scalbn(double x, int n);
 double SDL_uclibc_sin(double x);
 double SDL_uclibc_sqrt(double x);
--- a/src/libm/math_private.h	Sat Aug 16 23:17:47 2014 -0700
+++ b/src/libm/math_private.h	Sat Aug 16 23:23:15 2014 -0700
@@ -37,6 +37,7 @@
 #define floor           SDL_uclibc_floor
 #define __ieee754_log   SDL_uclibc_log
 #define __ieee754_pow   SDL_uclibc_pow
+#define round           SDL_uclibc_round
 #define scalbn          SDL_uclibc_scalbn
 #define sin             SDL_uclibc_sin
 #define __ieee754_sqrt  SDL_uclibc_sqrt
--- a/src/stdlib/SDL_stdlib.c	Sat Aug 16 23:17:47 2014 -0700
+++ b/src/stdlib/SDL_stdlib.c	Sat Aug 16 23:23:15 2014 -0700
@@ -170,6 +170,16 @@
 }
 
 double
+SDL_round(double x)
+{
+#if defined(HAVE_ROUND)
+    return round(x);
+#else
+    return SDL_uclibc_round(x);
+#endif /* HAVE_ROUND */
+}
+
+double
 SDL_scalbn(double x, int n)
 {
 #if defined(HAVE_SCALBN)