Hook up SDL_acos and SDL_asin properly.
authorRyan C. Gordon <icculus@icculus.org>
Mon, 09 Dec 2013 15:17:20 -0500
changeset 8056 abd9434c5d3e
parent 8055 3e2f230a6d62
child 8057 801d84e26f91
Hook up SDL_acos and SDL_asin properly.
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_psp.h
include/SDL_config_windows.h
src/libm/s_atan.c
src/stdlib/SDL_stdlib.c
--- a/CMakeLists.txt	Sat Dec 07 11:19:52 2013 -0800
+++ b/CMakeLists.txt	Mon Dec 09 15:17:20 2013 -0500
@@ -473,8 +473,8 @@
             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()
--- a/configure	Sat Dec 07 11:19:52 2013 -0800
+++ b/configure	Mon Dec 09 15:17:20 2013 -0500
@@ -16628,7 +16628,7 @@
   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"
--- a/configure.in	Sat Dec 07 11:19:52 2013 -0800
+++ b/configure.in	Mon Dec 09 15:17:20 2013 -0500
@@ -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 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)
--- a/include/SDL_config.h.cmake	Sat Dec 07 11:19:52 2013 -0800
+++ b/include/SDL_config.h.cmake	Mon Dec 09 15:17:20 2013 -0500
@@ -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
--- a/include/SDL_config.h.in	Sat Dec 07 11:19:52 2013 -0800
+++ b/include/SDL_config.h.in	Mon Dec 09 15:17:20 2013 -0500
@@ -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
--- a/include/SDL_config_android.h	Sat Dec 07 11:19:52 2013 -0800
+++ b/include/SDL_config_android.h	Mon Dec 09 15:17:20 2013 -0500
@@ -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
--- a/include/SDL_config_iphoneos.h	Sat Dec 07 11:19:52 2013 -0800
+++ b/include/SDL_config_iphoneos.h	Mon Dec 09 15:17:20 2013 -0500
@@ -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
--- a/include/SDL_config_macosx.h	Sat Dec 07 11:19:52 2013 -0800
+++ b/include/SDL_config_macosx.h	Mon Dec 09 15:17:20 2013 -0500
@@ -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
--- a/include/SDL_config_psp.h	Sat Dec 07 11:19:52 2013 -0800
+++ b/include/SDL_config_psp.h	Mon Dec 09 15:17:20 2013 -0500
@@ -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
--- a/include/SDL_config_windows.h	Sat Dec 07 11:19:52 2013 -0800
+++ b/include/SDL_config_windows.h	Mon Dec 09 15:17:20 2013 -0500
@@ -118,6 +118,8 @@
 #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
--- a/src/libm/s_atan.c	Sat Dec 07 11:19:52 2013 -0800
+++ b/src/libm/s_atan.c	Mon Dec 09 15:17:20 2013 -0500
@@ -113,28 +113,3 @@
 }
 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;
-}
--- a/src/stdlib/SDL_stdlib.c	Sat Dec 07 11:19:52 2013 -0800
+++ b/src/stdlib/SDL_stdlib.c	Mon Dec 09 15:17:20 2013 -0500
@@ -47,6 +47,42 @@
 }
 
 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)
 {
 #ifdef HAVE_CEIL