Skip to content

Commit

Permalink
compat: add sincos() and sincosf() replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémi Denis-Courmont committed Nov 13, 2016
1 parent eac6a8e commit 90e14b8
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
37 changes: 37 additions & 0 deletions compat/sincos.c
Original file line number Diff line number Diff line change
@@ -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);
}
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down
5 changes: 5 additions & 0 deletions include/vlc_fixups.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 90e14b8

Please sign in to comment.