summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2011-10-08 22:10:45 +0200
committerBruno Haible <bruno@clisp.org>2011-10-08 22:10:45 +0200
commita87ae2d257362ae83d26a51ab87d2226ec61d62b (patch)
tree4b140b803d6e7e114f7027b095c97c8ab2498fcb
parentba82f2877733278a887f1754c2f9e4a726dc2251 (diff)
downloadgnulib-a87ae2d257362ae83d26a51ab87d2226ec61d62b.tar.gz
New module 'expf'.
* lib/math.in.h (expf): New declaration. * lib/expf.c: New file. * m4/expf.m4: New file. * m4/math_h.m4 (gl_MATH_H): Test whether expf is declared. (gl_MATH_H_DEFAULTS): Initialize GNULIB_EXPF, HAVE_EXPF. * modules/math (Makefile.am): Substitute GNULIB_EXPF, HAVE_EXPF. * modules/expf: New file. * tests/test-math-c++.cc: Check the declaration of expf. * doc/posix-functions/expf.texi: Mention the new module.
-rw-r--r--ChangeLog11
-rw-r--r--doc/posix-functions/expf.texi10
-rw-r--r--lib/expf.c26
-rw-r--r--lib/math.in.h15
-rw-r--r--m4/expf.m425
-rw-r--r--m4/math_h.m46
-rw-r--r--modules/expf31
-rw-r--r--modules/math2
-rw-r--r--tests/test-math-c++.cc3
9 files changed, 122 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 1a5b3d05ae..1c8d98ad58 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2011-10-08 Bruno Haible <bruno@clisp.org>
+ New module 'expf'.
+ * lib/math.in.h (expf): New declaration.
+ * lib/expf.c: New file.
+ * m4/expf.m4: New file.
+ * m4/math_h.m4 (gl_MATH_H): Test whether expf is declared.
+ (gl_MATH_H_DEFAULTS): Initialize GNULIB_EXPF, HAVE_EXPF.
+ * modules/math (Makefile.am): Substitute GNULIB_EXPF, HAVE_EXPF.
+ * modules/expf: New file.
+ * tests/test-math-c++.cc: Check the declaration of expf.
+ * doc/posix-functions/expf.texi: Mention the new module.
+
exp: Use a .m4 file.
* m4/exp.m4: New file.
* modules/exp (Files): Add it.
diff --git a/doc/posix-functions/expf.texi b/doc/posix-functions/expf.texi
index f5052ccacd..1ad13d9dc8 100644
--- a/doc/posix-functions/expf.texi
+++ b/doc/posix-functions/expf.texi
@@ -4,14 +4,10 @@
POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/expf.html}
-Gnulib module: ---
+Gnulib module: expf
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/expf.c b/lib/expf.c
new file mode 100644
index 0000000000..a16dbea31e
--- /dev/null
+++ b/lib/expf.c
@@ -0,0 +1,26 @@
+/* Exponential 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
+expf (float x)
+{
+ return (float) exp ((double) x);
+}
diff --git a/lib/math.in.h b/lib/math.in.h
index 609cb9cafb..3055b91e50 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -228,6 +228,21 @@ _GL_WARN_ON_USE (cosl, "cosl is unportable - "
#endif
+#if @GNULIB_EXPF@
+# if !@HAVE_EXPF@
+# undef expf
+_GL_FUNCDECL_SYS (expf, float, (float x));
+# endif
+_GL_CXXALIAS_SYS (expf, float, (float x));
+_GL_CXXALIASWARN (expf);
+#elif defined GNULIB_POSIXCHECK
+# undef expf
+# if HAVE_RAW_DECL_EXPF
+_GL_WARN_ON_USE (expf, "expf is unportable - "
+ "use gnulib module expf for portability");
+# endif
+#endif
+
#if @GNULIB_EXPL@
# if !@HAVE_EXPL@ || !@HAVE_DECL_EXPL@
_GL_FUNCDECL_SYS (expl, long double, (long double x));
diff --git a/m4/expf.m4 b/m4/expf.m4
new file mode 100644
index 0000000000..0a9b4c9e9e
--- /dev/null
+++ b/m4/expf.m4
@@ -0,0 +1,25 @@
+# expf.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_EXPF],
+[
+ AC_REQUIRE([gl_MATH_H_DEFAULTS])
+ AC_REQUIRE([gl_FUNC_EXP])
+
+ dnl Test whether expf() exists. Assume that expf(), if it exists, is
+ dnl defined in the same library as exp().
+ save_LIBS="$LIBS"
+ LIBS="$LIBS $EXP_LIBM"
+ AC_CHECK_FUNCS([expf])
+ LIBS="$save_LIBS"
+ if test $ac_cv_func_expf = yes; then
+ EXPF_LIBM="$EXP_LIBM"
+ else
+ HAVE_EXPF=0
+ EXPF_LIBM="$EXP_LIBM"
+ fi
+ AC_SUBST([EXPF_LIBM])
+])
diff --git a/m4/math_h.m4 b/m4/math_h.m4
index ef3331f90a..c307291004 100644
--- a/m4/math_h.m4
+++ b/m4/math_h.m4
@@ -1,4 +1,4 @@
-# math_h.m4 serial 32
+# math_h.m4 serial 33
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,
@@ -39,7 +39,7 @@ AC_DEFUN([gl_MATH_H],
dnl Check for declarations of anything we want to poison if the
dnl corresponding gnulib module is not in use.
gl_WARN_ON_USE_PREPARE([[#include <math.h>]],
- [acosl asinl atanl ceilf ceill cosl expl fabsf floorf floorl fmodf
+ [acosl asinl atanl ceilf ceill cosl expf expl fabsf floorf floorl fmodf
frexpf frexpl
ldexpf ldexpl logb logl modff round roundf roundl sinl sqrtf sqrtl
tanl trunc truncf truncl])
@@ -63,6 +63,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
GNULIB_CEILF=0; AC_SUBST([GNULIB_CEILF])
GNULIB_CEILL=0; AC_SUBST([GNULIB_CEILL])
GNULIB_COSL=0; AC_SUBST([GNULIB_COSL])
+ GNULIB_EXPF=0; AC_SUBST([GNULIB_EXPF])
GNULIB_EXPL=0; AC_SUBST([GNULIB_EXPL])
GNULIB_FABSF=0; AC_SUBST([GNULIB_FABSF])
GNULIB_FLOOR=0; AC_SUBST([GNULIB_FLOOR])
@@ -99,6 +100,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
HAVE_ASINL=1; AC_SUBST([HAVE_ASINL])
HAVE_ATANL=1; AC_SUBST([HAVE_ATANL])
HAVE_COSL=1; AC_SUBST([HAVE_COSL])
+ HAVE_EXPF=1; AC_SUBST([HAVE_EXPF])
HAVE_EXPL=1; AC_SUBST([HAVE_EXPL])
HAVE_FABSF=1; AC_SUBST([HAVE_FABSF])
HAVE_FMODF=1; AC_SUBST([HAVE_FMODF])
diff --git a/modules/expf b/modules/expf
new file mode 100644
index 0000000000..857fa25d45
--- /dev/null
+++ b/modules/expf
@@ -0,0 +1,31 @@
+Description:
+expf() function: exponential function.
+
+Files:
+lib/expf.c
+m4/expf.m4
+
+Depends-on:
+math
+exp [test $HAVE_EXPF = 0]
+
+configure.ac:
+gl_FUNC_EXPF
+if test $HAVE_EXPF = 0; then
+ AC_LIBOBJ([expf])
+fi
+gl_MATH_MODULE_INDICATOR([expf])
+
+Makefile.am:
+
+Include:
+<math.h>
+
+Link:
+$(EXPF_LIBM)
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
diff --git a/modules/math b/modules/math
index 57647eee62..6e9be85628 100644
--- a/modules/math
+++ b/modules/math
@@ -35,6 +35,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's/@''GNULIB_CEILF''@/$(GNULIB_CEILF)/g' \
-e 's/@''GNULIB_CEILL''@/$(GNULIB_CEILL)/g' \
-e 's/@''GNULIB_COSL''@/$(GNULIB_COSL)/g' \
+ -e 's/@''GNULIB_EXPF''@/$(GNULIB_EXPF)/g' \
-e 's/@''GNULIB_EXPL''@/$(GNULIB_EXPL)/g' \
-e 's/@''GNULIB_FABSF''@/$(GNULIB_FABSF)/g' \
-e 's/@''GNULIB_FLOOR''@/$(GNULIB_FLOOR)/g' \
@@ -71,6 +72,7 @@ math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
-e 's|@''HAVE_ASINL''@|$(HAVE_ASINL)|g' \
-e 's|@''HAVE_ATANL''@|$(HAVE_ATANL)|g' \
-e 's|@''HAVE_COSL''@|$(HAVE_COSL)|g' \
+ -e 's|@''HAVE_EXPF''@|$(HAVE_EXPF)|g' \
-e 's|@''HAVE_EXPL''@|$(HAVE_EXPL)|g' \
-e 's|@''HAVE_FABSF''@|$(HAVE_FABSF)|g' \
-e 's|@''HAVE_FMODF''@|$(HAVE_FMODF)|g' \
diff --git a/tests/test-math-c++.cc b/tests/test-math-c++.cc
index e04904ec8e..9461fab421 100644
--- a/tests/test-math-c++.cc
+++ b/tests/test-math-c++.cc
@@ -34,6 +34,9 @@
//SIGNATURE_CHECK (GNULIB_NAMESPACE::cosh, double, (double));
//SIGNATURE_CHECK (GNULIB_NAMESPACE::erf, double, (double));
//SIGNATURE_CHECK (GNULIB_NAMESPACE::erfc, double, (double));
+#if GNULIB_TEST_EXPF
+SIGNATURE_CHECK (GNULIB_NAMESPACE::expf, float, (float));
+#endif
//SIGNATURE_CHECK (GNULIB_NAMESPACE::exp, double, (double));
#if GNULIB_TEST_FABSF
SIGNATURE_CHECK (GNULIB_NAMESPACE::fabsf, float, (float));