From bc3e0f7fe6920076f584507a62221214b1ce1e55 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Tue, 21 Mar 2006 09:48:02 +0000 Subject: [PATCH] * Use the asm versions of sin and cos when available. --- configure.ac | 5 +++++ kernel/kernel.c | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 9cdd782..845d563 100644 --- a/configure.ac +++ b/configure.ac @@ -59,6 +59,11 @@ AC_TRY_COMPILE([#include ],[Sleep(42);], [AC_MSG_RESULT(yes) AC_DEFINE(HAVE_SLEEP, 1, [Define to 1 if you have the `Sleep' function.])], [AC_MSG_RESULT(no)]) +AC_MSG_CHECKING(for fsin/fcos) +AC_TRY_COMPILE([],[asm("fsin\n\tfcos");], + [AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_FSIN_FCOS, 1, [Define to 1 if you have the `fsin' and `fcos' operands.])], + [AC_MSG_RESULT(no)]) AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm") CACA_DRIVERS="" diff --git a/kernel/kernel.c b/kernel/kernel.c index 780dcc8..1c3d7c1 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -227,6 +227,9 @@ int gettimeofday(struct timeval *tv, struct timezone *tz) double cos(double x) { double ret = 0.0; +#ifdef HAVE_FSIN_FCOS + asm volatile("fcos" : "=t" (ret) : "0" (x)); +#else double x2; double num = 1.0; double fact = 1.0; @@ -242,13 +245,16 @@ double cos(double x) num *= - x2; fact *= (2 * i + 1) * (2 * i + 2); } - +#endif return ret; } double sin(double x) { double ret = 0.0; +#ifdef HAVE_FSIN_FCOS + asm volatile("fsin" : "=t" (ret) : "0" (x)); +#else double x2; double num; double fact = 1.0; @@ -265,7 +271,7 @@ double sin(double x) num *= - x2; fact *= (2 * i + 2) * (2 * i + 3); } - +#endif return ret; }