[vlc-commits] compat: add sincos() and sincosf() replacements

Rémi Denis-Courmont git at videolan.org
Sun Nov 13 12:59:02 CET 2016


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Nov 13 13:27:40 2016 +0200| [90e14b835b807f43acbaa10d330f52fbe591226b] | committer: Rémi Denis-Courmont

compat: add sincos() and sincosf() replacements

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=90e14b835b807f43acbaa10d330f52fbe591226b
---

 compat/sincos.c      | 37 +++++++++++++++++++++++++++++++++++++
 configure.ac         |  5 +++++
 include/vlc_fixups.h |  5 +++++
 3 files changed, 47 insertions(+)

diff --git a/compat/sincos.c b/compat/sincos.c
new file mode 100644
index 0000000..e01698d
--- /dev/null
+++ b/compat/sincos.c
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * sincos.c: GNU sincos() & sincosf() replacements
+ *****************************************************************************
+ * Copyright © 2016 Rémi Denis-Courmont
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <math.h>
+
+void sincos(double r, double *restrict sr, double *restrict cr)
+{
+    *sr = sin(r);
+    *cr = cos(r);
+}
+
+void sincosf(float r, float *restrict sr, float *restrict cr)
+{
+    *sr = sinf(r);
+    *cr = cosf(r);
+}
diff --git a/configure.ac b/configure.ac
index c8900d2..0f5994e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -751,6 +751,11 @@ AC_CHECK_LIB(m,lrintf, [
 AC_CHECK_LIB(m,nanf,
   AC_DEFINE(HAVE_NANF, 1, [Define to 1 if you have the NANF function])
 )
+AC_CHECK_LIB(m,sincos, [
+  AC_DEFINE(HAVE_SINCOS, 1, [Define to 1 if you have the sincos function.])
+], [
+  AC_LIBOBJ([sincos])
+])
 
 dnl Check for dynamic plugins
 LIBDL=""
diff --git a/include/vlc_fixups.h b/include/vlc_fixups.h
index 7b7e619..a3fc6f3 100644
--- a/include/vlc_fixups.h
+++ b/include/vlc_fixups.h
@@ -481,6 +481,11 @@ void freeaddrinfo (struct addrinfo *res);
 #define nanf(tagp) NAN
 #endif
 
+#ifndef HAVE_SINCOS
+void sincos(double, double *, double *);
+void sincosf(float, float *, float *);
+#endif
+
 #ifndef HAVE_REALPATH
 char *realpath(const char * restrict pathname, char * restrict resolved_path);
 #endif



More information about the vlc-commits mailing list