From 3a018a7f9b0c254103a6c191b74a4b72e296af34 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 8 Oct 2011 23:16:29 +0200 Subject: [PATCH] New module 'tanf'. * lib/math.in.h (tanf): New declaration. * lib/tanf.c: New file. * m4/tanf.m4: New file. * m4/math_h.m4 (gl_MATH_H): Test whether tanf is declared. (gl_MATH_H_DEFAULTS): Initialize GNULIB_TANF, HAVE_TANF. * modules/math (Makefile.am): Substitute GNULIB_TANF, HAVE_TANF. * modules/tanf: New file. * tests/test-math-c++.cc: Check the declaration of tanf. * doc/posix-functions/tanf.texi: Mention the new module. --- ChangeLog | 11 +++++++++++ doc/posix-functions/tanf.texi | 10 +++++----- lib/math.in.h | 15 +++++++++++++++ lib/tanf.c | 26 ++++++++++++++++++++++++++ m4/math_h.m4 | 6 ++++-- m4/tanf.m4 | 25 +++++++++++++++++++++++++ modules/math | 2 ++ modules/tanf | 31 +++++++++++++++++++++++++++++++ tests/test-math-c++.cc | 3 +++ 9 files changed, 122 insertions(+), 7 deletions(-) create mode 100644 lib/tanf.c create mode 100644 m4/tanf.m4 create mode 100644 modules/tanf diff --git a/ChangeLog b/ChangeLog index 7d75aca1e..38d0245fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2011-10-08 Bruno Haible + New module 'tanf'. + * lib/math.in.h (tanf): New declaration. + * lib/tanf.c: New file. + * m4/tanf.m4: New file. + * m4/math_h.m4 (gl_MATH_H): Test whether tanf is declared. + (gl_MATH_H_DEFAULTS): Initialize GNULIB_TANF, HAVE_TANF. + * modules/math (Makefile.am): Substitute GNULIB_TANF, HAVE_TANF. + * modules/tanf: New file. + * tests/test-math-c++.cc: Check the declaration of tanf. + * doc/posix-functions/tanf.texi: Mention the new module. + tan: Use a .m4 file. * m4/tan.m4: New file. * modules/tan (Files): Add it. diff --git a/doc/posix-functions/tanf.texi b/doc/posix-functions/tanf.texi index a4bebb087..ede60fcd6 100644 --- a/doc/posix-functions/tanf.texi +++ b/doc/posix-functions/tanf.texi @@ -4,14 +4,10 @@ POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/tanf.html} -Gnulib module: --- +Gnulib module: tanf 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 4cbdbb3b6..053774ea3 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -722,6 +722,21 @@ _GL_WARN_ON_USE (sqrtl, "sqrtl is unportable - " #endif +#if @GNULIB_TANF@ +# if !@HAVE_TANF@ +# undef tanf +_GL_FUNCDECL_SYS (tanf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (tanf, float, (float x)); +_GL_CXXALIASWARN (tanf); +#elif defined GNULIB_POSIXCHECK +# undef tanf +# if HAVE_RAW_DECL_TANF +_GL_WARN_ON_USE (tanf, "tanf is unportable - " + "use gnulib module tanf for portability"); +# endif +#endif + #if @GNULIB_TANL@ # if !@HAVE_TANL@ || !@HAVE_DECL_TANL@ _GL_FUNCDECL_SYS (tanl, long double, (long double x)); diff --git a/lib/tanf.c b/lib/tanf.c new file mode 100644 index 000000000..39e1e1035 --- /dev/null +++ b/lib/tanf.c @@ -0,0 +1,26 @@ +/* Tangent 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 +tanf (float x) +{ + return (float) tan ((double) x); +} diff --git a/m4/math_h.m4 b/m4/math_h.m4 index ce1ef0b6f..1a78358a3 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -1,4 +1,4 @@ -# math_h.m4 serial 38 +# math_h.m4 serial 39 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, @@ -43,7 +43,7 @@ AC_DEFUN([gl_MATH_H], expf expl fabsf floorf floorl fmodf frexpf frexpl ldexpf ldexpl logb logf logl log10f modff powf round roundf roundl sinf sinl sqrtf sqrtl - tanl trunc truncf truncl]) + tanf tanl trunc truncf truncl]) ]) AC_DEFUN([gl_MATH_MODULE_INDICATOR], @@ -97,6 +97,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], GNULIB_SINL=0; AC_SUBST([GNULIB_SINL]) GNULIB_SQRTF=0; AC_SUBST([GNULIB_SQRTF]) GNULIB_SQRTL=0; AC_SUBST([GNULIB_SQRTL]) + GNULIB_TANF=0; AC_SUBST([GNULIB_TANF]) GNULIB_TANL=0; AC_SUBST([GNULIB_TANL]) GNULIB_TRUNC=0; AC_SUBST([GNULIB_TRUNC]) GNULIB_TRUNCF=0; AC_SUBST([GNULIB_TRUNCF]) @@ -125,6 +126,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], HAVE_SINL=1; AC_SUBST([HAVE_SINL]) HAVE_SQRTF=1; AC_SUBST([HAVE_SQRTF]) HAVE_SQRTL=1; AC_SUBST([HAVE_SQRTL]) + HAVE_TANF=1; AC_SUBST([HAVE_TANF]) HAVE_TANL=1; AC_SUBST([HAVE_TANL]) HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL]) HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL]) diff --git a/m4/tanf.m4 b/m4/tanf.m4 new file mode 100644 index 000000000..37f48743b --- /dev/null +++ b/m4/tanf.m4 @@ -0,0 +1,25 @@ +# tanf.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_TANF], +[ + AC_REQUIRE([gl_MATH_H_DEFAULTS]) + AC_REQUIRE([gl_FUNC_TAN]) + + dnl Test whether tanf() exists. Assume that tanf(), if it exists, is + dnl defined in the same library as tan(). + save_LIBS="$LIBS" + LIBS="$LIBS $TAN_LIBM" + AC_CHECK_FUNCS([tanf]) + LIBS="$save_LIBS" + if test $ac_cv_func_tanf = yes; then + TANF_LIBM="$TAN_LIBM" + else + HAVE_TANF=0 + TANF_LIBM="$TAN_LIBM" + fi + AC_SUBST([TANF_LIBM]) +]) diff --git a/modules/math b/modules/math index adff1be13..876ddc9d0 100644 --- a/modules/math +++ b/modules/math @@ -68,6 +68,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's/@''GNULIB_SINL''@/$(GNULIB_SINL)/g' \ -e 's/@''GNULIB_SQRTF''@/$(GNULIB_SQRTF)/g' \ -e 's/@''GNULIB_SQRTL''@/$(GNULIB_SQRTL)/g' \ + -e 's/@''GNULIB_TANF''@/$(GNULIB_TANF)/g' \ -e 's/@''GNULIB_TANL''@/$(GNULIB_TANL)/g' \ -e 's/@''GNULIB_TRUNC''@/$(GNULIB_TRUNC)/g' \ -e 's/@''GNULIB_TRUNCF''@/$(GNULIB_TRUNCF)/g' \ @@ -96,6 +97,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''HAVE_SINL''@|$(HAVE_SINL)|g' \ -e 's|@''HAVE_SQRTF''@|$(HAVE_SQRTF)|g' \ -e 's|@''HAVE_SQRTL''@|$(HAVE_SQRTL)|g' \ + -e 's|@''HAVE_TANF''@|$(HAVE_TANF)|g' \ -e 's|@''HAVE_TANL''@|$(HAVE_TANL)|g' \ -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \ -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \ diff --git a/modules/tanf b/modules/tanf new file mode 100644 index 000000000..943f7c786 --- /dev/null +++ b/modules/tanf @@ -0,0 +1,31 @@ +Description: +tanf() function: tangent function. + +Files: +lib/tanf.c +m4/tanf.m4 + +Depends-on: +math +tan [test $HAVE_TANF = 0] + +configure.ac: +gl_FUNC_TANF +if test $HAVE_TANF = 0; then + AC_LIBOBJ([tanf]) +fi +gl_MATH_MODULE_INDICATOR([tanf]) + +Makefile.am: + +Include: + + +Link: +$(TANF_LIBM) + +License: +LGPL + +Maintainer: +Bruno Haible diff --git a/tests/test-math-c++.cc b/tests/test-math-c++.cc index 32542fed3..a839f8f36 100644 --- a/tests/test-math-c++.cc +++ b/tests/test-math-c++.cc @@ -94,6 +94,9 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::sinf, float, (float)); SIGNATURE_CHECK (GNULIB_NAMESPACE::sqrtf, float, (float)); #endif //SIGNATURE_CHECK (GNULIB_NAMESPACE::sqrt, double, (double)); +#if GNULIB_TEST_TANF +SIGNATURE_CHECK (GNULIB_NAMESPACE::tanf, float, (float)); +#endif //SIGNATURE_CHECK (GNULIB_NAMESPACE::tan, double, (double)); //SIGNATURE_CHECK (GNULIB_NAMESPACE::tanh, double, (double)); //SIGNATURE_CHECK (GNULIB_NAMESPACE::y0, double, (double)); -- 2.11.0