New module 'tanf'.
authorBruno Haible <bruno@clisp.org>
Sat, 8 Oct 2011 21:16:29 +0000 (23:16 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 8 Oct 2011 21:16:29 +0000 (23:16 +0200)
* 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
doc/posix-functions/tanf.texi
lib/math.in.h
lib/tanf.c [new file with mode: 0644]
m4/math_h.m4
m4/tanf.m4 [new file with mode: 0644]
modules/math
modules/tanf [new file with mode: 0644]
tests/test-math-c++.cc

index 7d75aca..38d0245 100644 (file)
--- 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.
index a4bebb0..ede60fc 100644 (file)
@@ -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
index 4cbdbb3..053774e 100644 (file)
@@ -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 (file)
index 0000000..39e1e10
--- /dev/null
@@ -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);
+}
index ce1ef0b..1a78358 100644 (file)
@@ -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 (file)
index 0000000..37f4874
--- /dev/null
@@ -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])
+])
index adff1be..876ddc9 100644 (file)
@@ -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 (file)
index 0000000..943f7c7
--- /dev/null
@@ -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
index 32542fe..a839f8f 100644 (file)
@@ -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));