Added SDL_round(), contributed by Benoit Pierre - thanks!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 792f26c..bd6055c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -495,7 +495,7 @@ if(LIBC)
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(LIBC)
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}")
diff --git a/configure b/configure
index 08ecfbf..beb7b8e 100755
--- a/configure
+++ b/configure
@@ -16641,7 +16641,7 @@ if test "x$ac_cv_lib_m_pow" = xyes; then :
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"
diff --git a/configure.in b/configure.in
index 3c87ea7..1464d7e 100644
--- a/configure.in
+++ b/configure.in
@@ -271,7 +271,7 @@ if test x$enable_libc = xyes; then
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)
diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake
index 9bcf6e9..c149ee8 100644
--- a/include/SDL_config.h.cmake
+++ b/include/SDL_config.h.cmake
@@ -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
diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in
index 145a7b7..96c6945 100644
--- a/include/SDL_config.h.in
+++ b/include/SDL_config.h.in
@@ -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
diff --git a/include/SDL_config_android.h b/include/SDL_config_android.h
index 569ff1d..8300b46 100644
--- a/include/SDL_config_android.h
+++ b/include/SDL_config_android.h
@@ -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
diff --git a/include/SDL_config_iphoneos.h b/include/SDL_config_iphoneos.h
index 4e3eb2c..75ec3c1 100644
--- a/include/SDL_config_iphoneos.h
+++ b/include/SDL_config_iphoneos.h
@@ -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
diff --git a/include/SDL_config_macosx.h b/include/SDL_config_macosx.h
index b6af492..ebb63cb 100644
--- a/include/SDL_config_macosx.h
+++ b/include/SDL_config_macosx.h
@@ -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
diff --git a/include/SDL_config_pandora.h b/include/SDL_config_pandora.h
index aead1ff..2851ada 100644
--- a/include/SDL_config_pandora.h
+++ b/include/SDL_config_pandora.h
@@ -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
diff --git a/include/SDL_config_psp.h b/include/SDL_config_psp.h
index 617d691..354dc3f 100644
--- a/include/SDL_config_psp.h
+++ b/include/SDL_config_psp.h
@@ -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
diff --git a/include/SDL_config_windows.h b/include/SDL_config_windows.h
index 8bc7ffe..1b329e2 100644
--- a/include/SDL_config_windows.h
+++ b/include/SDL_config_windows.h
@@ -133,6 +133,7 @@ typedef unsigned int uintptr_t;
#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
diff --git a/include/SDL_config_winrt.h b/include/SDL_config_winrt.h
index d70a0bc..aa63476 100644
--- a/include/SDL_config_winrt.h
+++ b/include/SDL_config_winrt.h
@@ -135,6 +135,7 @@ typedef unsigned int uintptr_t;
#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
diff --git a/include/SDL_config_wiz.h b/include/SDL_config_wiz.h
index 9204567..46bc816 100644
--- a/include/SDL_config_wiz.h
+++ b/include/SDL_config_wiz.h
@@ -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
diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h
index 78d3402..47a5ca9 100644
--- a/include/SDL_stdinc.h
+++ b/include/SDL_stdinc.h
@@ -428,6 +428,7 @@ extern DECLSPEC double SDLCALL SDL_fabs(double x);
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);
diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h
index 8bcde63..d887964 100644
--- a/src/dynapi/SDL_dynapi_overrides.h
+++ b/src/dynapi/SDL_dynapi_overrides.h
@@ -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
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index c41cdc9..0b8546d 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -623,3 +623,4 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_HasAVX2,(void),(),return)
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)
diff --git a/src/libm/math_libm.h b/src/libm/math_libm.h
index 6b479f4..88f7852 100644
--- a/src/libm/math_libm.h
+++ b/src/libm/math_libm.h
@@ -30,6 +30,7 @@ double SDL_uclibc_fabs(double x);
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);
diff --git a/src/libm/math_private.h b/src/libm/math_private.h
index 74c8b3d..78b6240 100644
--- a/src/libm/math_private.h
+++ b/src/libm/math_private.h
@@ -37,6 +37,7 @@ typedef unsigned int u_int32_t;
#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
diff --git a/src/stdlib/SDL_stdlib.c b/src/stdlib/SDL_stdlib.c
index b1de63d..493bebe 100644
--- a/src/stdlib/SDL_stdlib.c
+++ b/src/stdlib/SDL_stdlib.c
@@ -170,6 +170,16 @@ SDL_pow(double x, double y)
}
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)