Mercurial > hg > octave-nkf > gnulib-hg
changeset 15878:c0c190f3cccb
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.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 08 Oct 2011 23:16:29 +0200 |
parents | b3bb8502c388 |
children | 1848649defc7 |
files | ChangeLog doc/posix-functions/tanf.texi lib/math.in.h lib/tanf.c m4/math_h.m4 m4/tanf.m4 modules/math modules/tanf tests/test-math-c++.cc |
diffstat | 9 files changed, 122 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2011-10-08 Bruno Haible <bruno@clisp.org> + 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.
--- 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 @@ 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
--- a/lib/math.in.h +++ b/lib/math.in.h @@ -722,6 +722,21 @@ #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));
new file mode 100644 --- /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 <http://www.gnu.org/licenses/>. */ + +#include <config.h> + +/* Specification. */ +#include <math.h> + +float +tanf (float x) +{ + return (float) tan ((double) x); +}
--- 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 @@ 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 @@ 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 @@ 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])
new file mode 100644 --- /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]) +])
--- a/modules/math +++ b/modules/math @@ -68,6 +68,7 @@ -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 @@ -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' \
new file mode 100644 --- /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: +<math.h> + +Link: +$(TANF_LIBM) + +License: +LGPL + +Maintainer: +Bruno Haible
--- a/tests/test-math-c++.cc +++ b/tests/test-math-c++.cc @@ -94,6 +94,9 @@ 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));