summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan C. Gordon <icculus@icculus.org>2013-12-09 15:17:20 -0500
committerRyan C. Gordon <icculus@icculus.org>2013-12-09 15:17:20 -0500
commitfac8b02737c495eb71289059e1f591abde9cdcf3 (patch)
tree82f48f02242845e94ee247f189aaa979bea6ffbe
parent97123358b0510d46d32ceecf0f0d921ef89a1b5f (diff)
Hook up SDL_acos and SDL_asin properly.
-rw-r--r--CMakeLists.txt4
-rwxr-xr-xconfigure2
-rw-r--r--configure.in2
-rw-r--r--include/SDL_config.h.cmake2
-rw-r--r--include/SDL_config.h.in2
-rw-r--r--include/SDL_config_android.h2
-rw-r--r--include/SDL_config_iphoneos.h2
-rw-r--r--include/SDL_config_macosx.h2
-rw-r--r--include/SDL_config_psp.h2
-rw-r--r--include/SDL_config_windows.h2
-rw-r--r--src/libm/s_atan.c25
-rw-r--r--src/stdlib/SDL_stdlib.c36
12 files changed, 54 insertions, 29 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1d15fb274a..7455ab84bc 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 0e10125a2a..bd2c5d2175 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 8d116a58dd..7c3a1b1ced 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 27e5f734f7..08237a87ae 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 574d9ae7f2..536b297744 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 0826415c68..489b9ff329 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 ade2966141..ae8a12bd83 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 9f2f76e3f9..7825e702c6 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 31ac2b2b70..989f7d8c72 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 6bde3f86fb..aa2f984510 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 2f24b29b08..970ea4dbfa 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 aa57d41b13..2cb31cb063 100644
--- a/src/stdlib/SDL_stdlib.c
+++ b/src/stdlib/SDL_stdlib.c
@@ -47,6 +47,42 @@ SDL_atan2(double x, double y)
}
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