From d01ad02be728fb7f934924157138c4dbc2bb1d77 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 9 Dec 2013 15:17:20 -0500 Subject: [PATCH] Hook up SDL_acos and SDL_asin properly. --- CMakeLists.txt | 4 ++-- configure | 2 +- configure.in | 2 +- include/SDL_config.h.cmake | 2 ++ include/SDL_config.h.in | 2 ++ include/SDL_config_android.h | 2 ++ include/SDL_config_iphoneos.h | 2 ++ include/SDL_config_macosx.h | 2 ++ include/SDL_config_psp.h | 2 ++ include/SDL_config_windows.h | 2 ++ src/libm/s_atan.c | 25 ------------------------ src/stdlib/SDL_stdlib.c | 36 +++++++++++++++++++++++++++++++++++ 12 files changed, 54 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d15fb274a079..7455ab84bc2d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -473,8 +473,8 @@ if(LIBC) malloc calloc realloc free qsort abs memset memcpy memmove memcmp strlen _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _ultoa strtol strtoul strtoll strtod atoi atof strcmp strncmp - _stricmp _strnicmp sscanf atan atan2 ceil copysign cos cosf fabs - floor log pow scalbn sin sinf sqrt) + _stricmp _strnicmp sscanf atan atan2 acos asin ceil copysign cos + cosf fabs floor log pow scalbn sin sinf sqrt) string(TOUPPER ${_FN} _UPPER) set(HAVE_${_UPPER} 1) endforeach() diff --git a/configure b/configure index 0e10125a2ab4f..bd2c5d21756a3 100755 --- a/configure +++ b/configure @@ -16628,7 +16628,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 ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt + for ac_func in atan atan2 acos asin ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt 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 8d116a58ddc1e..7c3a1b1ced2e6 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 sscanf snprintf 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 ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt) + AC_CHECK_FUNCS(atan atan2 acos asin ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt) 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 27e5f734f7d1a..08237a87aec14 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -130,6 +130,8 @@ #cmakedefine HAVE_M_PI 1 #cmakedefine HAVE_ATAN 1 #cmakedefine HAVE_ATAN2 1 +#cmakedefine HAVE_ACOS 1 +#cmakedefine HAVE_ASIN 1 #cmakedefine HAVE_CEIL 1 #cmakedefine HAVE_COPYSIGN 1 #cmakedefine HAVE_COS 1 diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 574d9ae7f2ab5..536b2977440d9 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -133,6 +133,8 @@ #undef HAVE_M_PI #undef HAVE_ATAN #undef HAVE_ATAN2 +#undef HAVE_ACOS +#undef HAVE_ASIN #undef HAVE_CEIL #undef HAVE_COPYSIGN #undef HAVE_COS diff --git a/include/SDL_config_android.h b/include/SDL_config_android.h index 0826415c6866b..489b9ff329992 100644 --- a/include/SDL_config_android.h +++ b/include/SDL_config_android.h @@ -87,6 +87,8 @@ #define HAVE_M_PI 1 #define HAVE_ATAN 1 #define HAVE_ATAN2 1 +#define HAVE_ACOS 1 +#define HAVE_ASIN 1 #define HAVE_CEIL 1 #define HAVE_COPYSIGN 1 #define HAVE_COS 1 diff --git a/include/SDL_config_iphoneos.h b/include/SDL_config_iphoneos.h index ade2966141a40..ae8a12bd839eb 100644 --- a/include/SDL_config_iphoneos.h +++ b/include/SDL_config_iphoneos.h @@ -85,6 +85,8 @@ #define HAVE_M_PI 1 #define HAVE_ATAN 1 #define HAVE_ATAN2 1 +#define HAVE_ACOS 1 +#define HAVE_ASIN 1 #define HAVE_CEIL 1 #define HAVE_COPYSIGN 1 #define HAVE_COS 1 diff --git a/include/SDL_config_macosx.h b/include/SDL_config_macosx.h index 9f2f76e3f9814..7825e702c6ce2 100644 --- a/include/SDL_config_macosx.h +++ b/include/SDL_config_macosx.h @@ -104,6 +104,8 @@ #define HAVE_SYSCTLBYNAME 1 #define HAVE_ATAN 1 #define HAVE_ATAN2 1 +#define HAVE_ACOS 1 +#define HAVE_ASIN 1 /* Enable various audio drivers */ #define SDL_AUDIO_DRIVER_COREAUDIO 1 diff --git a/include/SDL_config_psp.h b/include/SDL_config_psp.h index 31ac2b2b70abf..989f7d8c729dc 100644 --- a/include/SDL_config_psp.h +++ b/include/SDL_config_psp.h @@ -85,6 +85,8 @@ #define HAVE_M_PI 1 #define HAVE_ATAN 1 #define HAVE_ATAN2 1 +#define HAVE_ACOS 1 +#define HAVE_ASIN 1 #define HAVE_CEIL 1 #define HAVE_COPYSIGN 1 #define HAVE_COS 1 diff --git a/include/SDL_config_windows.h b/include/SDL_config_windows.h index 6bde3f86fbf0b..aa2f984510939 100644 --- a/include/SDL_config_windows.h +++ b/include/SDL_config_windows.h @@ -118,6 +118,8 @@ typedef unsigned int uintptr_t; #define HAVE__STRNICMP 1 #define HAVE_ATAN 1 #define HAVE_ATAN2 1 +#define HAVE_ACOS 1 +#define HAVE_ASIN 1 #define HAVE_CEIL 1 #define HAVE_COS 1 #define HAVE_COSF 1 diff --git a/src/libm/s_atan.c b/src/libm/s_atan.c index 2f24b29b08923..970ea4dbfad3e 100644 --- a/src/libm/s_atan.c +++ b/src/libm/s_atan.c @@ -113,28 +113,3 @@ double atan(double x) } libm_hidden_def(atan) -double SDL_acos(double val) -{ - double result; - if (val == -1.0) { - result = M_PI; - } else { - result = SDL_atan(SDL_sqrt(1.0 - val * val) / val); - if (result < 0.0) - { - result += M_PI; - } - } - return result; -} - -double SDL_asin(double val) -{ - double result; - if (val == -1.0) { - result = -(M_PI / 2.0); - } else { - result = (M_PI / 2.0) - SDL_acos(val); - } - return result; -} diff --git a/src/stdlib/SDL_stdlib.c b/src/stdlib/SDL_stdlib.c index aa57d41b135a8..2cb31cb06395a 100644 --- a/src/stdlib/SDL_stdlib.c +++ b/src/stdlib/SDL_stdlib.c @@ -46,6 +46,42 @@ SDL_atan2(double x, double y) #endif /* HAVE_ATAN2 */ } +double +SDL_acos(double val) +{ +#if defined(HAVE_ACOS) + return acos(val); +#else + double result; + if (val == -1.0) { + result = M_PI; + } else { + result = SDL_atan(SDL_sqrt(1.0 - val * val) / val); + if (result < 0.0) + { + result += M_PI; + } + } + return result; +#endif +} + +double +SDL_asin(double val) +{ +#if defined(HAVE_ASIN) + return asin(val); +#else + double result; + if (val == -1.0) { + result = -(M_PI / 2.0); + } else { + result = (M_PI / 2.0) - SDL_acos(val); + } + return result; +#endif +} + double SDL_ceil(double x) {