From e2de8c10bd15a92eff786f8f51d0a322fbc402ee Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 8 Oct 2011 22:57:59 +0200 Subject: [PATCH] New module 'sinf'. * lib/math.in.h (sinf): New declaration. * lib/sinf.c: New file. * m4/sinf.m4: New file. * m4/math_h.m4 (gl_MATH_H): Test whether sinf is declared. (gl_MATH_H_DEFAULTS): Initialize GNULIB_SINF, HAVE_SINF. * modules/math (Makefile.am): Substitute GNULIB_SINF, HAVE_SINF. * modules/sinf: New file. * tests/test-math-c++.cc: Check the declaration of sinf. * doc/posix-functions/sinf.texi: Mention the new module. --- ChangeLog | 11 +++++++++++ doc/posix-functions/sinf.texi | 10 +++++----- lib/math.in.h | 15 +++++++++++++++ lib/sinf.c | 26 ++++++++++++++++++++++++++ m4/math_h.m4 | 6 ++++-- m4/sinf.m4 | 25 +++++++++++++++++++++++++ modules/math | 2 ++ modules/sinf | 31 +++++++++++++++++++++++++++++++ tests/test-math-c++.cc | 3 +++ 9 files changed, 122 insertions(+), 7 deletions(-) create mode 100644 lib/sinf.c create mode 100644 m4/sinf.m4 create mode 100644 modules/sinf diff --git a/ChangeLog b/ChangeLog index 88aebc381..63609244f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2011-10-08 Bruno Haible + New module 'sinf'. + * lib/math.in.h (sinf): New declaration. + * lib/sinf.c: New file. + * m4/sinf.m4: New file. + * m4/math_h.m4 (gl_MATH_H): Test whether sinf is declared. + (gl_MATH_H_DEFAULTS): Initialize GNULIB_SINF, HAVE_SINF. + * modules/math (Makefile.am): Substitute GNULIB_SINF, HAVE_SINF. + * modules/sinf: New file. + * tests/test-math-c++.cc: Check the declaration of sinf. + * doc/posix-functions/sinf.texi: Mention the new module. + sin: Use a .m4 file. * m4/sin.m4: New file. * modules/sin (Files): Add it. diff --git a/doc/posix-functions/sinf.texi b/doc/posix-functions/sinf.texi index 6b9f6a12d..db4db150a 100644 --- a/doc/posix-functions/sinf.texi +++ b/doc/posix-functions/sinf.texi @@ -4,14 +4,10 @@ POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/sinf.html} -Gnulib module: --- +Gnulib module: sinf Portability problems fixed by Gnulib: @itemize -@end itemize - -Portability problems not fixed by Gnulib: -@itemize @item This function is missing on some platforms: Minix 3.1.8, AIX 5.1, Solaris 9. @@ -19,3 +15,7 @@ Minix 3.1.8, AIX 5.1, Solaris 9. This function is only defined as a macro with arguments on some platforms: MSVC 9. @end itemize + +Portability problems not fixed by Gnulib: +@itemize +@end itemize diff --git a/lib/math.in.h b/lib/math.in.h index c2ea02386..b27b65169 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -647,6 +647,21 @@ _GL_WARN_ON_USE (roundl, "roundl is unportable - " #endif +#if @GNULIB_SINF@ +# if !@HAVE_SINF@ +# undef sinf +_GL_FUNCDECL_SYS (sinf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (sinf, float, (float x)); +_GL_CXXALIASWARN (sinf); +#elif defined GNULIB_POSIXCHECK +# undef sinf +# if HAVE_RAW_DECL_SINF +_GL_WARN_ON_USE (sinf, "sinf is unportable - " + "use gnulib module sinf for portability"); +# endif +#endif + #if @GNULIB_SINL@ # if !@HAVE_SINL@ || !@HAVE_DECL_SINL@ _GL_FUNCDECL_SYS (sinl, long double, (long double x)); diff --git a/lib/sinf.c b/lib/sinf.c new file mode 100644 index 000000000..e6a1d557f --- /dev/null +++ b/lib/sinf.c @@ -0,0 +1,26 @@ +/* Sine function. + Copyright (C) 2011 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +float +sinf (float x) +{ + return (float) sin ((double) x); +} diff --git a/m4/math_h.m4 b/m4/math_h.m4 index 4c47bd79d..dc8695a9a 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -1,4 +1,4 @@ -# math_h.m4 serial 36 +# math_h.m4 serial 37 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -42,7 +42,7 @@ AC_DEFUN([gl_MATH_H], [acosl asinl atanl ceilf ceill cosl expf expl fabsf floorf floorl fmodf frexpf frexpl ldexpf ldexpl logb logf logl log10f modff powf - round roundf roundl sinl sqrtf sqrtl + round roundf roundl sinf sinl sqrtf sqrtl tanl trunc truncf truncl]) ]) @@ -92,6 +92,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], GNULIB_ROUNDF=0; AC_SUBST([GNULIB_ROUNDF]) GNULIB_ROUNDL=0; AC_SUBST([GNULIB_ROUNDL]) GNULIB_SIGNBIT=0; AC_SUBST([GNULIB_SIGNBIT]) + GNULIB_SINF=0; AC_SUBST([GNULIB_SINF]) GNULIB_SINL=0; AC_SUBST([GNULIB_SINL]) GNULIB_SQRTF=0; AC_SUBST([GNULIB_SQRTF]) GNULIB_SQRTL=0; AC_SUBST([GNULIB_SQRTL]) @@ -118,6 +119,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], HAVE_LOG10F=1; AC_SUBST([HAVE_LOG10F]) HAVE_MODFF=1; AC_SUBST([HAVE_MODFF]) HAVE_POWF=1; AC_SUBST([HAVE_POWF]) + HAVE_SINF=1; AC_SUBST([HAVE_SINF]) HAVE_SINL=1; AC_SUBST([HAVE_SINL]) HAVE_SQRTF=1; AC_SUBST([HAVE_SQRTF]) HAVE_SQRTL=1; AC_SUBST([HAVE_SQRTL]) diff --git a/m4/sinf.m4 b/m4/sinf.m4 new file mode 100644 index 000000000..dbe84ea00 --- /dev/null +++ b/m4/sinf.m4 @@ -0,0 +1,25 @@ +# sinf.m4 serial 1 +dnl Copyright (C) 2011 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_SINF], +[ + AC_REQUIRE([gl_MATH_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_SIN]) + + dnl Test whether sinf() exists. Assume that sinf(), if it exists, is + dnl defined in the same library as sin(). + save_LIBS="$LIBS" + LIBS="$LIBS $SIN_LIBM" + AC_CHECK_FUNCS([sinf]) + LIBS="$save_LIBS" + if test $ac_cv_func_sinf = yes; then + SINF_LIBM="$SIN_LIBM" + else + HAVE_SINF=0 + SINF_LIBM="$SIN_LIBM" + fi + AC_SUBST([SINF_LIBM]) +]) diff --git a/modules/math b/modules/math index 230279449..1dc02391d 100644 --- a/modules/math +++ b/modules/math @@ -63,6 +63,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's/@''GNULIB_ROUNDF''@/$(GNULIB_ROUNDF)/g' \ -e 's/@''GNULIB_ROUNDL''@/$(GNULIB_ROUNDL)/g' \ -e 's/@''GNULIB_SIGNBIT''@/$(GNULIB_SIGNBIT)/g' \ + -e 's/@''GNULIB_SINF''@/$(GNULIB_SINF)/g' \ -e 's/@''GNULIB_SINL''@/$(GNULIB_SINL)/g' \ -e 's/@''GNULIB_SQRTF''@/$(GNULIB_SQRTF)/g' \ -e 's/@''GNULIB_SQRTL''@/$(GNULIB_SQRTL)/g' \ @@ -89,6 +90,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''HAVE_LOG10F''@|$(HAVE_LOG10F)|g' \ -e 's|@''HAVE_MODFF''@|$(HAVE_MODFF)|g' \ -e 's|@''HAVE_POWF''@|$(HAVE_POWF)|g' \ + -e 's|@''HAVE_SINF''@|$(HAVE_SINF)|g' \ -e 's|@''HAVE_SINL''@|$(HAVE_SINL)|g' \ -e 's|@''HAVE_SQRTF''@|$(HAVE_SQRTF)|g' \ -e 's|@''HAVE_SQRTL''@|$(HAVE_SQRTL)|g' \ diff --git a/modules/sinf b/modules/sinf new file mode 100644 index 000000000..f3496871d --- /dev/null +++ b/modules/sinf @@ -0,0 +1,31 @@ +Description: +sinf() function: sine function. + +Files: +lib/sinf.c +m4/sinf.m4 + +Depends-on: +math +sin [test $HAVE_SINF = 0] + +configure.ac: +gl_FUNC_SINF +if test $HAVE_SINF = 0; then + AC_LIBOBJ([sinf]) +fi +gl_MATH_MODULE_INDICATOR([sinf]) + +Makefile.am: + +Include: + + +Link: +$(SINF_LIBM) + +License: +LGPL + +Maintainer: +Bruno Haible diff --git a/tests/test-math-c++.cc b/tests/test-math-c++.cc index e93f4d9bb..64eb4653e 100644 --- a/tests/test-math-c++.cc +++ b/tests/test-math-c++.cc @@ -82,6 +82,9 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::powf, float, (float, float)); //SIGNATURE_CHECK (GNULIB_NAMESPACE::pow, double, (double, double)); //SIGNATURE_CHECK (GNULIB_NAMESPACE::remainder, double, (double, double)); //SIGNATURE_CHECK (GNULIB_NAMESPACE::rint, double, (double)); +#if GNULIB_TEST_SINF +SIGNATURE_CHECK (GNULIB_NAMESPACE::sinf, float, (float)); +#endif //SIGNATURE_CHECK (GNULIB_NAMESPACE::sin, double, (double)); //SIGNATURE_CHECK (GNULIB_NAMESPACE::sinh, double, (double)); #if GNULIB_TEST_SQRTF -- 2.11.0