summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2011-11-01 19:18:48 -0500
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2011-11-04 10:30:19 +0100
commit7ae07d4f028849d30b4f260b3261d634f16d7331 (patch)
tree855777d02d49d15c9bf362ebe1bf8a30c40f9b65
parent2086015b9a223586c1a2b8d7f015ad3a38bdf8bc (diff)
libm: implement a generic sincos().
We already provide sincos() on some archs, so we should ship a generic version. Signed-off-by: William Pitcock <nenolod@dereferenced.org> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
-rw-r--r--libc/sysdeps/linux/common/bits/mathcalls.h2
-rw-r--r--libm/Makefile.in2
-rw-r--r--libm/sincos.c48
3 files changed, 50 insertions, 2 deletions
diff --git a/libc/sysdeps/linux/common/bits/mathcalls.h b/libc/sysdeps/linux/common/bits/mathcalls.h
index 1e92b527e..013d2b2a7 100644
--- a/libc/sysdeps/linux/common/bits/mathcalls.h
+++ b/libc/sysdeps/linux/common/bits/mathcalls.h
@@ -90,7 +90,7 @@ __MATHCALLI (sinh,, (_Mdouble_ __x))
__MATHCALLI (tanh,, (_Mdouble_ __x))
_Mdouble_END_NAMESPACE
-#if 0 /*def __USE_GNU*/
+#if defined __USE_GNU
/* Cosine and sine of X. */
__MATHDECL (void,sincos,,
(_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx))
diff --git a/libm/Makefile.in b/libm/Makefile.in
index af949e82c..23a55b369 100644
--- a/libm/Makefile.in
+++ b/libm/Makefile.in
@@ -73,7 +73,7 @@ libm_CSRC := \
s_isnan.c s_isnanf.c s_isinf.c s_isinff.c s_finitef.c \
s_fdim.c s_fma.c s_fmax.c s_fmin.c \
s_remquo.c w_exp2.c \
- cexp.c
+ cexp.c sincos.c
# Not implemented [yet?], see comment in float_wrappers.c:
# fdimf.o fmaf.o fmaxf.o fminf.o
diff --git a/libm/sincos.c b/libm/sincos.c
new file mode 100644
index 000000000..df6b670f8
--- /dev/null
+++ b/libm/sincos.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2011 William Pitcock <nenolod@dereferenced.org>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <features.h>
+#include <math.h>
+
+libm_hidden_proto(sincos)
+void sincos(double x, double *s, double *c)
+{
+ *s = sin(x);
+ *c = cos(x);
+}
+libm_hidden_def(sincos)
+
+libm_hidden_proto(sincosf)
+void sincosf(float x, float *s, float *c)
+{
+ *s = sinf(x);
+ *c = cosf(x);
+}
+libm_hidden_def(sincosf)
+
+#if defined __UCLIBC_HAS_LONG_DOUBLE_MATH__ && !defined __NO_LONG_DOUBLE_MATH
+libm_hidden_proto(sincosl)
+void sincosl(long double x, long double *s, long double *c)
+{
+ *s = sinl(x);
+ *c = cosl(x);
+}
+libm_hidden_def(sincosl)
+#endif